dsh-github-copilot 0.4.0-alpha.88 → 0.4.0-alpha.92

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
@@ -1684,7 +1684,7 @@ const usageSchema = z$1.object({
1684
1684
  totalTokens: count.optional(),
1685
1685
  reasoningTokens: count.optional()
1686
1686
  });
1687
- function record$7(value) {
1687
+ function record$8(value) {
1688
1688
  return typeof value === "object" && value !== null && !Array.isArray(value);
1689
1689
  }
1690
1690
  function sameRoute$1(left, right) {
@@ -1703,10 +1703,10 @@ function initialContextEvidence() {
1703
1703
  }
1704
1704
  /** Read only counts and routing leaves; never message content or opaque replay. */
1705
1705
  function foldContextEvidence(state, event) {
1706
- if (!record$7(event) || typeof event.type !== "string" || !record$7(event.data)) return state;
1706
+ if (!record$8(event) || typeof event.type !== "string" || !record$8(event.data)) return state;
1707
1707
  if (event.type === "request/header" || event.type === "model/selection") {
1708
- const raw = event.type === "request/header" ? record$7(event.data.header) ? event.data.header.config : void 0 : event.data;
1709
- if (!record$7(raw)) return {
1708
+ const raw = event.type === "request/header" ? record$8(event.data.header) ? event.data.header.config : void 0 : event.data;
1709
+ if (!record$8(raw)) return {
1710
1710
  ...state,
1711
1711
  route: null,
1712
1712
  sample: null,
@@ -1745,7 +1745,7 @@ function foldContextEvidence(state, event) {
1745
1745
  if (!copilot(state.route)) return state;
1746
1746
  if (event.type === "assistant/message" && event.data.source !== void 0) {
1747
1747
  const source = event.data.source;
1748
- const parsed = routeSchema.safeParse(record$7(source) ? {
1748
+ const parsed = routeSchema.safeParse(record$8(source) ? {
1749
1749
  provider: source.provider,
1750
1750
  model: source.model
1751
1751
  } : source);
@@ -1761,7 +1761,7 @@ function foldContextEvidence(state, event) {
1761
1761
  const settledUsage = usage !== void 0;
1762
1762
  let terminal;
1763
1763
  for (const entry of stream) {
1764
- if (!record$7(entry) || entry.type !== "chunk" || !record$7(entry.chunk)) continue;
1764
+ if (!record$8(entry) || entry.type !== "chunk" || !record$8(entry.chunk)) continue;
1765
1765
  if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
1766
1766
  if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
1767
1767
  }
@@ -1775,7 +1775,7 @@ function foldContextEvidence(state, event) {
1775
1775
  };
1776
1776
  const value = parsed.data;
1777
1777
  const zero = isZeroContextUsage(value);
1778
- const successful = record$7(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
1778
+ const successful = record$8(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
1779
1779
  if (zero && !successful) {
1780
1780
  const reason = state.sample !== null || state.reason === "none" ? "failed-zero" : state.reason;
1781
1781
  return {
@@ -1817,7 +1817,7 @@ const contextEvidenceDefinition = {
1817
1817
  function installContextEvidence(ctx) {
1818
1818
  ctx.inject(["sessionProjections"], (scope) => {
1819
1819
  const registry = scope.get("sessionProjections");
1820
- if (!record$7(registry) || typeof registry.register !== "function") {
1820
+ if (!record$8(registry) || typeof registry.register !== "function") {
1821
1821
  scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
1822
1822
  return;
1823
1823
  }
@@ -1831,7 +1831,7 @@ function installContextEvidence(ctx) {
1831
1831
  //#endregion
1832
1832
  //#region package.json
1833
1833
  var name$1 = "dsh-github-copilot";
1834
- var version = "0.4.0-alpha.88";
1834
+ var version = "0.4.0-alpha.92";
1835
1835
  //#endregion
1836
1836
  //#region lib/types/probe.js
1837
1837
  /**
@@ -2843,7 +2843,7 @@ function buildAnthropicWireBody(request, cfg, model) {
2843
2843
  }
2844
2844
  //#endregion
2845
2845
  //#region lib/types/responses-reasoning-text.js
2846
- function record$6(value) {
2846
+ function record$7(value) {
2847
2847
  return typeof value === "object" && value !== null;
2848
2848
  }
2849
2849
  function responseIndex(value) {
@@ -2901,13 +2901,13 @@ var ResponsesReasoningText = class {
2901
2901
  }
2902
2902
  /** Only recognized public text fields are examined; no copying of the item. */
2903
2903
  snapshot(item) {
2904
- if (!record$6(item) || item.type !== "reasoning") return "";
2904
+ if (!record$7(item) || item.type !== "reasoning") return "";
2905
2905
  let delta = "";
2906
2906
  for (const family of ["summary", "raw"]) {
2907
2907
  const value = family === "summary" ? item.summary : item.content;
2908
2908
  if (!Array.isArray(value)) continue;
2909
2909
  for (const [index, part] of value.entries()) {
2910
- if (!record$6(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
2910
+ if (!record$7(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
2911
2911
  delta += this.update(family, index, part.text, true);
2912
2912
  }
2913
2913
  }
@@ -5716,16 +5716,16 @@ function requestBodyEvidence(body, protocol) {
5716
5716
  //#endregion
5717
5717
  //#region lib/types/request-body-timeout.js
5718
5718
  const observedMessage = "Timed out reading request body. Try again, or use a smaller request size.";
5719
- function record$5(value) {
5719
+ function record$6(value) {
5720
5720
  return typeof value === "object" && value !== null && !Array.isArray(value);
5721
5721
  }
5722
5722
  /** Verified provider evidence, not guessed capabilities, token limits or network cause. */
5723
5723
  async function requestBodyTimeoutDiagnostic(response, body, signal, dispatch) {
5724
5724
  if (response.status !== 408 || signal?.aborted) return void 0;
5725
5725
  const value = await readResponseErrorJson(response, signal);
5726
- if (signal?.aborted || !record$5(value)) return void 0;
5726
+ if (signal?.aborted || !record$6(value)) return void 0;
5727
5727
  const error = Object.hasOwn(value, "error") ? value.error : value;
5728
- if (!record$5(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;
5728
+ if (!record$6(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;
5729
5729
  const size = body === void 0 ? "Request body size unavailable." : `Request body: ${Buffer.byteLength(body, "utf8")} UTF-8 bytes (not context tokens).`;
5730
5730
  const composition = formatRequestBodyEvidence(dispatch === void 0 ? { state: "unavailable" } : requestBodyEvidence(body, dispatch.protocol), dispatch?.responseHeadersMs);
5731
5731
  return `${REQUEST_BODY_TIMEOUT_MARKER} ${size} ${composition} Native retry policy is unchanged. If retries exhaust, use these numbers to choose an explicit attachment/image-offload budget change or native compaction for compressible history; tool definitions and opaque replay may remain. Also check network/proxy health and GitHub service status. Composition alone does not establish a cause or supplier size limit. A larger client timeout does not change this server timeout. No history was trimmed or model switched.`;
@@ -6199,7 +6199,7 @@ var Budget = class {
6199
6199
  if (this.consumed > ACCOUNT_MODEL_CATALOG_LIMITS.maxBytes) fail("CATALOG_TOO_LARGE", true);
6200
6200
  }
6201
6201
  };
6202
- function record$4(value, code) {
6202
+ function record$5(value, code) {
6203
6203
  if (typeof value !== "object" || value === null || Array.isArray(value)) fail(code);
6204
6204
  return value;
6205
6205
  }
@@ -6218,13 +6218,13 @@ function text$1(value, maxLength, code, budget) {
6218
6218
  budget.charge(encoder.encode(value).byteLength);
6219
6219
  return value;
6220
6220
  }
6221
- function positive(value, code) {
6221
+ function positive$1(value, code) {
6222
6222
  if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) fail(code);
6223
6223
  return value;
6224
6224
  }
6225
6225
  function optionalPositive(parent, key, code, budget) {
6226
6226
  const descriptor = dataProperty(parent, key, budget);
6227
- return descriptor === void 0 ? void 0 : positive(descriptor.value, code);
6227
+ return descriptor === void 0 ? void 0 : positive$1(descriptor.value, code);
6228
6228
  }
6229
6229
  function stringList(value, maxItems, maxLength, code, budget) {
6230
6230
  if (!Array.isArray(value)) fail(code);
@@ -6252,11 +6252,11 @@ function normalizeModel(raw, id, options, budget) {
6252
6252
  if (options.availableModelIds?.has(id) !== true) fail("MISSING_POLICY");
6253
6253
  policySource = "account-available-id";
6254
6254
  } else {
6255
- if (text$1(field(record$4(rawPolicy, "INVALID_POLICY"), "state", budget), 64, "INVALID_POLICY", budget) !== "enabled") fail("POLICY_NOT_ENABLED");
6255
+ if (text$1(field(record$5(rawPolicy, "INVALID_POLICY"), "state", budget), 64, "INVALID_POLICY", budget) !== "enabled") fail("POLICY_NOT_ENABLED");
6256
6256
  policySource = "server-enabled";
6257
6257
  }
6258
- const capabilities = record$4(field(raw, "capabilities", budget), "INVALID_CAPABILITIES");
6259
- const supports = record$4(field(capabilities, "supports", budget), "INVALID_SUPPORTS");
6258
+ const capabilities = record$5(field(raw, "capabilities", budget), "INVALID_CAPABILITIES");
6259
+ const supports = record$5(field(capabilities, "supports", budget), "INVALID_SUPPORTS");
6260
6260
  const streaming = field(supports, "streaming", budget);
6261
6261
  if (streaming === false) fail("STREAMING_UNSUPPORTED");
6262
6262
  if (streaming !== true) fail("INVALID_SUPPORTS");
@@ -6277,7 +6277,7 @@ function normalizeModel(raw, id, options, budget) {
6277
6277
  if (selected === void 0) fail(unsupportedEndpointCount === 0 && endpoints.includes("ws:/responses") ? "WEBSOCKET_ONLY" : "UNSUPPORTED_ENDPOINTS");
6278
6278
  const rawLimits = field(capabilities, "limits", budget);
6279
6279
  if (rawLimits === void 0) fail("MISSING_LIMITS");
6280
- const limits = record$4(rawLimits, "INVALID_LIMITS");
6280
+ const limits = record$5(rawLimits, "INVALID_LIMITS");
6281
6281
  const maxContext = optionalPositive(limits, "max_context_window_tokens", "INVALID_LIMITS", budget);
6282
6282
  const maxInputTokens = optionalPositive(limits, "max_prompt_tokens", "INVALID_LIMITS", budget);
6283
6283
  if (maxContext === void 0 && maxInputTokens === void 0) fail("MISSING_CONTEXT_LIMIT");
@@ -6295,7 +6295,7 @@ function normalizeModel(raw, id, options, budget) {
6295
6295
  if (vision === true) {
6296
6296
  const rawVisionLimits = field(limits, "vision", budget);
6297
6297
  if (rawVisionLimits !== void 0) {
6298
- const rawMediaTypes = field(record$4(rawVisionLimits, "INVALID_VISION_LIMITS"), "supported_media_types", budget);
6298
+ const rawMediaTypes = field(record$5(rawVisionLimits, "INVALID_VISION_LIMITS"), "supported_media_types", budget);
6299
6299
  if (rawMediaTypes !== void 0) {
6300
6300
  const mediaTypes = stringList(rawMediaTypes, ACCOUNT_MODEL_CATALOG_LIMITS.maxMediaTypes, 128, "INVALID_VISION_LIMITS", budget);
6301
6301
  const mime = /^[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*\/[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*$/iu;
@@ -6357,7 +6357,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
6357
6357
  fail("INVALID_JSON", true);
6358
6358
  }
6359
6359
  }
6360
- const data = field(record$4(raw, "INVALID_CATALOG"), "data", budget);
6360
+ const data = field(record$5(raw, "INVALID_CATALOG"), "data", budget);
6361
6361
  if (!Array.isArray(data)) fail("INVALID_CATALOG");
6362
6362
  const count = field(data, "length", budget);
6363
6363
  if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0) fail("INVALID_CATALOG");
@@ -6380,7 +6380,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
6380
6380
  for (let index = 0; index < count; index++) {
6381
6381
  let id;
6382
6382
  try {
6383
- const candidate = record$4(field(data, String(index), budget), "INVALID_MODEL");
6383
+ const candidate = record$5(field(data, String(index), budget), "INVALID_MODEL");
6384
6384
  const candidateId = text$1(field(candidate, "id", budget), ACCOUNT_MODEL_CATALOG_LIMITS.maxIdLength, "INVALID_ID", budget);
6385
6385
  if (!identifier.test(candidateId)) fail("INVALID_ID");
6386
6386
  id = candidateId;
@@ -6812,7 +6812,7 @@ function createAccountModelSource(dependencies) {
6812
6812
  }
6813
6813
  //#endregion
6814
6814
  //#region lib/types/agent-compaction.js
6815
- function record$3(value) {
6815
+ function record$4(value) {
6816
6816
  return typeof value === "object" && value !== null;
6817
6817
  }
6818
6818
  /** Resolve the owning preset's service without reaching into Core's service registry. */
@@ -6820,7 +6820,7 @@ function agentCompaction(agent) {
6820
6820
  if (typeof agent.ctx?.get !== "function") throw new LlmError("COPILOT_COMPACTION_AGENT_CONTEXT_UNAVAILABLE", "INVALID_REQUEST");
6821
6821
  const presets = agent.ctx.get("agentPresets");
6822
6822
  if (presets !== void 0) {
6823
- if (!record$3(presets) || typeof presets.composedPreset !== "function" || typeof presets.serviceFor !== "function") throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
6823
+ if (!record$4(presets) || typeof presets.composedPreset !== "function" || typeof presets.serviceFor !== "function") throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
6824
6824
  const preset = presets.composedPreset(agent.ctx);
6825
6825
  if (preset !== void 0) {
6826
6826
  if (typeof preset !== "string" || preset.trim().length === 0) throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
@@ -6942,6 +6942,92 @@ function installCopilotCompactionPressure(ctx, callbacks) {
6942
6942
  }, { prepend: true });
6943
6943
  }
6944
6944
  //#endregion
6945
+ //#region lib/types/pre-step-pressure.js
6946
+ function record$3(value) {
6947
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6948
+ }
6949
+ function positive(value) {
6950
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
6951
+ }
6952
+ function isEngine(value) {
6953
+ return record$3(value) && record$3(value.config) && typeof value.compactIfNeeded === "function";
6954
+ }
6955
+ /**
6956
+ * Prevent a continuing, unchanged route's known pressure from becoming an
6957
+ * unsampled model attempt. Final converted-request admission stays independent.
6958
+ */
6959
+ function installCopilotPreStepPressure(ctx, callbacks) {
6960
+ let warned = false;
6961
+ const unavailable = () => {
6962
+ if (warned) return;
6963
+ warned = true;
6964
+ ctx.logger.warn("COPILOT_PRE_STEP_PRESSURE_UNAVAILABLE: pre-step evidence is unavailable; retaining final request admission.");
6965
+ };
6966
+ return ctx.on("agent/pre-step", async ({ agent, step, signal }, next) => {
6967
+ const decision = await next();
6968
+ if (decision.kind !== "enter" || signal.aborted || step <= 1 || decision.messages.some((message) => message.source?.kind === "model-selection")) return decision;
6969
+ let engine;
6970
+ try {
6971
+ const header = agent.session.requestHeader();
6972
+ if (header?.config.provider !== "github-copilot-preview" || !isPluginPreviewProvider(ctx, header.config.provider)) return decision;
6973
+ const projections = ctx.get("sessionProjections");
6974
+ if (!record$3(projections) || typeof projections.stateOf !== "function") {
6975
+ unavailable();
6976
+ return decision;
6977
+ }
6978
+ const selection = projections.stateOf(agent.session, "modelSelection");
6979
+ if (!record$3(selection) || !Object.hasOwn(selection, "pending")) {
6980
+ unavailable();
6981
+ return decision;
6982
+ }
6983
+ if (selection.pending !== null) return decision;
6984
+ const budget = callbacks.resolve({
6985
+ ...header.config,
6986
+ messages: [],
6987
+ sessionId: agent.session.id
6988
+ });
6989
+ if (budget === void 0 || !positive(budget.inputBudgetTokens)) return decision;
6990
+ const candidate = agentCompaction(agent);
6991
+ if (!isEngine(candidate)) {
6992
+ unavailable();
6993
+ return decision;
6994
+ }
6995
+ const config = candidate.config;
6996
+ if (config.auto === false) return decision;
6997
+ if (config.auto !== true) {
6998
+ unavailable();
6999
+ return decision;
7000
+ }
7001
+ const policy = Array.isArray(config.modelPolicies) ? config.modelPolicies.find((value) => record$3(value) && value.provider === header.config.provider && value.model === header.config.model) : void 0;
7002
+ const retries = record$3(policy) ? policy.maxOverflowRetries ?? config.maxOverflowRetries : config.maxOverflowRetries;
7003
+ if (retries === 0) return decision;
7004
+ if (!positive(retries)) {
7005
+ unavailable();
7006
+ return decision;
7007
+ }
7008
+ const meter = ctx.get("tokenMeter");
7009
+ if (!record$3(meter) || typeof meter.measure !== "function") {
7010
+ unavailable();
7011
+ return decision;
7012
+ }
7013
+ const measured = meter.measure(agent.session);
7014
+ if (!record$3(measured) || typeof measured.totalTokens !== "number" || !Number.isSafeInteger(measured.totalTokens) || measured.totalTokens < 0) {
7015
+ unavailable();
7016
+ return decision;
7017
+ }
7018
+ if (measured.totalTokens <= budget.inputBudgetTokens) return decision;
7019
+ engine = candidate;
7020
+ } catch {
7021
+ unavailable();
7022
+ return decision;
7023
+ }
7024
+ signal.throwIfAborted();
7025
+ await engine.compactIfNeeded(agent, "context-overflow", signal);
7026
+ signal.throwIfAborted();
7027
+ return decision;
7028
+ }, { prepend: true });
7029
+ }
7030
+ //#endregion
6945
7031
  //#region lib/types/auto-assessment-evidence.js
6946
7032
  const milliseconds = z$1.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
6947
7033
  const SemanticAssessmentEvidenceSchema = z$1.object({
@@ -8979,7 +9065,7 @@ function apply$1(ctx, config = {}) {
8979
9065
  publishedDirectory = "";
8980
9066
  registration.replace([GITHUB_COPILOT_PREVIEW_PROVIDER_ID]);
8981
9067
  });
8982
- installCopilotCompactionPressure(ctx, { resolve(request) {
9068
+ const pressureCallbacks = { resolve(request) {
8983
9069
  const snapshot = source.readSnapshot();
8984
9070
  if (snapshot === void 0 || proofFor(snapshot) === void 0) return void 0;
8985
9071
  if (excludedModels().has(request.model)) return void 0;
@@ -8987,7 +9073,9 @@ function apply$1(ctx, config = {}) {
8987
9073
  if (descriptor === void 0) return void 0;
8988
9074
  const result = calculateRequestBudget(descriptor, request.maxTokens, resolveRequestBudgetPolicy(budgetSettings()));
8989
9075
  return result.ok ? { inputBudgetTokens: result.budget.pressureInputLimit } : void 0;
8990
- } });
9076
+ } };
9077
+ installCopilotPreStepPressure(ctx, pressureCallbacks);
9078
+ installCopilotCompactionPressure(ctx, pressureCallbacks);
8991
9079
  notify = () => {
8992
9080
  const view = getView();
8993
9081
  const directory = JSON.stringify({
@@ -0,0 +1,8 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { CopilotCompactionPressureCallbacks } from './compaction-pressure.ts';
3
+ /**
4
+ * Prevent a continuing, unchanged route's known pressure from becoming an
5
+ * unsampled model attempt. Final converted-request admission stays independent.
6
+ */
7
+ export declare function installCopilotPreStepPressure(ctx: Context, callbacks: CopilotCompactionPressureCallbacks): () => void;
8
+ //# sourceMappingURL=pre-step-pressure.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-github-copilot",
3
3
  "description": "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
4
- "version": "0.4.0-alpha.88",
4
+ "version": "0.4.0-alpha.92",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/",