dsh-github-copilot 0.4.2-alpha.4 → 0.4.2-alpha.5

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.
@@ -1,4 +1,4 @@
1
- import { a as DiagnosticsPendingSchema, c as DiagnosticsViewSchema, n as DIAGNOSTICS_OPERATIONS, r as DIAGNOSTICS_REASONS, s as DiagnosticsSnapshotSchema } from "./diagnostics-types-CpyhNCSg.js";
1
+ import { a as DiagnosticsPendingSchema, c as DiagnosticsViewSchema, n as DIAGNOSTICS_OPERATIONS, r as DIAGNOSTICS_REASONS, s as DiagnosticsSnapshotSchema } from "./diagnostics-types-Cd4BmeOe.js";
2
2
  import { z } from "zod";
3
3
  //#region lib/types/diagnostics-analysis.js
4
4
  const RETENTION_MS = 12096e5;
@@ -342,7 +342,9 @@ const composition = z.discriminatedUnion("state", [z.object({
342
342
  "size-limit",
343
343
  "work-limit",
344
344
  "invalid-json",
345
- "unsupported-shape"
345
+ "unsupported-shape",
346
+ "cancelled",
347
+ "time-limit"
346
348
  ]),
347
349
  totalBytes: integer$1.optional()
348
350
  }).strict()]);
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as GITHUB_COPILOT_PREVIEW_PROVIDER_ID, i as GITHUB_COPILOT_CREDENTIAL_KEY, n as GITHUB_COPILOT_AUTO_INTELLIGENCE_MODEL_ID, o as GITHUB_COPILOT_PROVIDER_ID, r as GITHUB_COPILOT_AUTO_MODEL_ID, s as autoModelPreference, t as GITHUB_COPILOT_AUTO_EFFICIENCY_MODEL_ID } from "./copilot-identity-DRZY_d2X.js";
2
- import { S as normalizeExcludedModelIds, _ as AutoAllocationSchema, b as ModelExclusionTurns, c as DiagnosticsViewSchema, d as diagnosticsReason, f as REQUEST_DIAGNOSTICS_RETENTION_MS, g as AUTO_ALLOCATION_POLICY, h as emptyAutoAllocationDiagnostics, i as DIAGNOSTICS_RETENTION_MS, l as diagnosticsBucket, m as AutoAllocationDiagnosticsCollector, o as DiagnosticsRowSchema, p as RequestDiagnosticSchema, s as DiagnosticsSnapshotSchema, u as diagnosticsOutcome, v as allocateAutoModel, x as excludedModelSet, y as normalizeHighCostModelIds } from "./diagnostics-types-CpyhNCSg.js";
2
+ import { S as normalizeExcludedModelIds, _ as AutoAllocationSchema, b as ModelExclusionTurns, c as DiagnosticsViewSchema, d as diagnosticsReason, f as REQUEST_DIAGNOSTICS_RETENTION_MS, g as AUTO_ALLOCATION_POLICY, h as emptyAutoAllocationDiagnostics, i as DIAGNOSTICS_RETENTION_MS, l as diagnosticsBucket, m as AutoAllocationDiagnosticsCollector, o as DiagnosticsRowSchema, p as RequestDiagnosticSchema, s as DiagnosticsSnapshotSchema, u as diagnosticsOutcome, v as allocateAutoModel, x as excludedModelSet, y as normalizeHighCostModelIds } from "./diagnostics-types-Cd4BmeOe.js";
3
3
  import { C as providerErrorMessage, D as onSettingsNamespaceUpdated, E as readCopilotCatalog, O as readConfigValue, S as isAbortError, T as isPluginPreviewProvider, _ as sameCandidates, a as COPILOT_HOSTED_SEARCH_PROVIDER_ID, b as currentSearchSelection, c as applyRequestAuth, d as ANTHROPIC_WEB_SEARCH_TOOL_TYPE, f as GITHUB_COPILOT_CREDENTIAL_KEY$1, g as candidatesForRoute, h as WEB_SEARCH_TOOL_TYPE, i as describeSearchBackend, k as readSettingsNamespace, l as normalizeRequestAuth, m as SearchPlan, n as routeSessionSearch, o as GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID, p as RESPONSES_WEB_SEARCH_TOOL_TYPE, r as DescribedSearchFallbackError, s as createTraditionalSearchProvider, t as isCopilotSearchSelection, u as providerRequestHeaders, v as currentChatRoute, w as readBounded, x as abortable$1, y as currentSearchInitiator } from "./search-routing-CV2hs8as.js";
4
4
  import { a as selectCompactionReasoning, i as resolveRequestBudgetPolicy, n as assessRequestBudget, r as calculateRequestBudget, t as DEFAULT_REQUEST_BUDGET_POLICY } from "./request-budget-DLY_aRq0.js";
5
5
  import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
@@ -16,12 +16,12 @@ import { getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
16
16
  import { credentialKey, credentialRef } from "@deepseek-ai/dsh-credentials";
17
17
  import { WebError } from "@deepseek-ai/dsh-web";
18
18
  import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "@earendil-works/pi-ai/api/github-copilot-headers";
19
+ import { setImmediate } from "node:timers/promises";
19
20
  import { AsyncLocalStorage } from "node:async_hooks";
20
21
  import { channel } from "node:diagnostics_channel";
21
22
  import { constants, gzip } from "node:zlib";
22
23
  import * as dshLlm from "@deepseek-ai/dsh-llm";
23
24
  import { CONTEXT_WINDOW_EXCEEDED_CODE, LlmError, ReasoningEffortId, attributionHeaders, boundContextSummary, callConfigEquals, contentHasImage, createUserMessage, isAgentLoopRequest, resolveImageAttachmentAccess, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
24
- import { setImmediate } from "node:timers/promises";
25
25
  import { Config as Config$1, PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
26
26
  import { estimateContextTokens, estimateMessageTokens } from "@earendil-works/pi-ai/utils/estimate";
27
27
  //#region lib/types/diagnostics-collector.js
@@ -59,6 +59,7 @@ var DiagnosticsCollector = class {
59
59
  autoAllocationEnabled = false;
60
60
  requestEnabled = false;
61
61
  requestHandles = /* @__PURE__ */ new Set();
62
+ requestGeneration = 0;
62
63
  lastWall = 0;
63
64
  autoAllocation;
64
65
  constructor(version, layer, changed = () => {}, wall = Date.now, mono = () => performance.now()) {
@@ -112,6 +113,7 @@ var DiagnosticsCollector = class {
112
113
  if (!Number.isSafeInteger(epoch)) throw new Error("COPILOT_DIAGNOSTICS_EPOCH_LIMIT");
113
114
  this.live.clear();
114
115
  this.requestHandles.clear();
116
+ this.requestGeneration++;
115
117
  this.autoAllocation.clear();
116
118
  this.data = {
117
119
  ...emptyDiagnostics(),
@@ -242,6 +244,7 @@ var DiagnosticsCollector = class {
242
244
  this.setRequestEnabled(false);
243
245
  }
244
246
  setRequestEnabled(enabled) {
247
+ if (this.requestEnabled !== enabled) this.requestGeneration++;
245
248
  if (this.requestEnabled && !enabled) for (const handle of this.requestHandles) handle.finish("interrupted", "unknown");
246
249
  this.requestEnabled = enabled;
247
250
  }
@@ -258,6 +261,8 @@ var DiagnosticsCollector = class {
258
261
  return;
259
262
  }
260
263
  const startedAt = this.wall(), startedMono = this.mono();
264
+ const generation = this.requestGeneration;
265
+ let retainedRow;
261
266
  const base = {
262
267
  ...start,
263
268
  version: this.version,
@@ -266,6 +271,32 @@ var DiagnosticsCollector = class {
266
271
  };
267
272
  let headers = {};
268
273
  const handle = {
274
+ isCurrent: () => this.requestEnabled && this.requestGeneration === generation && (this.requestHandles.has(handle) || retainedRow !== void 0 && retainedRow.startedAt > this.wall() - 864e5 && this.data.requests?.rows.includes(retainedRow) === true),
275
+ composition: (evidence) => {
276
+ if (!handle.isCurrent?.()) return;
277
+ const composition = RequestDiagnosticSchema.shape.composition.parse(evidence);
278
+ if (this.requestHandles.has(handle)) {
279
+ base.composition = composition;
280
+ return;
281
+ }
282
+ const current = this.data.requests;
283
+ if (!current || !retainedRow) return;
284
+ const next = {
285
+ ...retainedRow,
286
+ composition
287
+ };
288
+ const candidate = {
289
+ ...this.data,
290
+ requests: {
291
+ ...current,
292
+ rows: current.rows.map((row) => row === retainedRow ? next : row)
293
+ }
294
+ };
295
+ if (!DiagnosticsSnapshotSchema.safeParse(candidate).success) throw new Error("COPILOT_DIAGNOSTICS_CAPACITY");
296
+ this.data = candidate;
297
+ retainedRow = next;
298
+ this.changed();
299
+ },
269
300
  headers: (httpStatus, ms, upload) => {
270
301
  if (!this.requestHandles.has(handle)) return;
271
302
  headers = {
@@ -306,8 +337,10 @@ var DiagnosticsCollector = class {
306
337
  evicted: Math.min(Number.MAX_SAFE_INTEGER, current.evicted + evicted)
307
338
  }
308
339
  };
309
- if (DiagnosticsSnapshotSchema.safeParse(candidate).success) this.data = candidate;
310
- else current.dropped = Math.min(Number.MAX_SAFE_INTEGER, current.dropped + 1);
340
+ if (DiagnosticsSnapshotSchema.safeParse(candidate).success) {
341
+ this.data = candidate;
342
+ retainedRow = rows.includes(parsed.data) ? parsed.data : void 0;
343
+ } else current.dropped = Math.min(Number.MAX_SAFE_INTEGER, current.dropped + 1);
311
344
  this.changed();
312
345
  }
313
346
  };
@@ -460,7 +493,7 @@ const result$1 = strictRemoteCodec("dsh-github-copilot#DiagnosticsView", Diagnos
460
493
  var package_default = {
461
494
  name: "dsh-github-copilot",
462
495
  description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
463
- version: "0.4.2-alpha.4",
496
+ version: "0.4.2-alpha.5",
464
497
  releaseNotes: "CHANGELOG.md",
465
498
  publishConfig: {
466
499
  "access": "public",
@@ -3596,6 +3629,257 @@ async function isCopilotInputItemScopeError(response, signal) {
3596
3629
  //#region lib/types/request-body-timeout-marker.js
3597
3630
  const REQUEST_BODY_TIMEOUT_MARKER = "COPILOT_REQUEST_BODY_TIMEOUT: Copilot returned HTTP 408 / user_request_timeout while reading the request body; this is not context-window overflow.";
3598
3631
  //#endregion
3632
+ //#region lib/types/request-body-composition.js
3633
+ const REQUEST_BODY_COMPOSITION_LIMITS = Object.freeze({
3634
+ ...REQUEST_BODY_EVIDENCE_LIMITS,
3635
+ bytes: 33554432,
3636
+ sliceCharacters: 65536,
3637
+ elapsedMs: 2e3,
3638
+ concurrent: 4
3639
+ });
3640
+ var ScanError = class extends Error {
3641
+ state;
3642
+ constructor(state) {
3643
+ super(state);
3644
+ this.state = state;
3645
+ }
3646
+ };
3647
+ let activeScans = 0;
3648
+ /** Only bounded keys/discriminators are decoded; payload values never form an object graph. */
3649
+ async function requestBodyComposition(payload, protocol, options = {}) {
3650
+ if (payload === void 0) return { state: "unavailable" };
3651
+ const body = payload;
3652
+ const totalBytes = Buffer.byteLength(body, "utf8");
3653
+ if (totalBytes > REQUEST_BODY_COMPOSITION_LIMITS.bytes) return {
3654
+ state: "size-limit",
3655
+ totalBytes
3656
+ };
3657
+ if (activeScans >= REQUEST_BODY_COMPOSITION_LIMITS.concurrent) return {
3658
+ state: "work-limit",
3659
+ totalBytes
3660
+ };
3661
+ activeScans++;
3662
+ const startedAt = performance.now();
3663
+ let position = 0, nextYield = 0, values = 0, tokens = 0;
3664
+ let conversationBytes = 0, toolSchemaBytes = 0, systemBytes = 0, imageBlockBytes = 0, opaqueReplayBytes = 0;
3665
+ let conversationArray = false;
3666
+ const conversationKey = protocol === "openai-responses" ? "input" : "messages";
3667
+ const systemKey = protocol === "openai-responses" ? "instructions" : protocol === "anthropic-messages" ? "system" : void 0;
3668
+ const check = () => {
3669
+ if (options.signal?.aborted || options.isCurrent?.() === false) throw new ScanError("cancelled");
3670
+ if (performance.now() - startedAt >= REQUEST_BODY_COMPOSITION_LIMITS.elapsedMs) throw new ScanError("time-limit");
3671
+ };
3672
+ function* checkpoint() {
3673
+ if (position >= nextYield) {
3674
+ nextYield = position + REQUEST_BODY_COMPOSITION_LIMITS.sliceCharacters;
3675
+ yield;
3676
+ check();
3677
+ }
3678
+ }
3679
+ const bytes = (span) => Buffer.byteLength(body.slice(span.start, span.end), "utf8");
3680
+ const blank = (code) => code === 32 || code === 9 || code === 10 || code === 13;
3681
+ function* whitespace() {
3682
+ while (blank(body.charCodeAt(position))) {
3683
+ position++;
3684
+ if (position >= nextYield) yield* checkpoint();
3685
+ }
3686
+ }
3687
+ function* string(decode, key = false) {
3688
+ if (++tokens > REQUEST_BODY_COMPOSITION_LIMITS.tokens) throw new ScanError("work-limit");
3689
+ const start = position++;
3690
+ while (position < body.length) {
3691
+ if (position >= nextYield) yield* checkpoint();
3692
+ const code = body.charCodeAt(position++);
3693
+ if (code === 34) {
3694
+ if (key && position - start > REQUEST_BODY_COMPOSITION_LIMITS.keyCharacters) throw new ScanError("work-limit");
3695
+ const span = {
3696
+ kind: "string",
3697
+ start,
3698
+ end: position,
3699
+ image: 0,
3700
+ replay: 0
3701
+ };
3702
+ if (decode && position - start <= REQUEST_BODY_COMPOSITION_LIMITS.keyCharacters) span.text = JSON.parse(body.slice(start, position));
3703
+ return span;
3704
+ }
3705
+ if (code < 32) throw new ScanError("invalid-json");
3706
+ if (code === 92) {
3707
+ const escaped = body[position++];
3708
+ if (escaped === "u") {
3709
+ if (!/^[a-fA-F0-9]{4}$/.test(body.slice(position, position + 4))) throw new ScanError("invalid-json");
3710
+ position += 4;
3711
+ } else if (escaped === void 0 || !"\"\\/bfnrt".includes(escaped)) throw new ScanError("invalid-json");
3712
+ }
3713
+ if (key && position - start > REQUEST_BODY_COMPOSITION_LIMITS.keyCharacters) throw new ScanError("work-limit");
3714
+ }
3715
+ throw new ScanError("invalid-json");
3716
+ }
3717
+ function* visit(depth, location, decode = false) {
3718
+ yield* checkpoint();
3719
+ if (++values > REQUEST_BODY_COMPOSITION_LIMITS.values || ++tokens > REQUEST_BODY_COMPOSITION_LIMITS.tokens || depth > REQUEST_BODY_COMPOSITION_LIMITS.depth) throw new ScanError("work-limit");
3720
+ yield* whitespace();
3721
+ const start = position, character = body[position];
3722
+ if (character === "\"") return yield* string(decode);
3723
+ if (character === "[") {
3724
+ position++;
3725
+ const result = {
3726
+ kind: "array",
3727
+ start,
3728
+ end: 0,
3729
+ image: 0,
3730
+ replay: 0
3731
+ };
3732
+ yield* whitespace();
3733
+ if (body[position] !== "]") while (true) {
3734
+ const child = yield* visit(depth + 1, location);
3735
+ result.image += child.image;
3736
+ result.replay += child.replay;
3737
+ yield* whitespace();
3738
+ if (body[position] === "]") break;
3739
+ if (body[position++] !== ",") throw new ScanError("invalid-json");
3740
+ }
3741
+ position++;
3742
+ result.end = position;
3743
+ return result;
3744
+ }
3745
+ if (character === "{") {
3746
+ position++;
3747
+ const result = {
3748
+ kind: "object",
3749
+ start,
3750
+ end: 0,
3751
+ image: 0,
3752
+ replay: 0,
3753
+ strings: /* @__PURE__ */ new Set()
3754
+ };
3755
+ const seen = /* @__PURE__ */ new Set();
3756
+ let source, imageUrl, output;
3757
+ let encrypted = 0, signature = 0, redacted = 0;
3758
+ yield* whitespace();
3759
+ if (body[position] !== "}") while (true) {
3760
+ if (body[position] !== "\"") throw new ScanError("invalid-json");
3761
+ const key = (yield* string(true, true)).text;
3762
+ if (seen.has(key)) throw new ScanError("invalid-json");
3763
+ seen.add(key);
3764
+ yield* whitespace();
3765
+ if (body[position++] !== ":") throw new ScanError("invalid-json");
3766
+ const content = (location === "conversation" || location === "content") && key === "content";
3767
+ const possibleOutput = protocol === "openai-responses" && location === "conversation" && key === "output";
3768
+ const child = yield* visit(depth + 1, depth === 0 && key === conversationKey ? "conversation" : content || possibleOutput ? "content" : "other", key === "type");
3769
+ if (key === "type") result.type = child.text;
3770
+ if (child.kind === "string" && [
3771
+ "data",
3772
+ "url",
3773
+ "image_url",
3774
+ "file_id"
3775
+ ].includes(key)) result.strings.add(key);
3776
+ if (key === "source") source = child;
3777
+ if (key === "image_url") imageUrl = child;
3778
+ if (content && child.kind === "array") {
3779
+ result.image += child.image;
3780
+ result.replay += child.replay;
3781
+ }
3782
+ if (possibleOutput && child.kind === "array") output = child;
3783
+ if (child.kind === "string") {
3784
+ if (location === "conversation" && key === "encrypted_content") encrypted = bytes(child);
3785
+ if (location === "content" && key === "signature") signature = bytes(child);
3786
+ if (location === "content" && key === "data") redacted = bytes(child);
3787
+ }
3788
+ if (depth === 0) {
3789
+ if (key === conversationKey) {
3790
+ conversationArray = child.kind === "array";
3791
+ if (conversationArray) {
3792
+ conversationBytes = bytes(child);
3793
+ imageBlockBytes = child.image;
3794
+ opaqueReplayBytes = child.replay;
3795
+ }
3796
+ } else if (child.kind === "array" && (key === "tools" || protocol === "openai-completions" && key === "functions")) toolSchemaBytes += bytes(child);
3797
+ else if (key === systemKey && (child.kind === "string" || child.kind === "array")) systemBytes += bytes(child);
3798
+ }
3799
+ yield* whitespace();
3800
+ if (body[position] === "}") break;
3801
+ if (body[position++] !== ",") throw new ScanError("invalid-json");
3802
+ yield* whitespace();
3803
+ }
3804
+ position++;
3805
+ result.end = position;
3806
+ if (output && result.type === "function_call_output") {
3807
+ result.image += output.image;
3808
+ result.replay += output.replay;
3809
+ }
3810
+ if (location === "content" && (protocol === "openai-responses" ? result.type === "input_image" && (result.strings.has("image_url") || result.strings.has("file_id")) : protocol === "openai-completions" ? result.type === "image_url" && imageUrl?.strings?.has("url") : result.type === "image" && source?.kind === "object" && (source.type === "base64" && source.strings?.has("data") || source.type === "url" && source.strings?.has("url")))) {
3811
+ result.image = bytes(result);
3812
+ result.replay = 0;
3813
+ } else if (protocol === "openai-responses" && location === "conversation" && result.type === "reasoning") result.replay += encrypted;
3814
+ else if (protocol === "anthropic-messages" && location === "content") {
3815
+ if (result.type === "thinking") result.replay += signature;
3816
+ if (result.type === "redacted_thinking") result.replay += redacted;
3817
+ }
3818
+ return result;
3819
+ }
3820
+ const literal = [
3821
+ "true",
3822
+ "false",
3823
+ "null"
3824
+ ].find((value) => body.startsWith(value, position));
3825
+ if (literal) position += literal.length;
3826
+ else {
3827
+ const numberStart = position;
3828
+ while (position < body.length && /[0-9eE+.-]/.test(body[position])) if (++position - numberStart > 128) throw new ScanError("work-limit");
3829
+ if (!/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/.test(body.slice(numberStart, position))) throw new ScanError("invalid-json");
3830
+ }
3831
+ return {
3832
+ kind: "scalar",
3833
+ start,
3834
+ end: position,
3835
+ image: 0,
3836
+ replay: 0
3837
+ };
3838
+ }
3839
+ function* scan() {
3840
+ const root = yield* visit(0, "root");
3841
+ yield* whitespace();
3842
+ if (position !== body.length) throw new ScanError("invalid-json");
3843
+ if (root.kind !== "object" || !conversationArray) return {
3844
+ state: "unsupported-shape",
3845
+ totalBytes
3846
+ };
3847
+ const otherBytes = totalBytes - conversationBytes - toolSchemaBytes - systemBytes;
3848
+ const remainingConversationBytes = conversationBytes - imageBlockBytes - opaqueReplayBytes;
3849
+ if (otherBytes < 0 || remainingConversationBytes < 0) throw new ScanError("invalid-json");
3850
+ return {
3851
+ state: "complete",
3852
+ totalBytes,
3853
+ conversationBytes,
3854
+ toolSchemaBytes,
3855
+ systemBytes,
3856
+ otherBytes,
3857
+ imageBlockBytes,
3858
+ opaqueReplayBytes,
3859
+ remainingConversationBytes
3860
+ };
3861
+ }
3862
+ try {
3863
+ const scanner = scan();
3864
+ while (true) {
3865
+ const next = scanner.next();
3866
+ if (next.done) {
3867
+ check();
3868
+ return next.value;
3869
+ }
3870
+ await setImmediate();
3871
+ }
3872
+ } catch (error) {
3873
+ if (!(error instanceof ScanError)) throw error;
3874
+ return {
3875
+ state: error.state,
3876
+ totalBytes
3877
+ };
3878
+ } finally {
3879
+ activeScans--;
3880
+ }
3881
+ }
3882
+ //#endregion
3599
3883
  //#region lib/types/request-upload-evidence.js
3600
3884
  function object$6(value) {
3601
3885
  return typeof value === "object" && value !== null;
@@ -3710,7 +3994,9 @@ async function requestBodyTimeoutDiagnostic(response, body, signal, dispatch) {
3710
3994
  const compression = dispatch?.compression;
3711
3995
  const encoding = compression?.encoding === "gzip" ? ` Encoded body: ${compression.wireBytes} gzip bytes (prepared HTTP body, excluding transport framing; not confirmed delivered bytes). Lossless content encoding does not reduce context tokens or prove remote receipt.` : compression !== void 0 && compression.reason !== "disabled" ? ` Request compression not applied: ${compression.reason}; original request retained.` : "";
3712
3996
  const size = body === void 0 ? "Request body size unavailable." : `Request body${compression?.encoding === "gzip" ? " (original JSON)" : ""}: ${Buffer.byteLength(body, "utf8")} UTF-8 bytes (not context tokens).`;
3713
- const composition = formatRequestBodyEvidence(dispatch === void 0 ? { state: "unavailable" } : requestBodyEvidence(body, dispatch.protocol), dispatch?.responseHeadersMs, compression);
3997
+ const evidence = dispatch === void 0 ? { state: "unavailable" } : dispatch.composition !== void 0 ? await dispatch.composition : body !== void 0 && Buffer.byteLength(body, "utf8") > REQUEST_BODY_EVIDENCE_LIMITS.bytes ? await requestBodyComposition(body, dispatch.protocol, { signal }) : requestBodyEvidence(body, dispatch.protocol);
3998
+ if (signal?.aborted) return void 0;
3999
+ const composition = formatRequestBodyEvidence(evidence, dispatch?.responseHeadersMs, compression);
3714
4000
  const upload = formatRequestUploadEvidence(dispatch?.upload);
3715
4001
  return `${REQUEST_BODY_TIMEOUT_MARKER} ${size}${encoding} ${composition} ${upload} Native retry policy is unchanged. If retries exhaust, use these numbers to choose an explicit attachment/image-offload budget change or native compaction for compressible history; tool definitions and opaque replay may remain. Also check network/proxy health and GitHub service status. Composition alone does not establish a cause or supplier size limit. A larger client timeout does not change this server timeout. No history was trimmed or model switched.`;
3716
4002
  }
@@ -4234,10 +4520,25 @@ function createAccountProvider(descriptors, guard, baseURL) {
4234
4520
  });
4235
4521
  });
4236
4522
  let response;
4523
+ let composition;
4237
4524
  const upload = guard.onRequestBodyTimeout === void 0 && requestDiagnostic === void 0 ? void 0 : createRequestUploadObserver();
4238
4525
  const startedAt = performance.now();
4239
4526
  try {
4240
- response = await (upload === void 0 ? fetch(dispatchInput, dispatchInit) : upload.run(() => fetch(dispatchInput, dispatchInit)));
4527
+ const fetching = upload === void 0 ? fetch(dispatchInput, dispatchInit) : upload.run(() => fetch(dispatchInput, dispatchInit));
4528
+ const handle = requestDiagnostic;
4529
+ if (handle?.composition && originalBody !== void 0 && Buffer.byteLength(originalBody, "utf8") > REQUEST_BODY_EVIDENCE_LIMITS.bytes) {
4530
+ composition = requestBodyComposition(originalBody, entry.api, {
4531
+ signal: options.signal,
4532
+ isCurrent: handle.isCurrent
4533
+ }).catch(() => {
4534
+ observeDiagnostics(() => {
4535
+ throw new Error("COPILOT_REQUEST_COMPOSITION_FAILED");
4536
+ });
4537
+ return { state: "unavailable" };
4538
+ });
4539
+ composition.then((evidence) => observeDiagnostics(() => handle.composition?.(evidence)));
4540
+ }
4541
+ response = await fetching;
4241
4542
  } catch (error) {
4242
4543
  observeDiagnostics(() => requestDiagnostic?.headers(void 0, void 0, upload?.snapshot()));
4243
4544
  observeDiagnostics(() => requestDiagnostic?.finish(diagnosticAborted() ? "cancelled" : "transport-error", abortReason()));
@@ -4254,6 +4555,7 @@ function createAccountProvider(descriptors, guard, baseURL) {
4254
4555
  const diagnostic = await requestBodyTimeoutDiagnostic(response, originalBody, lease.signal, {
4255
4556
  protocol: entry.api,
4256
4557
  responseHeadersMs,
4558
+ ...composition === void 0 ? {} : { composition },
4257
4559
  ...upload === void 0 ? {} : { upload: upload.snapshot() },
4258
4560
  ...compression === void 0 ? {} : { compression }
4259
4561
  });
@@ -1,5 +1,5 @@
1
1
  import "./copilot-identity-DRZY_d2X.js";
2
- import { d as diagnosticsReason, u as diagnosticsOutcome } from "./diagnostics-types-CpyhNCSg.js";
2
+ import { d as diagnosticsReason, u as diagnosticsOutcome } from "./diagnostics-types-Cd4BmeOe.js";
3
3
  import { i as resolveRequestBudgetPolicy, r as calculateRequestBudget } from "./request-budget-DLY_aRq0.js";
4
4
  import z from "@deepseek-ai/schemastery";
5
5
  import { LlmError, createUserMessage } from "@deepseek-ai/dsh-llm";
package/lib/remote.js CHANGED
@@ -854,7 +854,9 @@ const composition = z.discriminatedUnion("state", [z.object({
854
854
  "size-limit",
855
855
  "work-limit",
856
856
  "invalid-json",
857
- "unsupported-shape"
857
+ "unsupported-shape",
858
+ "cancelled",
859
+ "time-limit"
858
860
  ]),
859
861
  totalBytes: integer$1.optional()
860
862
  }).strict()]);
@@ -19,6 +19,7 @@ export declare class DiagnosticsCollector {
19
19
  private autoAllocationEnabled;
20
20
  private requestEnabled;
21
21
  private readonly requestHandles;
22
+ private requestGeneration;
22
23
  private lastWall;
23
24
  private readonly autoAllocation;
24
25
  constructor(version: string, layer: 'client' | 'host', changed?: () => void, wall?: () => number, mono?: () => number);
@@ -97,11 +97,11 @@ export declare const diagnosticsDomain: {
97
97
  opaqueReplayBytes: number;
98
98
  remainingConversationBytes: number;
99
99
  } | {
100
- state: "unavailable" | "work-limit" | "size-limit" | "invalid-json" | "unsupported-shape";
100
+ state: "unavailable" | "work-limit" | "size-limit" | "invalid-json" | "unsupported-shape" | "cancelled" | "time-limit";
101
101
  totalBytes?: number | undefined;
102
102
  };
103
103
  encoding: "unknown" | "identity" | "gzip";
104
- outcome: "http-error" | "transport-error" | "stream-done" | "stream-error" | "cancelled" | "interrupted";
104
+ outcome: "cancelled" | "http-error" | "transport-error" | "stream-done" | "stream-error" | "interrupted";
105
105
  reason: "none" | "unknown" | "request-body-timeout" | "caller-abort" | "credential-changed" | "disposed" | "byte-idle-timeout" | "signal-abort";
106
106
  wireBytes?: number | undefined;
107
107
  upload?: {
@@ -329,6 +329,8 @@ export declare const DiagnosticsSnapshotSchema: z.ZodObject<{
329
329
  "size-limit": "size-limit";
330
330
  "invalid-json": "invalid-json";
331
331
  "unsupported-shape": "unsupported-shape";
332
+ cancelled: "cancelled";
333
+ "time-limit": "time-limit";
332
334
  }>;
333
335
  totalBytes: z.ZodOptional<z.ZodNumber>;
334
336
  }, z.core.$strict>], "state">;
@@ -364,11 +366,11 @@ export declare const DiagnosticsSnapshotSchema: z.ZodObject<{
364
366
  responseHeadersMs: z.ZodOptional<z.ZodNumber>;
365
367
  httpStatus: z.ZodOptional<z.ZodNumber>;
366
368
  outcome: z.ZodEnum<{
369
+ cancelled: "cancelled";
367
370
  "http-error": "http-error";
368
371
  "transport-error": "transport-error";
369
372
  "stream-done": "stream-done";
370
373
  "stream-error": "stream-error";
371
- cancelled: "cancelled";
372
374
  interrupted: "interrupted";
373
375
  }>;
374
376
  reason: z.ZodEnum<{
@@ -653,6 +655,8 @@ export declare const DiagnosticsViewSchema: z.ZodObject<{
653
655
  "size-limit": "size-limit";
654
656
  "invalid-json": "invalid-json";
655
657
  "unsupported-shape": "unsupported-shape";
658
+ cancelled: "cancelled";
659
+ "time-limit": "time-limit";
656
660
  }>;
657
661
  totalBytes: z.ZodOptional<z.ZodNumber>;
658
662
  }, z.core.$strict>], "state">;
@@ -688,11 +692,11 @@ export declare const DiagnosticsViewSchema: z.ZodObject<{
688
692
  responseHeadersMs: z.ZodOptional<z.ZodNumber>;
689
693
  httpStatus: z.ZodOptional<z.ZodNumber>;
690
694
  outcome: z.ZodEnum<{
695
+ cancelled: "cancelled";
691
696
  "http-error": "http-error";
692
697
  "transport-error": "transport-error";
693
698
  "stream-done": "stream-done";
694
699
  "stream-error": "stream-error";
695
- cancelled: "cancelled";
696
700
  interrupted: "interrupted";
697
701
  }>;
698
702
  reason: z.ZodEnum<{
@@ -0,0 +1,17 @@
1
+ import type { RequestBodyEvidence, RequestBodyProtocol } from './request-body-evidence.ts';
2
+ export declare const REQUEST_BODY_COMPOSITION_LIMITS: Readonly<{
3
+ bytes: number;
4
+ sliceCharacters: 65536;
5
+ elapsedMs: 2000;
6
+ concurrent: 4;
7
+ values: 65536;
8
+ tokens: 131072;
9
+ depth: 64;
10
+ keyCharacters: 128;
11
+ }>;
12
+ /** Only bounded keys/discriminators are decoded; payload values never form an object graph. */
13
+ export declare function requestBodyComposition(payload: string | undefined, protocol: RequestBodyProtocol, options?: {
14
+ signal?: AbortSignal;
15
+ isCurrent?: () => boolean;
16
+ }): Promise<RequestBodyEvidence>;
17
+ //# sourceMappingURL=request-body-composition.d.ts.map
@@ -20,11 +20,12 @@ export type RequestBodyEvidence = {
20
20
  readonly opaqueReplayBytes: number;
21
21
  readonly remainingConversationBytes: number;
22
22
  } | {
23
- readonly state: 'unavailable' | 'size-limit' | 'work-limit' | 'invalid-json' | 'unsupported-shape';
23
+ readonly state: 'unavailable' | 'size-limit' | 'work-limit' | 'invalid-json' | 'unsupported-shape' | 'cancelled' | 'time-limit';
24
24
  readonly totalBytes?: number;
25
25
  };
26
26
  export interface RequestBodyDispatchEvidence {
27
27
  readonly protocol: RequestBodyProtocol;
28
+ readonly composition?: Promise<RequestBodyEvidence>;
28
29
  /** Fetch invocation to response headers, not upload duration or clone-observation time. */
29
30
  readonly responseHeadersMs: number;
30
31
  readonly upload?: RequestUploadEvidence;
@@ -32,6 +32,8 @@ export declare const RequestDiagnosticSchema: z.ZodObject<{
32
32
  "size-limit": "size-limit";
33
33
  "invalid-json": "invalid-json";
34
34
  "unsupported-shape": "unsupported-shape";
35
+ cancelled: "cancelled";
36
+ "time-limit": "time-limit";
35
37
  }>;
36
38
  totalBytes: z.ZodOptional<z.ZodNumber>;
37
39
  }, z.core.$strict>], "state">;
@@ -67,11 +69,11 @@ export declare const RequestDiagnosticSchema: z.ZodObject<{
67
69
  responseHeadersMs: z.ZodOptional<z.ZodNumber>;
68
70
  httpStatus: z.ZodOptional<z.ZodNumber>;
69
71
  outcome: z.ZodEnum<{
72
+ cancelled: "cancelled";
70
73
  "http-error": "http-error";
71
74
  "transport-error": "transport-error";
72
75
  "stream-done": "stream-done";
73
76
  "stream-error": "stream-error";
74
- cancelled: "cancelled";
75
77
  interrupted: "interrupted";
76
78
  }>;
77
79
  reason: z.ZodEnum<{
@@ -115,6 +117,8 @@ export declare const RequestDiagnosticsSchema: z.ZodObject<{
115
117
  "size-limit": "size-limit";
116
118
  "invalid-json": "invalid-json";
117
119
  "unsupported-shape": "unsupported-shape";
120
+ cancelled: "cancelled";
121
+ "time-limit": "time-limit";
118
122
  }>;
119
123
  totalBytes: z.ZodOptional<z.ZodNumber>;
120
124
  }, z.core.$strict>], "state">;
@@ -150,11 +154,11 @@ export declare const RequestDiagnosticsSchema: z.ZodObject<{
150
154
  responseHeadersMs: z.ZodOptional<z.ZodNumber>;
151
155
  httpStatus: z.ZodOptional<z.ZodNumber>;
152
156
  outcome: z.ZodEnum<{
157
+ cancelled: "cancelled";
153
158
  "http-error": "http-error";
154
159
  "transport-error": "transport-error";
155
160
  "stream-done": "stream-done";
156
161
  "stream-error": "stream-error";
157
- cancelled: "cancelled";
158
162
  interrupted: "interrupted";
159
163
  }>;
160
164
  reason: z.ZodEnum<{
@@ -175,6 +179,8 @@ export declare const RequestDiagnosticsSchema: z.ZodObject<{
175
179
  }, z.core.$strict>;
176
180
  export type RequestDiagnostic = z.infer<typeof RequestDiagnosticSchema>;
177
181
  export interface RequestDiagnosticHandle {
182
+ composition?(evidence: RequestBodyEvidence): void;
183
+ isCurrent?(): boolean;
178
184
  headers(status: number | undefined, ms: number | undefined, upload?: RequestUploadEvidence): void;
179
185
  finish(outcome: RequestDiagnostic['outcome'], reason?: RequestDiagnostic['reason']): void;
180
186
  }
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.2-alpha.4",
4
+ "version": "0.4.2-alpha.5",
5
5
  "releaseNotes": "CHANGELOG.md",
6
6
  "publishConfig": {
7
7
  "access": "public",