dsh-github-copilot 0.4.0-alpha.132 → 0.4.0-alpha.134

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
@@ -311,7 +311,7 @@ const result$1 = strictRemoteCodec("dsh-github-copilot#DiagnosticsView", Diagnos
311
311
  var package_default = {
312
312
  name: "dsh-github-copilot",
313
313
  description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
314
- version: "0.4.0-alpha.132",
314
+ version: "0.4.0-alpha.134",
315
315
  publishConfig: {
316
316
  "access": "public",
317
317
  "registry": "https://registry.npmjs.org/",
@@ -365,6 +365,7 @@ var package_default = {
365
365
  "AGENTS.md",
366
366
  "docs/agent-readiness.md",
367
367
  "docs/model-compatibility-acceptance.md",
368
+ "docs/auto-review-sampling.md",
368
369
  "docs/single-route-migration.md",
369
370
  "docs/session-search-routing.md",
370
371
  "docs/npm-distribution.md",
@@ -2191,7 +2192,7 @@ var Budget = class {
2191
2192
  if (this.consumed > ACCOUNT_MODEL_CATALOG_LIMITS.maxBytes) fail$1("CATALOG_TOO_LARGE", true);
2192
2193
  }
2193
2194
  };
2194
- function record$14(value, code) {
2195
+ function record$15(value, code) {
2195
2196
  if (typeof value !== "object" || value === null || Array.isArray(value)) fail$1(code);
2196
2197
  return value;
2197
2198
  }
@@ -2244,11 +2245,11 @@ function normalizeModel(raw, id, options, budget) {
2244
2245
  if (options.availableModelIds?.has(id) !== true) fail$1("MISSING_POLICY");
2245
2246
  policySource = "account-available-id";
2246
2247
  } else {
2247
- if (text$2(field(record$14(rawPolicy, "INVALID_POLICY"), "state", budget), 64, "INVALID_POLICY", budget) !== "enabled") fail$1("POLICY_NOT_ENABLED");
2248
+ if (text$2(field(record$15(rawPolicy, "INVALID_POLICY"), "state", budget), 64, "INVALID_POLICY", budget) !== "enabled") fail$1("POLICY_NOT_ENABLED");
2248
2249
  policySource = "server-enabled";
2249
2250
  }
2250
- const capabilities = record$14(field(raw, "capabilities", budget), "INVALID_CAPABILITIES");
2251
- const supports = record$14(field(capabilities, "supports", budget), "INVALID_SUPPORTS");
2251
+ const capabilities = record$15(field(raw, "capabilities", budget), "INVALID_CAPABILITIES");
2252
+ const supports = record$15(field(capabilities, "supports", budget), "INVALID_SUPPORTS");
2252
2253
  const streaming = field(supports, "streaming", budget);
2253
2254
  if (streaming === false) fail$1("STREAMING_UNSUPPORTED");
2254
2255
  if (streaming !== true) fail$1("INVALID_SUPPORTS");
@@ -2269,7 +2270,7 @@ function normalizeModel(raw, id, options, budget) {
2269
2270
  if (selected === void 0) fail$1(unsupportedEndpointCount === 0 && endpoints.includes("ws:/responses") ? "WEBSOCKET_ONLY" : "UNSUPPORTED_ENDPOINTS");
2270
2271
  const rawLimits = field(capabilities, "limits", budget);
2271
2272
  if (rawLimits === void 0) fail$1("MISSING_LIMITS");
2272
- const limits = record$14(rawLimits, "INVALID_LIMITS");
2273
+ const limits = record$15(rawLimits, "INVALID_LIMITS");
2273
2274
  const maxContext = optionalPositive(limits, "max_context_window_tokens", "INVALID_LIMITS", budget);
2274
2275
  const maxInputTokens = optionalPositive(limits, "max_prompt_tokens", "INVALID_LIMITS", budget);
2275
2276
  if (maxContext === void 0 && maxInputTokens === void 0) fail$1("MISSING_CONTEXT_LIMIT");
@@ -2279,8 +2280,6 @@ function normalizeModel(raw, id, options, budget) {
2279
2280
  const efforts = rawEfforts === void 0 ? [] : stringList(rawEfforts, ACCOUNT_MODEL_CATALOG_LIMITS.maxEfforts, ACCOUNT_MODEL_CATALOG_LIMITS.maxEffortLength, "INVALID_REASONING", budget);
2280
2281
  const adaptiveThinking = field(supports, "adaptive_thinking", budget);
2281
2282
  if (adaptiveThinking !== void 0 && typeof adaptiveThinking !== "boolean") fail$1("INVALID_REASONING");
2282
- const thinking = field(supports, "thinking", budget);
2283
- if (thinking !== void 0 && typeof thinking !== "boolean") fail$1("INVALID_REASONING");
2284
2283
  const minThinkingBudget = optionalPositive(supports, "min_thinking_budget", "INVALID_REASONING", budget);
2285
2284
  const maxThinkingBudget = optionalPositive(supports, "max_thinking_budget", "INVALID_REASONING", budget);
2286
2285
  if (minThinkingBudget !== void 0 && maxThinkingBudget !== void 0 && minThinkingBudget > maxThinkingBudget) fail$1("INVALID_REASONING");
@@ -2289,7 +2288,7 @@ function normalizeModel(raw, id, options, budget) {
2289
2288
  if (vision === true) {
2290
2289
  const rawVisionLimits = field(limits, "vision", budget);
2291
2290
  if (rawVisionLimits !== void 0) {
2292
- const rawMediaTypes = field(record$14(rawVisionLimits, "INVALID_VISION_LIMITS"), "supported_media_types", budget);
2291
+ const rawMediaTypes = field(record$15(rawVisionLimits, "INVALID_VISION_LIMITS"), "supported_media_types", budget);
2293
2292
  if (rawMediaTypes !== void 0) {
2294
2293
  const mediaTypes = stringList(rawMediaTypes, ACCOUNT_MODEL_CATALOG_LIMITS.maxMediaTypes, 128, "INVALID_VISION_LIMITS", budget);
2295
2294
  const mime = /^[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*\/[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*$/iu;
@@ -2315,7 +2314,6 @@ function normalizeModel(raw, id, options, budget) {
2315
2314
  ...minThinkingBudget === void 0 ? {} : { minThinkingBudget },
2316
2315
  ...maxThinkingBudget === void 0 ? {} : { maxThinkingBudget }
2317
2316
  }),
2318
- sampling: Object.freeze({ temperature: thinking === true ? "unsupported" : thinking === false ? "supported" : "unknown" }),
2319
2317
  evidence: Object.freeze({
2320
2318
  endpoints: Object.freeze(endpoints),
2321
2319
  unsupportedEndpointCount,
@@ -2352,7 +2350,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
2352
2350
  fail$1("INVALID_JSON", true);
2353
2351
  }
2354
2352
  }
2355
- const data = field(record$14(raw, "INVALID_CATALOG"), "data", budget);
2353
+ const data = field(record$15(raw, "INVALID_CATALOG"), "data", budget);
2356
2354
  if (!Array.isArray(data)) fail$1("INVALID_CATALOG");
2357
2355
  const count = field(data, "length", budget);
2358
2356
  if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0) fail$1("INVALID_CATALOG");
@@ -2375,7 +2373,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
2375
2373
  for (let index = 0; index < count; index++) {
2376
2374
  let id;
2377
2375
  try {
2378
- const candidate = record$14(field(data, String(index), budget), "INVALID_MODEL");
2376
+ const candidate = record$15(field(data, String(index), budget), "INVALID_MODEL");
2379
2377
  const candidateId = text$2(field(candidate, "id", budget), ACCOUNT_MODEL_CATALOG_LIMITS.maxIdLength, "INVALID_ID", budget);
2380
2378
  if (!identifier.test(candidateId)) fail$1("INVALID_ID");
2381
2379
  id = candidateId;
@@ -3398,16 +3396,16 @@ function formatRequestUploadEvidence(evidence) {
3398
3396
  //#endregion
3399
3397
  //#region lib/types/request-body-timeout.js
3400
3398
  const observedMessage = "Timed out reading request body. Try again, or use a smaller request size.";
3401
- function record$13(value) {
3399
+ function record$14(value) {
3402
3400
  return typeof value === "object" && value !== null && !Array.isArray(value);
3403
3401
  }
3404
3402
  /** Verified provider evidence, not guessed capabilities, token limits or network cause. */
3405
3403
  async function requestBodyTimeoutDiagnostic(response, body, signal, dispatch) {
3406
3404
  if (response.status !== 408 || signal?.aborted) return void 0;
3407
3405
  const value = await readResponseErrorJson(response, signal);
3408
- if (signal?.aborted || !record$13(value)) return void 0;
3406
+ if (signal?.aborted || !record$14(value)) return void 0;
3409
3407
  const error = Object.hasOwn(value, "error") ? value.error : value;
3410
- 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;
3408
+ 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;
3411
3409
  const compression = dispatch?.compression;
3412
3410
  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.` : "";
3413
3411
  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).`;
@@ -3702,7 +3700,6 @@ function accountModelFromDescriptor(descriptor, baseURL) {
3702
3700
  reasoning: supported.length > 0,
3703
3701
  thinkingLevelMap: Object.freeze(map),
3704
3702
  unmappedReasoningEfforts: Object.freeze(unmapped),
3705
- temperatureCompatibility: descriptor.sampling.temperature,
3706
3703
  ...descriptor.reasoning.minThinkingBudget === void 0 ? {} : { minThinkingBudget: descriptor.reasoning.minThinkingBudget },
3707
3704
  ...descriptor.reasoning.maxThinkingBudget === void 0 ? {} : { maxThinkingBudget: descriptor.reasoning.maxThinkingBudget },
3708
3705
  headers: copilotPublicHeaders(),
@@ -3930,7 +3927,7 @@ function createAccountProvider(descriptors, guard, baseURL) {
3930
3927
  fetch: observeResponse
3931
3928
  } : {
3932
3929
  ...options,
3933
- ...responses && entry.temperatureCompatibility === "unsupported" ? { temperature: void 0 } : {},
3930
+ ...responses && guard.responsesOmitTemperature === true ? { temperature: void 0 } : {},
3934
3931
  signal: liveness?.signal ?? lease.signal,
3935
3932
  headers,
3936
3933
  fetch: observeResponse,
@@ -6180,7 +6177,7 @@ const usageSchema = z.object({
6180
6177
  totalTokens: count$2.optional(),
6181
6178
  reasoningTokens: count$2.optional()
6182
6179
  });
6183
- function record$12(value) {
6180
+ function record$13(value) {
6184
6181
  return typeof value === "object" && value !== null && !Array.isArray(value);
6185
6182
  }
6186
6183
  function sameRoute$1(left, right) {
@@ -6202,7 +6199,7 @@ function initialContextEvidence() {
6202
6199
  }
6203
6200
  /** Read only counts and routing leaves; never message content or opaque replay. */
6204
6201
  function foldContextEvidence(state, event) {
6205
- if (!record$12(event) || typeof event.type !== "string" || !record$12(event.data)) return state;
6202
+ if (!record$13(event) || typeof event.type !== "string" || !record$13(event.data)) return state;
6206
6203
  if (event.type === "step/start") {
6207
6204
  const step = stepSchema.safeParse({
6208
6205
  turn: event.data.turn,
@@ -6264,7 +6261,7 @@ function foldContextEvidence(state, event) {
6264
6261
  };
6265
6262
  const operation = state.compaction;
6266
6263
  if (operation?.state === "running" && count$2.safeParse(event.seq).success && Number(event.seq) > operation.startSeq) {
6267
- if (event.type === "user/message" && record$12(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === operation.id) state = {
6264
+ if (event.type === "user/message" && record$13(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === operation.id) state = {
6268
6265
  ...state,
6269
6266
  compaction: {
6270
6267
  ...operation,
@@ -6281,7 +6278,7 @@ function foldContextEvidence(state, event) {
6281
6278
  };
6282
6279
  }
6283
6280
  if (event.type === "request/header" || event.type === "model/selection") {
6284
- const raw = event.type === "request/header" ? record$12(event.data.header) ? event.data.header.config : void 0 : event.data;
6281
+ const raw = event.type === "request/header" ? record$13(event.data.header) ? event.data.header.config : void 0 : event.data;
6285
6282
  const revoke = () => state.compaction ? {
6286
6283
  ...state.compaction,
6287
6284
  headerSeq: null,
@@ -6289,7 +6286,7 @@ function foldContextEvidence(state, event) {
6289
6286
  step: null,
6290
6287
  request: "unknown"
6291
6288
  } : state.compaction;
6292
- if (!record$12(raw)) return {
6289
+ if (!record$13(raw)) return {
6293
6290
  ...state,
6294
6291
  route: null,
6295
6292
  sample: null,
@@ -6340,7 +6337,7 @@ function foldContextEvidence(state, event) {
6340
6337
  };
6341
6338
  }
6342
6339
  if (event.type.startsWith("compaction/") || event.surfaceOp !== void 0 && event.surfaceOp !== "append") {
6343
- const checkpoint = event.type === "user/message" && record$12(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === state.compaction?.id;
6340
+ const checkpoint = event.type === "user/message" && record$13(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === state.compaction?.id;
6344
6341
  return {
6345
6342
  ...state,
6346
6343
  sample: null,
@@ -6358,9 +6355,9 @@ function foldContextEvidence(state, event) {
6358
6355
  }
6359
6356
  if (event.type !== "assistant/message" && event.type !== "assistant/attempt") return state;
6360
6357
  if (!copilot(state.route)) return state;
6361
- const source = record$12(event.data.message) ? event.data.message.source : event.data.source;
6358
+ const source = record$13(event.data.message) ? event.data.message.source : event.data.source;
6362
6359
  if (event.type === "assistant/message" && source !== void 0) {
6363
- const parsed = routeSchema.safeParse(record$12(source) ? {
6360
+ const parsed = routeSchema.safeParse(record$13(source) ? {
6364
6361
  provider: source.provider,
6365
6362
  model: source.model
6366
6363
  } : source);
@@ -6390,11 +6387,11 @@ function foldContextEvidence(state, event) {
6390
6387
  const settledUsage = usage !== void 0;
6391
6388
  let terminal;
6392
6389
  for (const entry of stream) {
6393
- if (!record$12(entry) || entry.type !== "chunk" || !record$12(entry.chunk)) continue;
6390
+ if (!record$13(entry) || entry.type !== "chunk" || !record$13(entry.chunk)) continue;
6394
6391
  if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
6395
6392
  if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
6396
6393
  }
6397
- const successful = event.data.interrupted !== true && record$12(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
6394
+ const successful = event.data.interrupted !== true && record$13(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
6398
6395
  const compact = state.compaction;
6399
6396
  if (compact?.state === "completed") {
6400
6397
  if (compact.headerSeq === null || !count$2.safeParse(event.seq).success || Number(event.seq) <= compact.headerSeq) return state;
@@ -6411,7 +6408,7 @@ function foldContextEvidence(state, event) {
6411
6408
  ...state,
6412
6409
  compaction: {
6413
6410
  ...compact,
6414
- 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"
6411
+ 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"
6415
6412
  }
6416
6413
  };
6417
6414
  } else if (compact?.state === "running") return state;
@@ -6478,7 +6475,7 @@ const contextEvidenceDefinition = {
6478
6475
  function installContextEvidence(ctx) {
6479
6476
  ctx.inject(["sessionProjections"], (scope) => {
6480
6477
  const registry = scope.get("sessionProjections");
6481
- if (!record$12(registry) || typeof registry.register !== "function") {
6478
+ if (!record$13(registry) || typeof registry.register !== "function") {
6482
6479
  scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
6483
6480
  return;
6484
6481
  }
@@ -6872,6 +6869,7 @@ const Config = z$1.object({
6872
6869
  chatStreamLiveness: z$1.boolean().default(true),
6873
6870
  chatMaxRequestImageBytes: z$1.number().step(1).min(1).max(Number.MAX_SAFE_INTEGER).default(20971520),
6874
6871
  responsesRequestCompression: z$1.boolean().default(false),
6872
+ responsesOmitTemperature: z$1.boolean().default(false),
6875
6873
  probe: z$1.boolean().default(true),
6876
6874
  probeTimeoutMs: z$1.number().step(1).min(1).max(MAX_TIMEOUT_MS).default(3e4),
6877
6875
  accountModelTtlMs: z$1.number().step(1).min(0).max(MAX_TIMEOUT_MS).default(864e5),
@@ -7540,7 +7538,7 @@ function buildAnthropicWireBody(request, cfg, model) {
7540
7538
  }
7541
7539
  //#endregion
7542
7540
  //#region lib/types/responses-reasoning-text.js
7543
- function record$11(value) {
7541
+ function record$12(value) {
7544
7542
  return typeof value === "object" && value !== null;
7545
7543
  }
7546
7544
  function responseIndex(value) {
@@ -7598,13 +7596,13 @@ var ResponsesReasoningText = class {
7598
7596
  }
7599
7597
  /** Only recognized public text fields are examined; no copying of the item. */
7600
7598
  snapshot(item) {
7601
- if (!record$11(item) || item.type !== "reasoning") return "";
7599
+ if (!record$12(item) || item.type !== "reasoning") return "";
7602
7600
  let delta = "";
7603
7601
  for (const family of ["summary", "raw"]) {
7604
7602
  const value = family === "summary" ? item.summary : item.content;
7605
7603
  if (!Array.isArray(value)) continue;
7606
7604
  for (const [index, part] of value.entries()) {
7607
- if (!record$11(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
7605
+ if (!record$12(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
7608
7606
  delta += this.update(family, index, part.text, true);
7609
7607
  }
7610
7608
  }
@@ -9943,13 +9941,13 @@ function resolveCopilotResponsesReasoning(ctx, request, candidate) {
9943
9941
  }
9944
9942
  //#endregion
9945
9943
  //#region lib/types/replay-recovery.js
9946
- function record$10(value) {
9944
+ function record$11(value) {
9947
9945
  return value !== null && typeof value === "object" && !Array.isArray(value);
9948
9946
  }
9949
9947
  function parsed(body) {
9950
9948
  if (requestBodyEvidence(body, "openai-responses").state !== "complete" || body === void 0) throw new Error("COPILOT_REPLAY_RECOVERY_EVIDENCE_UNAVAILABLE");
9951
9949
  const payload = JSON.parse(body);
9952
- if (!record$10(payload) || !Array.isArray(payload.input) || !payload.input.every(record$10)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
9950
+ if (!record$11(payload) || !Array.isArray(payload.input) || !payload.input.every(record$11)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
9953
9951
  return {
9954
9952
  input: payload.input,
9955
9953
  payload
@@ -10045,7 +10043,7 @@ var ReplayRecoveryStore = class {
10045
10043
  const value = hash(item);
10046
10044
  return value === void 0 || !admitted.has(value);
10047
10045
  }).length === decoded.input.length) return payload;
10048
- if (!record$10(payload) || !Array.isArray(payload.input)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
10046
+ if (!record$11(payload) || !Array.isArray(payload.input)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
10049
10047
  const input = payload.input.filter((_, index) => {
10050
10048
  const item = decoded.input[index];
10051
10049
  const value = hash(item);
@@ -10251,7 +10249,7 @@ const SESSION_CONTINUATION_LIMITS = Object.freeze({
10251
10249
  ciphertextCodeUnits: 67108864,
10252
10250
  chunkCodeUnits: 65536
10253
10251
  });
10254
- function record$9(value) {
10252
+ function record$10(value) {
10255
10253
  return typeof value === "object" && value !== null && !Array.isArray(value);
10256
10254
  }
10257
10255
  /** One admitted turn; fingerprints never become durable history or account provenance. */
@@ -10264,7 +10262,7 @@ var SessionContinuationTurn = class {
10264
10262
  async transform(payload, assertCurrent = () => {}) {
10265
10263
  assertCurrent();
10266
10264
  if (this.processing) throw new Error("COPILOT_CONTINUATION_PROCESSING_OVERLAP");
10267
- if (!record$9(payload) || !Array.isArray(payload.input) || payload.input.length > SESSION_CONTINUATION_LIMITS.inputItems) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
10265
+ if (!record$10(payload) || !Array.isArray(payload.input) || payload.input.length > SESSION_CONTINUATION_LIMITS.inputItems) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
10268
10266
  this.processing = true;
10269
10267
  try {
10270
10268
  const hashes = /* @__PURE__ */ new Map();
@@ -10275,7 +10273,7 @@ var SessionContinuationTurn = class {
10275
10273
  assertCurrent();
10276
10274
  }
10277
10275
  const item = payload.input[index];
10278
- if (!record$9(item)) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
10276
+ if (!record$10(item)) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
10279
10277
  if (item.type !== "reasoning") continue;
10280
10278
  const ciphertext = item.encrypted_content;
10281
10279
  if (typeof ciphertext !== "string" || !ciphertext || item.status !== void 0 && item.status !== "completed") throw new Error("COPILOT_CONTINUATION_UNSUPPORTED_REASONING");
@@ -10374,7 +10372,7 @@ const compactionContinuationDefinition = {
10374
10372
  view: (state) => state
10375
10373
  }
10376
10374
  };
10377
- function record$8(value) {
10375
+ function record$9(value) {
10378
10376
  return typeof value === "object" && value !== null && !Array.isArray(value);
10379
10377
  }
10380
10378
  /** Native brackets authorize scope, never loss; the existing Session policy authorizes loss. */
@@ -10384,7 +10382,7 @@ function installCompactionContinuation(ctx, enabled) {
10384
10382
  let disposed = false;
10385
10383
  const removeProjection = ctx.inject(["sessionProjections"], (scope) => {
10386
10384
  const registry = scope.get("sessionProjections");
10387
- if (!record$8(registry) || typeof registry.register !== "function") throw new Error("COPILOT_CONTINUATION_COMPACTION_PROJECTION_UNAVAILABLE");
10385
+ if (!record$9(registry) || typeof registry.register !== "function") throw new Error("COPILOT_CONTINUATION_COMPACTION_PROJECTION_UNAVAILABLE");
10388
10386
  const remove = registry.register(compactionContinuationDefinition);
10389
10387
  if (typeof remove !== "function") throw new Error("COPILOT_CONTINUATION_COMPACTION_PROJECTION_DISPOSER_UNAVAILABLE");
10390
10388
  return () => {
@@ -10840,7 +10838,7 @@ function installCompactionReplay(ctx) {
10840
10838
  }
10841
10839
  //#endregion
10842
10840
  //#region lib/types/agent-compaction.js
10843
- function record$7(value) {
10841
+ function record$8(value) {
10844
10842
  return typeof value === "object" && value !== null;
10845
10843
  }
10846
10844
  /** Resolve the owning preset's service without reaching into Core's service registry. */
@@ -10848,7 +10846,7 @@ function agentCompaction(agent) {
10848
10846
  if (typeof agent.ctx?.get !== "function") throw new LlmError("COPILOT_COMPACTION_AGENT_CONTEXT_UNAVAILABLE", "INVALID_REQUEST");
10849
10847
  const presets = agent.ctx.get("agentPresets");
10850
10848
  if (presets !== void 0) {
10851
- if (!record$7(presets) || typeof presets.composedPreset !== "function" || typeof presets.serviceFor !== "function") throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
10849
+ if (!record$8(presets) || typeof presets.composedPreset !== "function" || typeof presets.serviceFor !== "function") throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
10852
10850
  const preset = presets.composedPreset(agent.ctx);
10853
10851
  if (preset !== void 0) {
10854
10852
  if (typeof preset !== "string" || preset.trim().length === 0) throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
@@ -10971,14 +10969,14 @@ function installCopilotCompactionPressure(ctx, callbacks) {
10971
10969
  }
10972
10970
  //#endregion
10973
10971
  //#region lib/types/pre-step-pressure.js
10974
- function record$6(value) {
10972
+ function record$7(value) {
10975
10973
  return typeof value === "object" && value !== null && !Array.isArray(value);
10976
10974
  }
10977
10975
  function positive(value) {
10978
10976
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
10979
10977
  }
10980
10978
  function isEngine(value) {
10981
- return record$6(value) && record$6(value.config) && typeof value.compactIfNeeded === "function";
10979
+ return record$7(value) && record$7(value.config) && typeof value.compactIfNeeded === "function";
10982
10980
  }
10983
10981
  /**
10984
10982
  * Prevent a continuing, unchanged route's known pressure from becoming an
@@ -10999,12 +10997,12 @@ function installCopilotPreStepPressure(ctx, callbacks) {
10999
10997
  const header = agent.session.requestHeader();
11000
10998
  if (header?.config.provider !== "github-copilot-preview" || !isPluginPreviewProvider(ctx, header.config.provider)) return decision;
11001
10999
  const projections = ctx.get("sessionProjections");
11002
- if (!record$6(projections) || typeof projections.stateOf !== "function") {
11000
+ if (!record$7(projections) || typeof projections.stateOf !== "function") {
11003
11001
  unavailable();
11004
11002
  return decision;
11005
11003
  }
11006
11004
  const selection = projections.stateOf(agent.session, "modelSelection");
11007
- if (!record$6(selection) || !Object.hasOwn(selection, "pending")) {
11005
+ if (!record$7(selection) || !Object.hasOwn(selection, "pending")) {
11008
11006
  unavailable();
11009
11007
  return decision;
11010
11008
  }
@@ -11026,20 +11024,20 @@ function installCopilotPreStepPressure(ctx, callbacks) {
11026
11024
  unavailable();
11027
11025
  return decision;
11028
11026
  }
11029
- const policy = Array.isArray(config.modelPolicies) ? config.modelPolicies.find((value) => record$6(value) && value.provider === header.config.provider && value.model === header.config.model) : void 0;
11030
- const retries = record$6(policy) ? policy.maxOverflowRetries ?? config.maxOverflowRetries : config.maxOverflowRetries;
11027
+ const policy = Array.isArray(config.modelPolicies) ? config.modelPolicies.find((value) => record$7(value) && value.provider === header.config.provider && value.model === header.config.model) : void 0;
11028
+ const retries = record$7(policy) ? policy.maxOverflowRetries ?? config.maxOverflowRetries : config.maxOverflowRetries;
11031
11029
  if (retries === 0) return decision;
11032
11030
  if (!positive(retries)) {
11033
11031
  unavailable();
11034
11032
  return decision;
11035
11033
  }
11036
11034
  const meter = ctx.get("tokenMeter");
11037
- if (!record$6(meter) || typeof meter.measure !== "function") {
11035
+ if (!record$7(meter) || typeof meter.measure !== "function") {
11038
11036
  unavailable();
11039
11037
  return decision;
11040
11038
  }
11041
11039
  const measured = meter.measure(agent.session);
11042
- if (!record$6(measured) || typeof measured.totalTokens !== "number" || !Number.isSafeInteger(measured.totalTokens) || measured.totalTokens < 0) {
11040
+ if (!record$7(measured) || typeof measured.totalTokens !== "number" || !Number.isSafeInteger(measured.totalTokens) || measured.totalTokens < 0) {
11043
11041
  unavailable();
11044
11042
  return decision;
11045
11043
  }
@@ -11157,17 +11155,17 @@ const TaskAssessmentSchema = z.object({
11157
11155
  "insufficient-evidence"
11158
11156
  ])).max(7)
11159
11157
  }).strict();
11160
- function record$5(value) {
11158
+ function record$6(value) {
11161
11159
  return typeof value === "object" && value !== null && !Array.isArray(value);
11162
11160
  }
11163
11161
  function text(message) {
11164
- if (!record$5(message) || !Array.isArray(message.content)) return "";
11165
- return message.content.flatMap((block) => record$5(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
11162
+ if (!record$6(message) || !Array.isArray(message.content)) return "";
11163
+ return message.content.flatMap((block) => record$6(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
11166
11164
  }
11167
11165
  function user(message) {
11168
- if (!record$5(message)) return false;
11169
- if (record$5(message.source) && message.source.kind === "model-selection") return false;
11170
- return message.role === "user" || record$5(message.source) && message.source.kind === "user";
11166
+ if (!record$6(message)) return false;
11167
+ if (record$6(message.source) && message.source.kind === "model-selection") return false;
11168
+ return message.role === "user" || record$6(message.source) && message.source.kind === "user";
11171
11169
  }
11172
11170
  function difficult(current) {
11173
11171
  return /\b(prove|proof|theorem|debug|investigate|diagnose)\b|证明|定理|调试|排查|根因|调查/iu.test(current);
@@ -11184,8 +11182,8 @@ function assessTaskLocally(messages) {
11184
11182
  const last = messages.findLast(user);
11185
11183
  const current = text(last).trim();
11186
11184
  const history = messages.slice(0, last === void 0 ? 0 : messages.lastIndexOf(last));
11187
- const hasWork = history.some((message) => record$5(message) && (message.role === "assistant" || message.role === "tool" || user(message) || record$5(message.source) && message.source.kind === "model"));
11188
- const nonText = record$5(last) && Array.isArray(last.content) && last.content.some((block) => !record$5(block) || block.type !== "text");
11185
+ const hasWork = history.some((message) => record$6(message) && (message.role === "assistant" || message.role === "tool" || user(message) || record$6(message.source) && message.source.kind === "model"));
11186
+ const nonText = record$6(last) && Array.isArray(last.content) && last.content.some((block) => !record$6(block) || block.type !== "text");
11189
11187
  if (!hasWork && !nonText && /^(hello|hi|hey|你好|您好|嗨)[!!。.\s]*$/iu.test(current)) return {
11190
11188
  demand: "simple",
11191
11189
  source: "local",
@@ -11227,7 +11225,7 @@ function assessTaskLocally(messages) {
11227
11225
  /** Separate text-only projection for assessment; never mutates the chat request. */
11228
11226
  function assessmentInput(messages) {
11229
11227
  let omitted = false;
11230
- const context = messages.filter((message) => !record$5(message) || message.role !== "system" && message.role !== "developer" && !(record$5(message.source) && message.source.kind === "model-selection"));
11228
+ const context = messages.filter((message) => !record$6(message) || message.role !== "system" && message.role !== "developer" && !(record$6(message.source) && message.source.kind === "model-selection"));
11231
11229
  const lastUser = context.findLastIndex(user);
11232
11230
  const priorUser = context.slice(0, lastUser < 0 ? 0 : lastUser).findLastIndex(user);
11233
11231
  const priority = [.../* @__PURE__ */ new Set([
@@ -11239,13 +11237,13 @@ function assessmentInput(messages) {
11239
11237
  let length = 0;
11240
11238
  for (const index of priority) {
11241
11239
  const message = context[index];
11242
- if (!record$5(message)) {
11240
+ if (!record$6(message)) {
11243
11241
  omitted = true;
11244
11242
  continue;
11245
11243
  }
11246
11244
  if (!Array.isArray(message.content)) omitted = true;
11247
11245
  const content = text(message);
11248
- if (Array.isArray(message.content) && message.content.some((block) => !record$5(block) || block.type !== "text")) omitted = true;
11246
+ if (Array.isArray(message.content) && message.content.some((block) => !record$6(block) || block.type !== "text")) omitted = true;
11249
11247
  if (content.length > 1600) omitted = true;
11250
11248
  const role = typeof message.role === "string" && [
11251
11249
  "user",
@@ -11397,14 +11395,14 @@ var AutoModelRoutingError = class extends Error {
11397
11395
  this.name = "AutoModelRoutingError";
11398
11396
  }
11399
11397
  };
11400
- function record$4(value) {
11398
+ function record$5(value) {
11401
11399
  return typeof value === "object" && value !== null;
11402
11400
  }
11403
11401
  function userMessage(value) {
11404
- if (!record$4(value)) return false;
11405
- if (record$4(value.source) && value.source.kind === "model-selection") return false;
11402
+ if (!record$5(value)) return false;
11403
+ if (record$5(value.source) && value.source.kind === "model-selection") return false;
11406
11404
  if (value.role === "user") return true;
11407
- return record$4(value.source) && value.source.kind === "user";
11405
+ return record$5(value.source) && value.source.kind === "user";
11408
11406
  }
11409
11407
  function latestUserContent(messages) {
11410
11408
  for (let index = messages.length - 1; index >= 0; index--) {
@@ -11415,9 +11413,9 @@ function latestUserContent(messages) {
11415
11413
  }
11416
11414
  function classifyAutoModelTurn(messages) {
11417
11415
  let text = "";
11418
- const requiresImage = messages.some((message) => record$4(message) && Array.isArray(message.content) && message.content.some((block) => record$4(block) && block.type === "image" && block.offloaded !== true));
11416
+ const requiresImage = messages.some((message) => record$5(message) && Array.isArray(message.content) && message.content.some((block) => record$5(block) && block.type === "image" && block.offloaded !== true));
11419
11417
  for (const block of latestUserContent(messages)) {
11420
- if (!record$4(block)) continue;
11418
+ if (!record$5(block)) continue;
11421
11419
  if (block.type === "text" && typeof block.text === "string") text += `${block.text}\n`;
11422
11420
  }
11423
11421
  const codeFenceCount = text.match(/```/gu)?.length ?? 0;
@@ -11467,7 +11465,7 @@ function resolveSeed(messages, context) {
11467
11465
  if (typeof context?.seed === "string" && context.seed.length > 0) return fnv1a(context.seed);
11468
11466
  if (context?.sessionId !== void 0) return fnv1a(`${context.sessionId}:${context.turn ?? 1}`);
11469
11467
  let text = "";
11470
- for (const block of latestUserContent(messages)) if (record$4(block) && typeof block.text === "string") text += block.text;
11468
+ for (const block of latestUserContent(messages)) if (record$5(block) && typeof block.text === "string") text += block.text;
11471
11469
  return fnv1a(text || "default-auto-seed");
11472
11470
  }
11473
11471
  function targetCategory(assessment, preference) {
@@ -11810,7 +11808,7 @@ const TurnRequestModelsStateSchema = z.object({
11810
11808
  }).strict().nullable(),
11811
11809
  turns: z.array(row).max(128)
11812
11810
  }).strict();
11813
- function record$3(value) {
11811
+ function record$4(value) {
11814
11812
  return typeof value === "object" && value !== null && !Array.isArray(value);
11815
11813
  }
11816
11814
  const validCount = (value) => count$1.safeParse(value).success;
@@ -11825,14 +11823,14 @@ function uncertain(state) {
11825
11823
  };
11826
11824
  }
11827
11825
  function foldTurnRequestModels(state, event) {
11828
- if (!record$3(event)) return state;
11826
+ if (!record$4(event)) return state;
11829
11827
  const lifecycle = [
11830
11828
  "turn/start",
11831
11829
  "turn/end",
11832
11830
  "step/start",
11833
11831
  "step/end"
11834
11832
  ].includes(String(event.type));
11835
- if (!record$3(event.data)) return lifecycle || event.type === "request/header" ? uncertain(state) : state;
11833
+ if (!record$4(event.data)) return lifecycle || event.type === "request/header" ? uncertain(state) : state;
11836
11834
  const data = event.data;
11837
11835
  if (lifecycle && (!validCount(data.turn) || event.type !== "turn/start" && state.active !== null && data.turn !== state.active.turn || String(event.type).startsWith("step/") && !validCount(data.step) || event.type === "step/start" && state.active?.step != null || event.type === "step/end" && state.active !== null && data.step !== state.active.step)) return uncertain(state);
11838
11836
  if (event.type === "turn/start" && validCount(data.turn)) return {
@@ -11867,8 +11865,8 @@ function foldTurnRequestModels(state, event) {
11867
11865
  active: null
11868
11866
  };
11869
11867
  if (event.type !== "request/header" || active.step === null) return state;
11870
- const config = record$3(data.header) ? data.header.config : void 0;
11871
- const parsed = route.safeParse(record$3(config) && [
11868
+ const config = record$4(data.header) ? data.header.config : void 0;
11869
+ const parsed = route.safeParse(record$4(config) && [
11872
11870
  "initial",
11873
11871
  "resume",
11874
11872
  "change",
@@ -11912,7 +11910,7 @@ const turnRequestModelsDefinition = {
11912
11910
  function installTurnRequestModels(ctx) {
11913
11911
  ctx.inject(["sessionProjections"], (scope) => {
11914
11912
  const registry = scope.get("sessionProjections");
11915
- if (!record$3(registry) || typeof registry.register !== "function") {
11913
+ if (!record$4(registry) || typeof registry.register !== "function") {
11916
11914
  scope.logger.warn("[github-copilot] COPILOT_TURN_REQUEST_PROJECTION_UNAVAILABLE");
11917
11915
  return;
11918
11916
  }
@@ -11965,7 +11963,7 @@ var __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializ
11965
11963
  if (target) Object.defineProperty(target, contextIn.name, descriptor);
11966
11964
  done = true;
11967
11965
  };
11968
- function record$2(value) {
11966
+ function record$3(value) {
11969
11967
  return typeof value === "object" && value !== null;
11970
11968
  }
11971
11969
  /** Public Host binding for the existing bounded, runtime-only decision store. */
@@ -12036,7 +12034,7 @@ let TurnSelectionController = (() => {
12036
12034
  requestedModels(agent, turn) {
12037
12035
  if (!Number.isSafeInteger(turn) || turn < 0) throw new Error("COPILOT_TURN_SELECTION_INVALID_TURN");
12038
12036
  const registry = this.ctx.get("sessionProjections");
12039
- if (!record$2(registry) || typeof registry.stateOf !== "function") throw new Error("COPILOT_TURN_REQUEST_PROJECTION_UNAVAILABLE");
12037
+ if (!record$3(registry) || typeof registry.stateOf !== "function") throw new Error("COPILOT_TURN_REQUEST_PROJECTION_UNAVAILABLE");
12040
12038
  const row = TurnRequestModelsStateSchema.parse(registry.stateOf(agent.session, TURN_REQUEST_MODELS)).turns.find((value) => value.turn === turn);
12041
12039
  return row ? {
12042
12040
  routes: row.routes,
@@ -12178,7 +12176,7 @@ const AutoModelIntentSchema = z.object({
12178
12176
  selection: selectionSchema.nullable(),
12179
12177
  blocked: z.boolean()
12180
12178
  }).strict();
12181
- function record$1(value) {
12179
+ function record$2(value) {
12182
12180
  return typeof value === "object" && value !== null && !Array.isArray(value);
12183
12181
  }
12184
12182
  function initialAutoModelIntent(inherited = 0) {
@@ -12190,7 +12188,7 @@ function initialAutoModelIntent(inherited = 0) {
12190
12188
  }
12191
12189
  /** Request headers describe execution, not replacement of an explicit picker intent. */
12192
12190
  function foldAutoModelIntent(state, event) {
12193
- if (!record$1(event) || event.type !== "model/selection") return state;
12191
+ if (!record$2(event) || event.type !== "model/selection") return state;
12194
12192
  if (!Number.isSafeInteger(event.seq) || Number(event.seq) < 0) return {
12195
12193
  ...state,
12196
12194
  selection: null,
@@ -12198,7 +12196,7 @@ function foldAutoModelIntent(state, event) {
12198
12196
  };
12199
12197
  if (Number(event.seq) < state.inherited) return state;
12200
12198
  const data = event.data;
12201
- const parsed = selectionSchema.safeParse(record$1(data) ? {
12199
+ const parsed = selectionSchema.safeParse(record$2(data) ? {
12202
12200
  provider: data.provider,
12203
12201
  model: data.model
12204
12202
  } : data);
@@ -12246,14 +12244,14 @@ async function decide(dependencies, signal, messages, preference, context) {
12246
12244
  throw cause;
12247
12245
  }
12248
12246
  }
12249
- function record(value) {
12247
+ function record$1(value) {
12250
12248
  return typeof value === "object" && value !== null;
12251
12249
  }
12252
12250
  function buildRoutingContext(ctx, agent, turn, messages, budgetPolicyConfig) {
12253
12251
  const meter = ctx.get("tokenMeter");
12254
- if (!record(meter) || typeof meter.estimateMessage !== "function" || typeof meter.measure !== "function") throw failure$1("COPILOT_AUTO_TOKEN_METER_UNAVAILABLE");
12252
+ if (!record$1(meter) || typeof meter.estimateMessage !== "function" || typeof meter.measure !== "function") throw failure$1("COPILOT_AUTO_TOKEN_METER_UNAVAILABLE");
12255
12253
  const measured = meter.measure(agent.session);
12256
- if (!record(measured) || typeof measured.totalTokens !== "number" || !Number.isSafeInteger(measured.totalTokens) || measured.totalTokens < 0) throw failure$1("COPILOT_AUTO_TOKEN_ESTIMATE_INVALID");
12254
+ if (!record$1(measured) || typeof measured.totalTokens !== "number" || !Number.isSafeInteger(measured.totalTokens) || measured.totalTokens < 0) throw failure$1("COPILOT_AUTO_TOKEN_ESTIMATE_INVALID");
12257
12255
  const estimate = meter.estimateMessage.bind(meter);
12258
12256
  const estimateMessage = (message) => {
12259
12257
  const value = estimate(message);
@@ -12262,9 +12260,9 @@ function buildRoutingContext(ctx, agent, turn, messages, budgetPolicyConfig) {
12262
12260
  };
12263
12261
  const sessionId = typeof agent.session?.id === "string" ? agent.session.id : void 0;
12264
12262
  const compaction = agentCompaction(agent);
12265
- const compactionConfig = record(compaction) && record(compaction.config) ? compaction.config : void 0;
12263
+ const compactionConfig = record$1(compaction) && record$1(compaction.config) ? compaction.config : void 0;
12266
12264
  const compactionAvailable = compaction !== void 0 && compactionConfig?.auto !== false && (typeof compactionConfig?.maxOverflowRetries !== "number" || compactionConfig.maxOverflowRetries > 0);
12267
- const hasCompactionSummary = messages.some((m) => record(m) && (record(m.source) && (m.source.kind === "compaction" || m.source.kind === "compact-checkpoint") || typeof m.surfaceOp === "object"));
12265
+ const hasCompactionSummary = messages.some((m) => record$1(m) && (record$1(m.source) && (m.source.kind === "compaction" || m.source.kind === "compact-checkpoint") || typeof m.surfaceOp === "object"));
12268
12266
  const requestHeader = typeof agent.session?.requestHeader === "function" ? agent.session.requestHeader() : void 0;
12269
12267
  const requestedMaxTokens = requestHeader?.config.maxTokens;
12270
12268
  const requestBudgetPolicy = budgetPolicyConfig ? resolveRequestBudgetPolicy(budgetPolicyConfig) : DEFAULT_REQUEST_BUDGET_POLICY;
@@ -12281,7 +12279,7 @@ function buildRoutingContext(ctx, agent, turn, messages, budgetPolicyConfig) {
12281
12279
  };
12282
12280
  }
12283
12281
  function modelSelectionNotice(value) {
12284
- return record(value) && record(value.source) && value.source.kind === "model-selection";
12282
+ return record$1(value) && record$1(value.source) && value.source.kind === "model-selection";
12285
12283
  }
12286
12284
  function routeLabel(provider, model, otherProvider) {
12287
12285
  return provider === otherProvider ? model : `${provider}/${model}`;
@@ -12329,12 +12327,12 @@ function installAutoModelRouting(ctx, dependencies) {
12329
12327
  };
12330
12328
  const pendingAuto = (agent) => {
12331
12329
  const registry = ctx.get("sessionProjections");
12332
- if (!record(registry) || typeof registry.stateOf !== "function") return void 0;
12330
+ if (!record$1(registry) || typeof registry.stateOf !== "function") return void 0;
12333
12331
  const native = registry.stateOf(agent.session, "modelSelection");
12334
- if (!record(native)) return void 0;
12332
+ if (!record$1(native)) return void 0;
12335
12333
  const selection = native.pending;
12336
12334
  if (selection === null && agent.session.requestHeader()?.config.provider === "github-copilot-preview") return retainedAuto(registry, agent.session);
12337
- if (!record(selection) || selection.provider !== "github-copilot-preview") return void 0;
12335
+ if (!record$1(selection) || selection.provider !== "github-copilot-preview") return void 0;
12338
12336
  return typeof selection.model === "string" && autoModelPreference(selection.model) !== void 0 ? selection.model : void 0;
12339
12337
  };
12340
12338
  const decisionFor = (agent, turn, messages, preference, signal) => {
@@ -12392,7 +12390,7 @@ function installAutoModelRouting(ctx, dependencies) {
12392
12390
  const previous = followed.get(agent);
12393
12391
  if (previous) {
12394
12392
  const registry = ctx.get("sessionProjections");
12395
- if (!record(registry) || typeof registry.stateOf !== "function") throw failure$1("COPILOT_PARENT_MODEL_PROJECTIONS_UNAVAILABLE");
12393
+ if (!record$1(registry) || typeof registry.stateOf !== "function") throw failure$1("COPILOT_PARENT_MODEL_PROJECTIONS_UNAVAILABLE");
12396
12394
  const state = followSchema.safeParse(registry.stateOf(agent.session, PARENT_MODEL_FOLLOW_PROJECTION));
12397
12395
  if (!state.success) throw failure$1("COPILOT_PARENT_MODEL_TURN_UNAVAILABLE");
12398
12396
  if (state.data.turn === previous.turn) return previous.selection;
@@ -12401,7 +12399,7 @@ function installAutoModelRouting(ctx, dependencies) {
12401
12399
  const followAll = dependencies.followParentModel?.() === true;
12402
12400
  if (!bindings.some((binding) => binding.childSessionId === agent.session.id) && (!followAll || agent.session.header.origin !== "subagent")) return void 0;
12403
12401
  const projections = ctx.get("sessionProjections");
12404
- if (!record(projections) || typeof projections.register !== "function" || typeof projections.stateOf !== "function") throw failure$1("COPILOT_PARENT_MODEL_PROJECTIONS_UNAVAILABLE");
12402
+ if (!record$1(projections) || typeof projections.register !== "function" || typeof projections.stateOf !== "function") throw failure$1("COPILOT_PARENT_MODEL_PROJECTIONS_UNAVAILABLE");
12405
12403
  const stateOf = projections.stateOf;
12406
12404
  if (!removeFollowProjection) {
12407
12405
  const remove = projections.register({
@@ -12417,16 +12415,16 @@ function installAutoModelRouting(ctx, dependencies) {
12417
12415
  };
12418
12416
  }
12419
12417
  const readSubject = (value) => {
12420
- if (!record(value) || !record(value.session)) return void 0;
12418
+ if (!record$1(value) || !record$1(value.session)) return void 0;
12421
12419
  const session = value.session;
12422
- if (typeof session.id !== "string" || !record(session.header) || typeof session.requestHeader !== "function") return void 0;
12420
+ if (typeof session.id !== "string" || !record$1(session.header) || typeof session.requestHeader !== "function") return void 0;
12423
12421
  const parsed = followSchema.safeParse(Reflect.apply(stateOf, projections, [session, PARENT_MODEL_FOLLOW_PROJECTION]));
12424
12422
  const selection = Reflect.apply(stateOf, projections, [session, "modelSelection"]);
12425
- if (!parsed.success || !record(selection) || !Object.hasOwn(selection, "pending")) throw failure$1("COPILOT_PARENT_MODEL_SELECTION_UNAVAILABLE");
12423
+ if (!parsed.success || !record$1(selection) || !Object.hasOwn(selection, "pending")) throw failure$1("COPILOT_PARENT_MODEL_SELECTION_UNAVAILABLE");
12426
12424
  const pending = selection.pending === null ? null : followSelection(selection.pending);
12427
12425
  if (pending === void 0) throw failure$1("COPILOT_PARENT_MODEL_SELECTION_UNAVAILABLE");
12428
12426
  const header = session.requestHeader();
12429
- const recorded = record(header) ? followSelection(header.config) : void 0;
12427
+ const recorded = record$1(header) ? followSelection(header.config) : void 0;
12430
12428
  const retained = pending === null && recorded?.provider === "github-copilot-preview" ? retainedAuto(projections, session) : void 0;
12431
12429
  return {
12432
12430
  id: session.id,
@@ -12452,7 +12450,7 @@ function installAutoModelRouting(ctx, dependencies) {
12452
12450
  const agents = ctx.get("agents");
12453
12451
  try {
12454
12452
  const selection = resolveParentModel(child, bindings, (id) => {
12455
- if (!record(agents) || typeof agents.get !== "function") return void 0;
12453
+ if (!record$1(agents) || typeof agents.get !== "function") return void 0;
12456
12454
  return readSubject(agents.get(id));
12457
12455
  }, followAll);
12458
12456
  followed.set(agent, {
@@ -12474,9 +12472,9 @@ function installAutoModelRouting(ctx, dependencies) {
12474
12472
  const owner = ctx.get("githubCopilotSessionAccounts");
12475
12473
  if (!owner) return;
12476
12474
  const projections = ctx.get("sessionProjections");
12477
- const state = record(projections) && typeof projections.stateOf === "function" ? projections.stateOf(agent.session, "modelSelection") : void 0;
12478
- const pending = record(state) ? state.pending : void 0;
12479
- if ((followIntent(agent)?.provider ?? (record(pending) ? pending.provider : agent.session.requestHeader()?.config.provider ?? (record(state) && pending === null ? ctx.get("agentDefaultModel")?.currentSelection()?.provider : void 0))) === "github-copilot-preview") owner.admit(agent, turn, signal);
12475
+ const state = record$1(projections) && typeof projections.stateOf === "function" ? projections.stateOf(agent.session, "modelSelection") : void 0;
12476
+ const pending = record$1(state) ? state.pending : void 0;
12477
+ if ((followIntent(agent)?.provider ?? (record$1(pending) ? pending.provider : agent.session.requestHeader()?.config.provider ?? (record$1(state) && pending === null ? ctx.get("agentDefaultModel")?.currentSelection()?.provider : void 0))) === "github-copilot-preview") owner.admit(agent, turn, signal);
12480
12478
  };
12481
12479
  const installAgent = (agent) => {
12482
12480
  if (agentDisposers.has(agent)) return;
@@ -12590,8 +12588,8 @@ function installAutoModelRouting(ctx, dependencies) {
12590
12588
  if (!virtual && pending === void 0) {
12591
12589
  routed.delete(agent);
12592
12590
  const projections = ctx.get("sessionProjections");
12593
- const selection = record(projections) && typeof projections.stateOf === "function" ? projections.stateOf(agent.session, "modelSelection") : void 0;
12594
- const fixed = record(selection) && record(selection.pending) && selection.pending.provider === resolved.provider && selection.pending.model === resolved.model;
12591
+ const selection = record$1(projections) && typeof projections.stateOf === "function" ? projections.stateOf(agent.session, "modelSelection") : void 0;
12592
+ const fixed = record$1(selection) && record$1(selection.pending) && selection.pending.provider === resolved.provider && selection.pending.model === resolved.model;
12595
12593
  if (!signal.aborted && (resolved.provider === "github-copilot-preview" || resolved.provider === "github-copilot")) {
12596
12594
  if (resolved.provider === "github-copilot-preview") dependencies.admitModel?.(agent, turn, resolved.model, signal);
12597
12595
  selections.record(agent, turn, { mode: fixed ? "manual" : "unknown" });
@@ -12612,9 +12610,9 @@ function installAutoModelRouting(ctx, dependencies) {
12612
12610
  }
12613
12611
  if (!state.recorded) {
12614
12612
  const projections = ctx.get("sessionProjections");
12615
- if (inherited === void 0 && virtual && record(projections) && typeof projections.stateOf === "function") {
12613
+ if (inherited === void 0 && virtual && record$1(projections) && typeof projections.stateOf === "function") {
12616
12614
  const selection = projections.stateOf(agent.session, "modelSelection");
12617
- if (record(selection) && selection.pending === null && agent.session.requestHeader() === void 0) Reflect.apply(agent.session.append, agent.session, ["model/selection", {
12615
+ if (record$1(selection) && selection.pending === null && agent.session.requestHeader() === void 0) Reflect.apply(agent.session.append, agent.session, ["model/selection", {
12618
12616
  provider: GITHUB_COPILOT_PREVIEW_PROVIDER_ID,
12619
12617
  model: resolved.model
12620
12618
  }]);
@@ -13521,6 +13519,7 @@ function createAccountRuntime(ctx, config, binding, exclusionTurns, replayRecove
13521
13519
  ...lifetime.guard(lease),
13522
13520
  ...hooks,
13523
13521
  responsesRequestCompression: settings?.responsesRequestCompression === true && (template.transport === void 0 || template.transport === "sse"),
13522
+ responsesOmitTemperature: settings?.responsesOmitTemperature === true,
13524
13523
  onReplayFailure(error) {
13525
13524
  if (error.dispatchEvidence !== void 0) ctx.logger.warn(`[github-copilot] ${error.dispatchEvidence}`);
13526
13525
  hooks.onReplayFailure?.(error);
@@ -13855,6 +13854,104 @@ var preview_route_default = {
13855
13854
  apply: apply$1
13856
13855
  };
13857
13856
  //#endregion
13857
+ //#region lib/types/auto-review-sampling.js
13858
+ var __rewriteRelativeImportExtension = function(path, preserveJsx) {
13859
+ if (typeof path === "string" && /^\.\.?\//.test(path)) return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
13860
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
13861
+ });
13862
+ return path;
13863
+ };
13864
+ const REVIEWER = "@deepseek-ai/dsh-experimental-auto-review";
13865
+ const CORE_VERSION = "0.2.0-rc.2";
13866
+ function record(value) {
13867
+ return value !== null && typeof value === "object";
13868
+ }
13869
+ function streamService(value) {
13870
+ return record(value) && typeof value.stream === "function";
13871
+ }
13872
+ /** Resolve the published callback, never the configured entry's display name. */
13873
+ async function isNativeReviewerContext(caller) {
13874
+ const fiber = caller.fiber;
13875
+ const entry = fiber.entry;
13876
+ if (entry === void 0 || entry.fiber !== fiber || entry.options.name !== REVIEWER || fiber.runtime === null || fiber.uid === null) return false;
13877
+ const base = entry.parent.tree.ctx.baseUrl;
13878
+ const packages = caller.get("pluginPackages");
13879
+ if (base === void 0 || packages === void 0) return false;
13880
+ const owner = packages.packageOf(REVIEWER, base);
13881
+ if (owner?.name !== REVIEWER || owner.version !== CORE_VERSION) return false;
13882
+ if (packages.packageOf(REVIEWER, import.meta.url)?.manifestPath !== owner.manifestPath) return false;
13883
+ const module = await import(__rewriteRelativeImportExtension(REVIEWER));
13884
+ return record(module) && typeof module.apply === "function" && module.apply === fiber.runtime.callback && fiber.uid !== null && entry.fiber === fiber && entry.options.name === REVIEWER;
13885
+ }
13886
+ /** Reversible service-read delegation; neither the native service nor its context is changed. */
13887
+ function installAutoReviewSampling(ctx) {
13888
+ let active = true;
13889
+ const lifecycle = new AbortController();
13890
+ const diagnosed = /* @__PURE__ */ new Set();
13891
+ const diagnose = (code) => {
13892
+ if (diagnosed.has(code)) return;
13893
+ diagnosed.add(code);
13894
+ ctx.logger.warn(`github-copilot: Auto reviewer sampling scope unavailable (${code})`);
13895
+ };
13896
+ const dispose = ctx.on("internal/get", (caller, name, _error, next) => {
13897
+ const native = next();
13898
+ if (!active || name !== "llm" || !streamService(native)) return native;
13899
+ const entry = caller.fiber.entry;
13900
+ if (entry === void 0 || entry.fiber !== caller.fiber || entry.options.name !== REVIEWER) return native;
13901
+ const runtime = native;
13902
+ const scopedStream = (options) => (async function* () {
13903
+ if (!active || options.provider !== "github-copilot-preview") {
13904
+ yield* runtime.stream(options);
13905
+ return;
13906
+ }
13907
+ let identified;
13908
+ try {
13909
+ identified = await isNativeReviewerContext(caller);
13910
+ } catch {
13911
+ diagnose("COPILOT_AUTO_REVIEW_IDENTITY_UNAVAILABLE");
13912
+ yield* runtime.stream(options);
13913
+ return;
13914
+ }
13915
+ if (!active || !identified) {
13916
+ if (active) diagnose("COPILOT_AUTO_REVIEW_IDENTITY_UNPROVEN");
13917
+ yield* runtime.stream(options);
13918
+ return;
13919
+ }
13920
+ const preview = ctx.get("githubCopilotPreview");
13921
+ if (preview === void 0) {
13922
+ diagnose("COPILOT_AUTO_REVIEW_ROUTE_UNAVAILABLE");
13923
+ yield* runtime.stream(options);
13924
+ return;
13925
+ }
13926
+ await preview.discover({ signal: options.signal });
13927
+ const route = preview.recoveryLimits(options.model, currentSearchInitiator(ctx));
13928
+ if (!active || route?.api !== "openai-responses") {
13929
+ if (active && route === void 0) diagnose("COPILOT_AUTO_REVIEW_ROUTE_UNPROVEN");
13930
+ yield* runtime.stream(options);
13931
+ return;
13932
+ }
13933
+ route.assertCurrent();
13934
+ const signal = options.signal === void 0 ? lifecycle.signal : AbortSignal.any([options.signal, lifecycle.signal]);
13935
+ const request = {
13936
+ ...options,
13937
+ temperature: void 0,
13938
+ signal
13939
+ };
13940
+ if (Object.isFrozen(options)) Object.freeze(request);
13941
+ yield* runtime.stream(request);
13942
+ })();
13943
+ return new Proxy(runtime, { get(target, key) {
13944
+ return key === "stream" ? scopedStream : Reflect.get(target, key, target);
13945
+ } });
13946
+ });
13947
+ return () => {
13948
+ active = false;
13949
+ lifecycle.abort();
13950
+ dispose();
13951
+ diagnosed.clear();
13952
+ };
13953
+ }
13954
+ //#endregion
13858
13955
  //#region lib/types/index.js
13859
13956
  /**
13860
13957
  * The inline web-search plugin: short-circuits agent-loop model calls on
@@ -13913,6 +14010,7 @@ function observeSettingsNamespace(ctx, namespace, config, hooks) {
13913
14010
  * @param config - the composition entry config, used as the settings base layer.
13914
14011
  */
13915
14012
  function apply(ctx, config) {
14013
+ ctx.effect(() => installAutoReviewSampling(ctx));
13916
14014
  ctx.plugin({ apply(scope) {
13917
14015
  new DiagnosticsController(scope);
13918
14016
  } });