dsh-github-copilot 0.4.2-alpha.17 → 0.4.2-alpha.19.dsh.0.2.0.rc.2

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
@@ -582,7 +582,7 @@ const result$1 = strictRemoteCodec("dsh-github-copilot#DiagnosticsView", Diagnos
582
582
  var package_default = {
583
583
  name: "dsh-github-copilot",
584
584
  description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
585
- version: "0.4.2-alpha.17",
585
+ version: "0.4.2-alpha.19.dsh.0.2.0.rc.2",
586
586
  releaseNotes: "CHANGELOG.md",
587
587
  publishConfig: {
588
588
  "access": "public",
@@ -2646,7 +2646,7 @@ var Budget = class {
2646
2646
  if (this.consumed > ACCOUNT_MODEL_CATALOG_LIMITS.maxBytes) fail$1("CATALOG_TOO_LARGE", true);
2647
2647
  }
2648
2648
  };
2649
- function record$15(value, code) {
2649
+ function record$16(value, code) {
2650
2650
  if (typeof value !== "object" || value === null || Array.isArray(value)) fail$1(code);
2651
2651
  return value;
2652
2652
  }
@@ -2699,11 +2699,11 @@ function normalizeModel(raw, id, options, budget) {
2699
2699
  if (options.availableModelIds?.has(id) !== true) fail$1("MISSING_POLICY");
2700
2700
  policySource = "account-available-id";
2701
2701
  } else {
2702
- if (text$2(field(record$15(rawPolicy, "INVALID_POLICY"), "state", budget), 64, "INVALID_POLICY", budget) !== "enabled") fail$1("POLICY_NOT_ENABLED");
2702
+ if (text$2(field(record$16(rawPolicy, "INVALID_POLICY"), "state", budget), 64, "INVALID_POLICY", budget) !== "enabled") fail$1("POLICY_NOT_ENABLED");
2703
2703
  policySource = "server-enabled";
2704
2704
  }
2705
- const capabilities = record$15(field(raw, "capabilities", budget), "INVALID_CAPABILITIES");
2706
- const supports = record$15(field(capabilities, "supports", budget), "INVALID_SUPPORTS");
2705
+ const capabilities = record$16(field(raw, "capabilities", budget), "INVALID_CAPABILITIES");
2706
+ const supports = record$16(field(capabilities, "supports", budget), "INVALID_SUPPORTS");
2707
2707
  const streaming = field(supports, "streaming", budget);
2708
2708
  if (streaming === false) fail$1("STREAMING_UNSUPPORTED");
2709
2709
  if (streaming !== true) fail$1("INVALID_SUPPORTS");
@@ -2724,7 +2724,7 @@ function normalizeModel(raw, id, options, budget) {
2724
2724
  if (selected === void 0) fail$1(unsupportedEndpointCount === 0 && endpoints.includes("ws:/responses") ? "WEBSOCKET_ONLY" : "UNSUPPORTED_ENDPOINTS");
2725
2725
  const rawLimits = field(capabilities, "limits", budget);
2726
2726
  if (rawLimits === void 0) fail$1("MISSING_LIMITS");
2727
- const limits = record$15(rawLimits, "INVALID_LIMITS");
2727
+ const limits = record$16(rawLimits, "INVALID_LIMITS");
2728
2728
  const maxContext = optionalPositive(limits, "max_context_window_tokens", "INVALID_LIMITS", budget);
2729
2729
  const maxInputTokens = optionalPositive(limits, "max_prompt_tokens", "INVALID_LIMITS", budget);
2730
2730
  if (maxContext === void 0 && maxInputTokens === void 0) fail$1("MISSING_CONTEXT_LIMIT");
@@ -2742,7 +2742,7 @@ function normalizeModel(raw, id, options, budget) {
2742
2742
  if (vision === true) {
2743
2743
  const rawVisionLimits = field(limits, "vision", budget);
2744
2744
  if (rawVisionLimits !== void 0) {
2745
- const rawMediaTypes = field(record$15(rawVisionLimits, "INVALID_VISION_LIMITS"), "supported_media_types", budget);
2745
+ const rawMediaTypes = field(record$16(rawVisionLimits, "INVALID_VISION_LIMITS"), "supported_media_types", budget);
2746
2746
  if (rawMediaTypes !== void 0) {
2747
2747
  const mediaTypes = stringList(rawMediaTypes, ACCOUNT_MODEL_CATALOG_LIMITS.maxMediaTypes, 128, "INVALID_VISION_LIMITS", budget);
2748
2748
  const mime = /^[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*\/[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*$/iu;
@@ -2804,7 +2804,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
2804
2804
  fail$1("INVALID_JSON", true);
2805
2805
  }
2806
2806
  }
2807
- const data = field(record$15(raw, "INVALID_CATALOG"), "data", budget);
2807
+ const data = field(record$16(raw, "INVALID_CATALOG"), "data", budget);
2808
2808
  if (!Array.isArray(data)) fail$1("INVALID_CATALOG");
2809
2809
  const count = field(data, "length", budget);
2810
2810
  if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0) fail$1("INVALID_CATALOG");
@@ -2827,7 +2827,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
2827
2827
  for (let index = 0; index < count; index++) {
2828
2828
  let id;
2829
2829
  try {
2830
- const candidate = record$15(field(data, String(index), budget), "INVALID_MODEL");
2830
+ const candidate = record$16(field(data, String(index), budget), "INVALID_MODEL");
2831
2831
  const candidateId = text$2(field(candidate, "id", budget), ACCOUNT_MODEL_CATALOG_LIMITS.maxIdLength, "INVALID_ID", budget);
2832
2832
  if (!identifier.test(candidateId)) fail$1("INVALID_ID");
2833
2833
  id = candidateId;
@@ -3413,17 +3413,17 @@ const TaskAssessmentSchema = z.object({
3413
3413
  "insufficient-evidence"
3414
3414
  ])).max(7)
3415
3415
  }).strict();
3416
- function record$14(value) {
3416
+ function record$15(value) {
3417
3417
  return typeof value === "object" && value !== null && !Array.isArray(value);
3418
3418
  }
3419
3419
  function text$1(message) {
3420
- if (!record$14(message) || !Array.isArray(message.content)) return "";
3421
- return message.content.flatMap((block) => record$14(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
3420
+ if (!record$15(message) || !Array.isArray(message.content)) return "";
3421
+ return message.content.flatMap((block) => record$15(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
3422
3422
  }
3423
3423
  function user(message) {
3424
- if (!record$14(message)) return false;
3425
- if (record$14(message.source) && message.source.kind === "model-selection") return false;
3426
- return message.role === "user" || record$14(message.source) && message.source.kind === "user";
3424
+ if (!record$15(message)) return false;
3425
+ if (record$15(message.source) && message.source.kind === "model-selection") return false;
3426
+ return message.role === "user" || record$15(message.source) && message.source.kind === "user";
3427
3427
  }
3428
3428
  function difficult(current) {
3429
3429
  return /\b(prove|proof|theorem|debug|investigate|diagnose)\b|证明|定理|调试|排查|根因|调查/iu.test(current);
@@ -3440,8 +3440,8 @@ function assessTaskLocally(messages) {
3440
3440
  const last = messages.findLast(user);
3441
3441
  const current = text$1(last).trim();
3442
3442
  const history = messages.slice(0, last === void 0 ? 0 : messages.lastIndexOf(last));
3443
- const hasWork = history.some((message) => record$14(message) && (message.role === "assistant" || message.role === "tool" || user(message) || record$14(message.source) && message.source.kind === "model"));
3444
- const nonText = record$14(last) && Array.isArray(last.content) && last.content.some((block) => !record$14(block) || block.type !== "text");
3443
+ const hasWork = history.some((message) => record$15(message) && (message.role === "assistant" || message.role === "tool" || user(message) || record$15(message.source) && message.source.kind === "model"));
3444
+ const nonText = record$15(last) && Array.isArray(last.content) && last.content.some((block) => !record$15(block) || block.type !== "text");
3445
3445
  if (!hasWork && !nonText && /^(hello|hi|hey|你好|您好|嗨)[!!。.\s]*$/iu.test(current)) return {
3446
3446
  demand: "simple",
3447
3447
  source: "local",
@@ -3483,7 +3483,7 @@ function assessTaskLocally(messages) {
3483
3483
  /** Separate text-only projection for assessment; never mutates the chat request. */
3484
3484
  function assessmentInput(messages) {
3485
3485
  let omitted = false;
3486
- const context = messages.filter((message) => !record$14(message) || message.role !== "system" && message.role !== "developer" && !(record$14(message.source) && message.source.kind === "model-selection"));
3486
+ const context = messages.filter((message) => !record$15(message) || message.role !== "system" && message.role !== "developer" && !(record$15(message.source) && message.source.kind === "model-selection"));
3487
3487
  const lastUser = context.findLastIndex(user);
3488
3488
  const priorUser = context.slice(0, lastUser < 0 ? 0 : lastUser).findLastIndex(user);
3489
3489
  const continuing = lastUser >= 0 && continuation(text$1(context[lastUser]).trim());
@@ -3507,13 +3507,13 @@ function assessmentInput(messages) {
3507
3507
  let length = 0;
3508
3508
  for (const index of priority) {
3509
3509
  const message = context[index];
3510
- if (!record$14(message)) {
3510
+ if (!record$15(message)) {
3511
3511
  omitted = true;
3512
3512
  continue;
3513
3513
  }
3514
3514
  let limited = !Array.isArray(message.content);
3515
3515
  const content = text$1(message);
3516
- if (Array.isArray(message.content) && message.content.some((block) => !record$14(block) || block.type !== "text")) limited = true;
3516
+ if (Array.isArray(message.content) && message.content.some((block) => !record$15(block) || block.type !== "text")) limited = true;
3517
3517
  if (content.length > 1600) limited = true;
3518
3518
  if (taskIndices.has(index) && content.trim() === "") limited = true;
3519
3519
  if (limited) {
@@ -4518,7 +4518,7 @@ async function requestBodyComposition(payload, protocol, options = {}) {
4518
4518
  function object$6(value) {
4519
4519
  return typeof value === "object" && value !== null;
4520
4520
  }
4521
- function count$3(value) {
4521
+ function count$4(value) {
4522
4522
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
4523
4523
  }
4524
4524
  /** Observe public native events only; never read request fields, mutate transport or imply remote receipt. */
@@ -4530,7 +4530,7 @@ function createRequestUploadObserver() {
4530
4530
  let socket;
4531
4531
  let connectionAmbiguous = false, socketBoundToRequest = false;
4532
4532
  let alpn = "unavailable", nodeWritableBufferBytes;
4533
- const elapsed = () => startedAt === void 0 ? void 0 : count$3(Math.round(performance.now() - startedAt));
4533
+ const elapsed = () => startedAt === void 0 ? void 0 : count$4(Math.round(performance.now() - startedAt));
4534
4534
  const request = (data) => !closed && object$6(data) && object$6(data.request) ? requests.get(data.request) : void 0;
4535
4535
  const connected = (data, boundToRequest = false) => {
4536
4536
  if (closed || !object$6(data) || !object$6(data.socket)) return;
@@ -4565,7 +4565,7 @@ function createRequestUploadObserver() {
4565
4565
  if (request(data) !== 1 || bodyWrite) return;
4566
4566
  bodyWrite = true;
4567
4567
  bodyWriteCompleteMs = elapsed();
4568
- nodeWritableBufferBytes = count$3(socket?.writableLength);
4568
+ nodeWritableBufferBytes = count$4(socket?.writableLength);
4569
4569
  },
4570
4570
  "undici:request:headers": (data) => {
4571
4571
  if (request(data) === 1 && nativeResponseHeadersMs === void 0) nativeResponseHeadersMs = elapsed();
@@ -4615,16 +4615,16 @@ function formatRequestUploadEvidence(evidence) {
4615
4615
  //#endregion
4616
4616
  //#region lib/types/request-body-timeout.js
4617
4617
  const observedMessage = "Timed out reading request body. Try again, or use a smaller request size.";
4618
- function record$13(value) {
4618
+ function record$14(value) {
4619
4619
  return typeof value === "object" && value !== null && !Array.isArray(value);
4620
4620
  }
4621
4621
  /** Verified provider evidence, not guessed capabilities, token limits or network cause. */
4622
4622
  async function requestBodyTimeoutDiagnostic(response, body, signal, dispatch) {
4623
4623
  if (response.status !== 408 || signal?.aborted) return void 0;
4624
4624
  const value = await readResponseErrorJson(response, signal);
4625
- if (signal?.aborted || !record$13(value)) return void 0;
4625
+ if (signal?.aborted || !record$14(value)) return void 0;
4626
4626
  const error = Object.hasOwn(value, "error") ? value.error : value;
4627
- if (!record$13(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;
4627
+ if (!record$14(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;
4628
4628
  const compression = dispatch?.compression;
4629
4629
  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.` : "";
4630
4630
  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).`;
@@ -7415,28 +7415,28 @@ function isZeroContextUsage(usage) {
7415
7415
  //#endregion
7416
7416
  //#region lib/types/context-evidence.js
7417
7417
  const COPILOT_CONTEXT_EVIDENCE = "githubCopilotContextEvidence";
7418
- const count$2 = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
7418
+ const count$3 = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
7419
7419
  const routeSchema = z.object({
7420
7420
  provider: z.string().min(1),
7421
7421
  model: z.string().min(1)
7422
7422
  }).strict();
7423
7423
  const sampleSchema = z.object({
7424
- tokens: count$2,
7425
- seq: count$2,
7424
+ tokens: count$3,
7425
+ seq: count$3,
7426
7426
  route: routeSchema
7427
7427
  }).strict();
7428
7428
  const incidentSchema = z.object({
7429
7429
  kind: z.enum(["failed-zero", "invalid-sample"]),
7430
- seq: count$2
7430
+ seq: count$3
7431
7431
  }).strict();
7432
7432
  const stepSchema = z.object({
7433
- turn: count$2,
7434
- step: count$2
7433
+ turn: count$3,
7434
+ step: count$3
7435
7435
  }).strict();
7436
7436
  const compactionSchema = z.object({
7437
7437
  id: z.string().min(1).max(256),
7438
- startSeq: count$2,
7439
- endSeq: count$2.nullable(),
7438
+ startSeq: count$3,
7439
+ endSeq: count$3.nullable(),
7440
7440
  state: z.enum([
7441
7441
  "running",
7442
7442
  "completed",
@@ -7444,7 +7444,7 @@ const compactionSchema = z.object({
7444
7444
  "unknown"
7445
7445
  ]),
7446
7446
  checkpoint: z.boolean(),
7447
- headerSeq: count$2.nullable(),
7447
+ headerSeq: count$3.nullable(),
7448
7448
  requestRoute: routeSchema.nullable(),
7449
7449
  step: stepSchema.nullable(),
7450
7450
  request: z.enum([
@@ -7473,14 +7473,14 @@ const ContextEvidenceSchema = z.object({
7473
7473
  activeStep: stepSchema.nullable().optional()
7474
7474
  }).strict();
7475
7475
  const usageSchema = z.object({
7476
- inputTokens: count$2,
7477
- outputTokens: count$2,
7478
- cacheReadTokens: count$2.optional(),
7479
- cacheWriteTokens: count$2.optional(),
7480
- totalTokens: count$2.optional(),
7481
- reasoningTokens: count$2.optional()
7476
+ inputTokens: count$3,
7477
+ outputTokens: count$3,
7478
+ cacheReadTokens: count$3.optional(),
7479
+ cacheWriteTokens: count$3.optional(),
7480
+ totalTokens: count$3.optional(),
7481
+ reasoningTokens: count$3.optional()
7482
7482
  });
7483
- function record$12(value) {
7483
+ function record$13(value) {
7484
7484
  return typeof value === "object" && value !== null && !Array.isArray(value);
7485
7485
  }
7486
7486
  function sameRoute$1(left, right) {
@@ -7502,7 +7502,7 @@ function initialContextEvidence() {
7502
7502
  }
7503
7503
  /** Read only counts and routing leaves; never message content or opaque replay. */
7504
7504
  function foldContextEvidence(state, event) {
7505
- if (!record$12(event) || typeof event.type !== "string" || !record$12(event.data)) return state;
7505
+ if (!record$13(event) || typeof event.type !== "string" || !record$13(event.data)) return state;
7506
7506
  if (event.type === "step/start") {
7507
7507
  const step = stepSchema.safeParse({
7508
7508
  turn: event.data.turn,
@@ -7515,7 +7515,7 @@ function foldContextEvidence(state, event) {
7515
7515
  }
7516
7516
  if (event.type === "compaction/start") {
7517
7517
  const id = compactionSchema.shape.id.safeParse(event.data.compactionId);
7518
- const seq = count$2.safeParse(event.seq);
7518
+ const seq = count$3.safeParse(event.seq);
7519
7519
  return {
7520
7520
  ...state,
7521
7521
  sample: null,
@@ -7535,7 +7535,7 @@ function foldContextEvidence(state, event) {
7535
7535
  } : null
7536
7536
  };
7537
7537
  }
7538
- if (event.type === "step/start" && state.compaction?.state === "completed" && state.compaction.endSeq !== null && count$2.safeParse(event.seq).success && Number(event.seq) > state.compaction.endSeq) {
7538
+ if (event.type === "step/start" && state.compaction?.state === "completed" && state.compaction.endSeq !== null && count$3.safeParse(event.seq).success && Number(event.seq) > state.compaction.endSeq) {
7539
7539
  const step = compactionSchema.shape.step.safeParse({
7540
7540
  turn: event.data.turn,
7541
7541
  step: event.data.step
@@ -7545,7 +7545,7 @@ function foldContextEvidence(state, event) {
7545
7545
  compaction: {
7546
7546
  ...state.compaction,
7547
7547
  step: step.success ? step.data : null,
7548
- headerSeq: step.success ? count$2.parse(event.seq) : null,
7548
+ headerSeq: step.success ? count$3.parse(event.seq) : null,
7549
7549
  requestRoute: state.route,
7550
7550
  request: step.success && copilot(state.route) ? "pending" : "unknown"
7551
7551
  }
@@ -7563,8 +7563,8 @@ function foldContextEvidence(state, event) {
7563
7563
  activeStep: null
7564
7564
  };
7565
7565
  const operation = state.compaction;
7566
- if (operation?.state === "running" && count$2.safeParse(event.seq).success && Number(event.seq) > operation.startSeq) {
7567
- if (event.type === "user/message" && record$12(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === operation.id) state = {
7566
+ if (operation?.state === "running" && count$3.safeParse(event.seq).success && Number(event.seq) > operation.startSeq) {
7567
+ if (event.type === "user/message" && record$13(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === operation.id) state = {
7568
7568
  ...state,
7569
7569
  compaction: {
7570
7570
  ...operation,
@@ -7575,13 +7575,13 @@ function foldContextEvidence(state, event) {
7575
7575
  ...state,
7576
7576
  compaction: {
7577
7577
  ...operation,
7578
- endSeq: count$2.parse(event.seq),
7578
+ endSeq: count$3.parse(event.seq),
7579
7579
  state: event.data.error !== void 0 ? "failed" : operation.checkpoint ? "completed" : "unknown"
7580
7580
  }
7581
7581
  };
7582
7582
  }
7583
7583
  if (event.type === "request/header" || event.type === "model/selection") {
7584
- const raw = event.type === "request/header" ? record$12(event.data.header) ? event.data.header.config : void 0 : event.data;
7584
+ const raw = event.type === "request/header" ? record$13(event.data.header) ? event.data.header.config : void 0 : event.data;
7585
7585
  const revoke = () => state.compaction ? {
7586
7586
  ...state.compaction,
7587
7587
  headerSeq: null,
@@ -7589,7 +7589,7 @@ function foldContextEvidence(state, event) {
7589
7589
  step: null,
7590
7590
  request: "unknown"
7591
7591
  } : state.compaction;
7592
- if (!record$12(raw)) return {
7592
+ if (!record$13(raw)) return {
7593
7593
  ...state,
7594
7594
  route: null,
7595
7595
  sample: null,
@@ -7614,11 +7614,11 @@ function foldContextEvidence(state, event) {
7614
7614
  const route = parsed.data;
7615
7615
  const compact = state.compaction;
7616
7616
  if (compact?.state === "completed") {
7617
- if (event.type === "request/header" && compact.endSeq !== null && count$2.safeParse(event.seq).success && Number(event.seq) > compact.endSeq && copilot(route)) state = {
7617
+ if (event.type === "request/header" && compact.endSeq !== null && count$3.safeParse(event.seq).success && Number(event.seq) > compact.endSeq && copilot(route)) state = {
7618
7618
  ...state,
7619
7619
  compaction: {
7620
7620
  ...compact,
7621
- headerSeq: count$2.parse(event.seq),
7621
+ headerSeq: count$3.parse(event.seq),
7622
7622
  requestRoute: route,
7623
7623
  step: state.activeStep ?? null,
7624
7624
  request: "pending"
@@ -7640,7 +7640,7 @@ function foldContextEvidence(state, event) {
7640
7640
  };
7641
7641
  }
7642
7642
  if (event.type.startsWith("compaction/") || event.surfaceOp !== void 0 && event.surfaceOp !== "append") {
7643
- const checkpoint = event.type === "user/message" && record$12(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === state.compaction?.id;
7643
+ const checkpoint = event.type === "user/message" && record$13(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === state.compaction?.id;
7644
7644
  return {
7645
7645
  ...state,
7646
7646
  sample: null,
@@ -7658,14 +7658,14 @@ function foldContextEvidence(state, event) {
7658
7658
  }
7659
7659
  if (event.type !== "assistant/message" && event.type !== "assistant/attempt") return state;
7660
7660
  if (!copilot(state.route)) return state;
7661
- const source = record$12(event.data.message) ? event.data.message.source : event.data.source;
7661
+ const source = record$13(event.data.message) ? event.data.message.source : event.data.source;
7662
7662
  if (event.type === "assistant/message" && source !== void 0) {
7663
- const parsed = routeSchema.safeParse(record$12(source) ? {
7663
+ const parsed = routeSchema.safeParse(record$13(source) ? {
7664
7664
  provider: source.provider,
7665
7665
  model: source.model
7666
7666
  } : source);
7667
7667
  if (!parsed.success || !sameRoute$1(state.route, parsed.data)) {
7668
- const seq = count$2.safeParse(event.seq);
7668
+ const seq = count$3.safeParse(event.seq);
7669
7669
  return {
7670
7670
  ...state,
7671
7671
  sample: null,
@@ -7690,14 +7690,14 @@ function foldContextEvidence(state, event) {
7690
7690
  const settledUsage = usage !== void 0;
7691
7691
  let terminal;
7692
7692
  for (const entry of stream) {
7693
- if (!record$12(entry) || entry.type !== "chunk" || !record$12(entry.chunk)) continue;
7693
+ if (!record$13(entry) || entry.type !== "chunk" || !record$13(entry.chunk)) continue;
7694
7694
  if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
7695
7695
  if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
7696
7696
  }
7697
- const successful = event.data.interrupted !== true && record$12(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
7697
+ const successful = event.data.interrupted !== true && record$13(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
7698
7698
  const compact = state.compaction;
7699
7699
  if (compact?.state === "completed") {
7700
- if (compact.headerSeq === null || !count$2.safeParse(event.seq).success || Number(event.seq) <= compact.headerSeq) return state;
7700
+ if (compact.headerSeq === null || !count$3.safeParse(event.seq).success || Number(event.seq) <= compact.headerSeq) return state;
7701
7701
  if (!sameRoute$1(compact.requestRoute, state.route)) return state;
7702
7702
  if (compact.step === null) return {
7703
7703
  ...state,
@@ -7711,14 +7711,14 @@ function foldContextEvidence(state, event) {
7711
7711
  ...state,
7712
7712
  compaction: {
7713
7713
  ...compact,
7714
- request: event.type === "assistant/message" && successful && source !== void 0 ? "succeeded" : record$12(terminal) && terminal.kind === "aborted" ? "cancelled" : record$12(terminal) && terminal.kind === "error" ? "failed" : "unknown"
7714
+ request: event.type === "assistant/message" && successful && source !== void 0 ? "succeeded" : record$13(terminal) && terminal.kind === "aborted" ? "cancelled" : record$13(terminal) && terminal.kind === "error" ? "failed" : "unknown"
7715
7715
  }
7716
7716
  };
7717
7717
  } else if (compact?.state === "running") return state;
7718
7718
  if (usage === void 0) return state;
7719
7719
  const parsed = usageSchema.safeParse(usage);
7720
- if (!parsed.success || !count$2.safeParse(event.seq).success) {
7721
- const seq = count$2.safeParse(event.seq);
7720
+ if (!parsed.success || !count$3.safeParse(event.seq).success) {
7721
+ const seq = count$3.safeParse(event.seq);
7722
7722
  return {
7723
7723
  ...state,
7724
7724
  sample: null,
@@ -7737,7 +7737,7 @@ function foldContextEvidence(state, event) {
7737
7737
  reason: "failed-zero",
7738
7738
  incident: {
7739
7739
  kind: "failed-zero",
7740
- seq: count$2.parse(event.seq)
7740
+ seq: count$3.parse(event.seq)
7741
7741
  }
7742
7742
  };
7743
7743
  const tokens = value.inputTokens + (value.cacheReadTokens ?? 0) + (value.cacheWriteTokens ?? 0);
@@ -7748,14 +7748,14 @@ function foldContextEvidence(state, event) {
7748
7748
  reason: "invalid-sample",
7749
7749
  incident: {
7750
7750
  kind: "invalid-sample",
7751
- seq: count$2.parse(event.seq)
7751
+ seq: count$3.parse(event.seq)
7752
7752
  }
7753
7753
  };
7754
7754
  return {
7755
7755
  ...state,
7756
7756
  sample: {
7757
7757
  tokens,
7758
- seq: count$2.parse(event.seq),
7758
+ seq: count$3.parse(event.seq),
7759
7759
  route: state.route
7760
7760
  },
7761
7761
  invalid: false,
@@ -7778,7 +7778,7 @@ const contextEvidenceDefinition = {
7778
7778
  function installContextEvidence(ctx) {
7779
7779
  ctx.inject(["sessionProjections"], (scope) => {
7780
7780
  const registry = scope.get("sessionProjections");
7781
- if (!record$12(registry) || typeof registry.register !== "function") {
7781
+ if (!record$13(registry) || typeof registry.register !== "function") {
7782
7782
  scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
7783
7783
  return;
7784
7784
  }
@@ -8849,7 +8849,7 @@ function buildAnthropicWireBody(request, cfg, model) {
8849
8849
  }
8850
8850
  //#endregion
8851
8851
  //#region lib/types/responses-reasoning-text.js
8852
- function record$11(value) {
8852
+ function record$12(value) {
8853
8853
  return typeof value === "object" && value !== null;
8854
8854
  }
8855
8855
  function responseIndex(value) {
@@ -8907,13 +8907,13 @@ var ResponsesReasoningText = class {
8907
8907
  }
8908
8908
  /** Only recognized public text fields are examined; no copying of the item. */
8909
8909
  snapshot(item) {
8910
- if (!record$11(item) || item.type !== "reasoning") return "";
8910
+ if (!record$12(item) || item.type !== "reasoning") return "";
8911
8911
  let delta = "";
8912
8912
  for (const family of ["summary", "raw"]) {
8913
8913
  const value = family === "summary" ? item.summary : item.content;
8914
8914
  if (!Array.isArray(value)) continue;
8915
8915
  for (const [index, part] of value.entries()) {
8916
- if (!record$11(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
8916
+ if (!record$12(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
8917
8917
  delta += this.update(family, index, part.text, true);
8918
8918
  }
8919
8919
  }
@@ -11146,13 +11146,13 @@ function resolveCopilotResponsesReasoning(ctx, request, candidate) {
11146
11146
  }
11147
11147
  //#endregion
11148
11148
  //#region lib/types/replay-recovery.js
11149
- function record$10(value) {
11149
+ function record$11(value) {
11150
11150
  return value !== null && typeof value === "object" && !Array.isArray(value);
11151
11151
  }
11152
11152
  function parsed(body) {
11153
11153
  if (requestBodyEvidence(body, "openai-responses").state !== "complete" || body === void 0) throw new Error("COPILOT_REPLAY_RECOVERY_EVIDENCE_UNAVAILABLE");
11154
11154
  const payload = JSON.parse(body);
11155
- if (!record$10(payload) || !Array.isArray(payload.input) || !payload.input.every(record$10)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
11155
+ if (!record$11(payload) || !Array.isArray(payload.input) || !payload.input.every(record$11)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
11156
11156
  return {
11157
11157
  input: payload.input,
11158
11158
  payload
@@ -11248,7 +11248,7 @@ var ReplayRecoveryStore = class {
11248
11248
  const value = hash(item);
11249
11249
  return value === void 0 || !admitted.has(value);
11250
11250
  }).length === decoded.input.length) return payload;
11251
- if (!record$10(payload) || !Array.isArray(payload.input)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
11251
+ if (!record$11(payload) || !Array.isArray(payload.input)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
11252
11252
  const input = payload.input.filter((_, index) => {
11253
11253
  const item = decoded.input[index];
11254
11254
  const value = hash(item);
@@ -11268,6 +11268,82 @@ var ReplayRecoveryStore = class {
11268
11268
  }
11269
11269
  };
11270
11270
  //#endregion
11271
+ //#region lib/types/replay-recovery-evidence.js
11272
+ const REPLAY_RECOVERY_EVIDENCE = "githubCopilotReplayRecoveryEvidence";
11273
+ const count$2 = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
11274
+ const ReplayRecoveryEvidenceSchema = z.object({
11275
+ inherited: count$2,
11276
+ turn: count$2.nullable(),
11277
+ managed: z.boolean(),
11278
+ failureSeq: count$2.nullable()
11279
+ }).strict();
11280
+ function record$10(value) {
11281
+ return typeof value === "object" && value !== null && !Array.isArray(value);
11282
+ }
11283
+ function initialReplayRecoveryEvidence(inherited = 0) {
11284
+ return {
11285
+ inherited,
11286
+ turn: null,
11287
+ managed: false,
11288
+ failureSeq: null
11289
+ };
11290
+ }
11291
+ /** A historical fixed-code notice is not current account proof or recovery authorization. */
11292
+ function foldReplayRecoveryEvidence(state, event) {
11293
+ if (!record$10(event) || !count$2.safeParse(event.seq).success || Number(event.seq) < state.inherited || !record$10(event.data)) return state;
11294
+ const data = event.data;
11295
+ if (event.type === "turn/start") {
11296
+ const turn = count$2.safeParse(data.turn);
11297
+ return {
11298
+ ...state,
11299
+ turn: turn.success ? turn.data : null,
11300
+ failureSeq: null
11301
+ };
11302
+ }
11303
+ if (state.turn === null) return state;
11304
+ if (event.type === "request/header") {
11305
+ const config = record$10(data.header) ? data.header.config : void 0;
11306
+ return {
11307
+ ...state,
11308
+ managed: record$10(config) && config.provider === "github-copilot-preview"
11309
+ };
11310
+ }
11311
+ if (event.type !== "turn/end" || data.turn !== state.turn) return state;
11312
+ const reason = data.reason;
11313
+ const error = record$10(reason) && reason.kind === "error" ? reason.error : void 0;
11314
+ const rejected = record$10(error) && (error.code === "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH" || typeof error.message === "string" && error.message.length <= 8192 && error.message.startsWith("COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH:"));
11315
+ return {
11316
+ ...state,
11317
+ turn: null,
11318
+ failureSeq: state.managed && rejected ? Number(event.seq) : null
11319
+ };
11320
+ }
11321
+ const replayRecoveryEvidenceDefinition = {
11322
+ key: REPLAY_RECOVERY_EVIDENCE,
11323
+ stateVersion: 1,
11324
+ stateSchema: ReplayRecoveryEvidenceSchema,
11325
+ init: (_header, inherited = 0) => initialReplayRecoveryEvidence(inherited),
11326
+ apply: foldReplayRecoveryEvidence,
11327
+ wire: {
11328
+ viewSchema: ReplayRecoveryEvidenceSchema,
11329
+ view: (state) => state
11330
+ }
11331
+ };
11332
+ function installReplayRecoveryEvidence(ctx) {
11333
+ ctx.inject(["sessionProjections"], (scope) => {
11334
+ const registry = scope.get("sessionProjections");
11335
+ if (!record$10(registry) || typeof registry.register !== "function") {
11336
+ scope.logger.warn("COPILOT_REPLAY_RECOVERY_PROJECTION_UNAVAILABLE");
11337
+ return;
11338
+ }
11339
+ const remove = registry.register(replayRecoveryEvidenceDefinition);
11340
+ if (typeof remove !== "function") throw new Error("COPILOT_REPLAY_RECOVERY_PROJECTION_DISPOSER_UNAVAILABLE");
11341
+ return () => {
11342
+ remove();
11343
+ };
11344
+ });
11345
+ }
11346
+ //#endregion
11271
11347
  //#region lib/types/replay-recovery-host.js
11272
11348
  var __runInitializers$2 = function(thisArg, initializers, value) {
11273
11349
  var useValue = arguments.length > 2;
@@ -11384,6 +11460,7 @@ let ReplayRecoveryController = (() => {
11384
11460
  };
11385
11461
  })();
11386
11462
  function installReplayRecovery(ctx, proof) {
11463
+ installReplayRecoveryEvidence(ctx);
11387
11464
  const store = new ReplayRecoveryStore();
11388
11465
  const requests = /* @__PURE__ */ new WeakMap();
11389
11466
  const currentRequests = /* @__PURE__ */ new WeakMap();
@@ -13539,7 +13616,8 @@ function diagnosticMime(value) {
13539
13616
  return typeof value === "string" && value.length <= 128 && imageMime.test(value) ? value.toLowerCase() : "unavailable";
13540
13617
  }
13541
13618
  /** Inspect native projected images, never infer wire formats from durable filenames. */
13542
- function imageInputFailure(model, messages) {
13619
+ function imageInputFailure(model, messages, observe) {
13620
+ let mismatchReported = false;
13543
13621
  for (const [messageIndex, message] of messages.entries()) {
13544
13622
  if (typeof message !== "object" || message === null || !("content" in message) || !Array.isArray(message.content)) continue;
13545
13623
  const content = message.content;
@@ -13550,8 +13628,13 @@ function imageInputFailure(model, messages) {
13550
13628
  let code;
13551
13629
  if (!model.input.includes("image")) code = "COPILOT_IMAGE_INPUT_UNSUPPORTED";
13552
13630
  else if (typeof mimeType !== "string" || !imageMime.test(mimeType)) code = "COPILOT_IMAGE_MEDIA_TYPE_UNAVAILABLE";
13553
- else if (allowed !== void 0 && !allowed.includes(mimeType.toLowerCase())) code = "COPILOT_IMAGE_MEDIA_TYPE_UNSUPPORTED";
13554
- else continue;
13631
+ else {
13632
+ if (!mismatchReported && allowed !== void 0 && !allowed.includes(mimeType.toLowerCase())) {
13633
+ mismatchReported = true;
13634
+ observe?.("COPILOT_IMAGE_MEDIA_TYPE_UNADVERTISED");
13635
+ }
13636
+ continue;
13637
+ }
13555
13638
  const role = "role" in message && typeof message.role === "string" && [
13556
13639
  "user",
13557
13640
  "assistant",
@@ -13573,7 +13656,7 @@ function imageInputFailure(model, messages) {
13573
13656
  return {
13574
13657
  code,
13575
13658
  diagnostic,
13576
- message: `${code}: Request blocked before selected-model dispatch. ${code === "COPILOT_IMAGE_INPUT_UNSUPPORTED" ? "The selected model does not admit image input." : code === "COPILOT_IMAGE_MEDIA_TYPE_UNAVAILABLE" ? "The native projected image MIME is missing or invalid; format compatibility cannot be verified." : "The native projected image MIME is outside the selected model's explicit account-advertised formats."} History images also count, even on a text-only continuation. Auto checks general image capability, not candidate-specific projected formats. For a subsequent turn, explicitly choose a model whose advertised formats accept this projection, or start a separate text-only Session without the old images. If MIME is unavailable, report this diagnostic; filenames do not establish projected format. No automatic retry or model switch was performed. Projected transcript positions are zero-based, not durable history IDs. ${JSON.stringify(diagnostic)}`
13659
+ message: `${code}: Request blocked before selected-model dispatch. ${code === "COPILOT_IMAGE_INPUT_UNSUPPORTED" ? "The selected model does not admit image input." : "The native projected image MIME is missing or invalid; format compatibility cannot be verified."} History images also count, even on a text-only continuation. Auto checks general image capability, not candidate-specific projected formats. For a subsequent turn, explicitly choose a model whose advertised formats accept this projection, or start a separate text-only Session without the old images. If MIME is unavailable, report this diagnostic; filenames do not establish projected format. No automatic retry or model switch was performed. Projected transcript positions are zero-based, not durable history IDs. ${JSON.stringify(diagnostic)}`
13577
13660
  };
13578
13661
  }
13579
13662
  }
@@ -13886,7 +13969,8 @@ var PreviewAdapter = class extends PiAiAdapter {
13886
13969
  replayRecovery;
13887
13970
  requestCheckpoint;
13888
13971
  captureRequest;
13889
- constructor(lifetime, optionsFor, discoverSnapshot, refreshRejected, requestBudgetSettings, accountModelSettings, classifierReasoningOff = false, replayRecovery, requestCheckpoint, captureRequest = () => void 0) {
13972
+ imageDiagnostic;
13973
+ constructor(lifetime, optionsFor, discoverSnapshot, refreshRejected, requestBudgetSettings, accountModelSettings, classifierReasoningOff = false, replayRecovery, requestCheckpoint, captureRequest = () => void 0, imageDiagnostic) {
13890
13974
  super(optionsFor());
13891
13975
  this.lifetime = lifetime;
13892
13976
  this.optionsFor = optionsFor;
@@ -13898,6 +13982,7 @@ var PreviewAdapter = class extends PiAiAdapter {
13898
13982
  this.replayRecovery = replayRecovery;
13899
13983
  this.requestCheckpoint = requestCheckpoint;
13900
13984
  this.captureRequest = captureRequest;
13985
+ this.imageDiagnostic = imageDiagnostic;
13901
13986
  }
13902
13987
  async listModels(provider) {
13903
13988
  owned(provider);
@@ -14062,7 +14147,7 @@ var PreviewAdapter = class extends PiAiAdapter {
14062
14147
  const inspectRequest = (_model, context, nativeOptions) => {
14063
14148
  owner.requestCheckpoint?.();
14064
14149
  if (signal.aborted) throw abortFailure(signal);
14065
- const imageFailure = imageInputFailure(lease.descriptor, context.messages);
14150
+ const imageFailure = imageInputFailure(lease.descriptor, context.messages, owner.imageDiagnostic);
14066
14151
  if (imageFailure !== void 0) {
14067
14152
  requestFailure = new LlmError(imageFailure.message, "INVALID_REQUEST");
14068
14153
  throw requestFailure;
@@ -14443,7 +14528,7 @@ function createAccountRuntime(ctx, config, binding, exclusionTurns, replayRecove
14443
14528
  };
14444
14529
  };
14445
14530
  return {
14446
- adapter: new PreviewAdapter(lifetime, optionsFor, discoverSnapshot, refreshRejected, budgetSettings, cacheSettings, false, replayRecovery, void 0, (signal) => ctx.get("githubCopilotSessionAccounts")?.recordRequest(signal)),
14531
+ adapter: new PreviewAdapter(lifetime, optionsFor, discoverSnapshot, refreshRejected, budgetSettings, cacheSettings, false, replayRecovery, void 0, (signal) => ctx.get("githubCopilotSessionAccounts")?.recordRequest(signal), (code) => ctx.logger.warn(code)),
14447
14532
  preview: {
14448
14533
  getView,
14449
14534
  refresh,
@@ -14545,7 +14630,7 @@ function createAccountRuntime(ctx, config, binding, exclusionTurns, replayRecove
14545
14630
  });
14546
14631
  const revision = lifetime.revision;
14547
14632
  const classifierOptionsFor = (lease, hooks) => optionsFor(lease, hooks, true);
14548
- const adapter = new PreviewAdapter(lifetime, classifierOptionsFor, discoverSnapshot, refreshRejected, budgetSettings, cacheSettings, true, void 0, checkpoint);
14633
+ const adapter = new PreviewAdapter(lifetime, classifierOptionsFor, discoverSnapshot, refreshRejected, budgetSettings, cacheSettings, true, void 0, checkpoint, void 0, (code) => ctx.logger.warn(code));
14549
14634
  try {
14550
14635
  const prepared = await adapter.prepareCall(GITHUB_COPILOT_PREVIEW_PROVIDER_ID, model.id, signal);
14551
14636
  checkpoint?.();
@@ -1,5 +1,6 @@
1
1
  import type { AccountModelDescriptor } from './account-model-catalog.ts';
2
- export type ImageInputFailureCode = 'COPILOT_IMAGE_INPUT_UNSUPPORTED' | 'COPILOT_IMAGE_MEDIA_TYPE_UNAVAILABLE' | 'COPILOT_IMAGE_MEDIA_TYPE_UNSUPPORTED';
2
+ export type ImageInputFailureCode = 'COPILOT_IMAGE_INPUT_UNSUPPORTED' | 'COPILOT_IMAGE_MEDIA_TYPE_UNAVAILABLE';
3
+ export type ImageInputDiagnosticCode = 'COPILOT_IMAGE_MEDIA_TYPE_UNADVERTISED';
3
4
  export interface ImageInputFailure {
4
5
  readonly code: ImageInputFailureCode;
5
6
  readonly message: string;
@@ -16,5 +17,5 @@ export interface ImageInputFailure {
16
17
  };
17
18
  }
18
19
  /** Inspect native projected images, never infer wire formats from durable filenames. */
19
- export declare function imageInputFailure(model: AccountModelDescriptor, messages: readonly unknown[]): ImageInputFailure | undefined;
20
+ export declare function imageInputFailure(model: AccountModelDescriptor, messages: readonly unknown[], observe?: (code: ImageInputDiagnosticCode) => void): ImageInputFailure | undefined;
20
21
  //# sourceMappingURL=image-input-admission.d.ts.map