dsh-github-copilot 0.4.0-alpha.75 → 0.4.0-alpha.77
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/AGENTS.md +9 -0
- package/CHANGELOG.md +12 -0
- package/README.md +10 -8
- package/README.zh.md +10 -8
- package/deployment-baseline.json +7 -2
- package/docs/automatic-model-routing.md +24 -0
- package/docs/copilot-compaction.md +6 -0
- package/lib/client.js +32 -12
- package/lib/client.js.map +1 -1
- package/lib/index.js +44 -25
- package/lib/remote.js +0 -4
- package/lib/types/agent-compaction.d.ts +4 -0
- package/lib/types/turn-selection-card.d.ts +3 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1700,7 +1700,7 @@ const usageSchema = z$1.object({
|
|
|
1700
1700
|
totalTokens: count.optional(),
|
|
1701
1701
|
reasoningTokens: count.optional()
|
|
1702
1702
|
});
|
|
1703
|
-
function record$
|
|
1703
|
+
function record$6(value) {
|
|
1704
1704
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1705
1705
|
}
|
|
1706
1706
|
function sameRoute$1(left, right) {
|
|
@@ -1719,10 +1719,10 @@ function initialContextEvidence() {
|
|
|
1719
1719
|
}
|
|
1720
1720
|
/** Read only counts and routing leaves; never message content or opaque replay. */
|
|
1721
1721
|
function foldContextEvidence(state, event) {
|
|
1722
|
-
if (!record$
|
|
1722
|
+
if (!record$6(event) || typeof event.type !== "string" || !record$6(event.data)) return state;
|
|
1723
1723
|
if (event.type === "request/header" || event.type === "model/selection") {
|
|
1724
|
-
const raw = event.type === "request/header" ? record$
|
|
1725
|
-
if (!record$
|
|
1724
|
+
const raw = event.type === "request/header" ? record$6(event.data.header) ? event.data.header.config : void 0 : event.data;
|
|
1725
|
+
if (!record$6(raw)) return {
|
|
1726
1726
|
...state,
|
|
1727
1727
|
route: null,
|
|
1728
1728
|
sample: null,
|
|
@@ -1761,7 +1761,7 @@ function foldContextEvidence(state, event) {
|
|
|
1761
1761
|
if (!copilot(state.route)) return state;
|
|
1762
1762
|
if (event.type === "assistant/message" && event.data.source !== void 0) {
|
|
1763
1763
|
const source = event.data.source;
|
|
1764
|
-
const parsed = routeSchema.safeParse(record$
|
|
1764
|
+
const parsed = routeSchema.safeParse(record$6(source) ? {
|
|
1765
1765
|
provider: source.provider,
|
|
1766
1766
|
model: source.model
|
|
1767
1767
|
} : source);
|
|
@@ -1777,7 +1777,7 @@ function foldContextEvidence(state, event) {
|
|
|
1777
1777
|
const settledUsage = usage !== void 0;
|
|
1778
1778
|
let terminal;
|
|
1779
1779
|
for (const entry of stream) {
|
|
1780
|
-
if (!record$
|
|
1780
|
+
if (!record$6(entry) || entry.type !== "chunk" || !record$6(entry.chunk)) continue;
|
|
1781
1781
|
if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
|
|
1782
1782
|
if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
|
|
1783
1783
|
}
|
|
@@ -1791,7 +1791,7 @@ function foldContextEvidence(state, event) {
|
|
|
1791
1791
|
};
|
|
1792
1792
|
const value = parsed.data;
|
|
1793
1793
|
const zero = isZeroContextUsage(value);
|
|
1794
|
-
const successful = record$
|
|
1794
|
+
const successful = record$6(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
|
|
1795
1795
|
if (zero && !successful) {
|
|
1796
1796
|
const reason = state.sample !== null || state.reason === "none" ? "failed-zero" : state.reason;
|
|
1797
1797
|
return {
|
|
@@ -1833,7 +1833,7 @@ const contextEvidenceDefinition = {
|
|
|
1833
1833
|
function installContextEvidence(ctx) {
|
|
1834
1834
|
ctx.inject(["sessionProjections"], (scope) => {
|
|
1835
1835
|
const registry = scope.get("sessionProjections");
|
|
1836
|
-
if (!record$
|
|
1836
|
+
if (!record$6(registry) || typeof registry.register !== "function") {
|
|
1837
1837
|
scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
|
|
1838
1838
|
return;
|
|
1839
1839
|
}
|
|
@@ -1847,7 +1847,7 @@ function installContextEvidence(ctx) {
|
|
|
1847
1847
|
//#endregion
|
|
1848
1848
|
//#region package.json
|
|
1849
1849
|
var name$1 = "dsh-github-copilot";
|
|
1850
|
-
var version = "0.4.0-alpha.
|
|
1850
|
+
var version = "0.4.0-alpha.77";
|
|
1851
1851
|
//#endregion
|
|
1852
1852
|
//#region lib/types/probe.js
|
|
1853
1853
|
/**
|
|
@@ -2856,7 +2856,7 @@ function buildAnthropicWireBody(request, cfg, model) {
|
|
|
2856
2856
|
}
|
|
2857
2857
|
//#endregion
|
|
2858
2858
|
//#region lib/types/responses-reasoning-text.js
|
|
2859
|
-
function record$
|
|
2859
|
+
function record$5(value) {
|
|
2860
2860
|
return typeof value === "object" && value !== null;
|
|
2861
2861
|
}
|
|
2862
2862
|
function responseIndex(value) {
|
|
@@ -2914,13 +2914,13 @@ var ResponsesReasoningText = class {
|
|
|
2914
2914
|
}
|
|
2915
2915
|
/** Only recognized public text fields are examined; no copying of the item. */
|
|
2916
2916
|
snapshot(item) {
|
|
2917
|
-
if (!record$
|
|
2917
|
+
if (!record$5(item) || item.type !== "reasoning") return "";
|
|
2918
2918
|
let delta = "";
|
|
2919
2919
|
for (const family of ["summary", "raw"]) {
|
|
2920
2920
|
const value = family === "summary" ? item.summary : item.content;
|
|
2921
2921
|
if (!Array.isArray(value)) continue;
|
|
2922
2922
|
for (const [index, part] of value.entries()) {
|
|
2923
|
-
if (!record$
|
|
2923
|
+
if (!record$5(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
|
|
2924
2924
|
delta += this.update(family, index, part.text, true);
|
|
2925
2925
|
}
|
|
2926
2926
|
}
|
|
@@ -5542,16 +5542,16 @@ async function isCopilotInputItemScopeError(response, signal) {
|
|
|
5542
5542
|
//#endregion
|
|
5543
5543
|
//#region lib/types/request-body-timeout.js
|
|
5544
5544
|
const observedMessage = "Timed out reading request body. Try again, or use a smaller request size.";
|
|
5545
|
-
function record$
|
|
5545
|
+
function record$4(value) {
|
|
5546
5546
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5547
5547
|
}
|
|
5548
5548
|
/** Verified provider evidence, not guessed capabilities, token limits or network cause. */
|
|
5549
5549
|
async function requestBodyTimeoutDiagnostic(response, body, signal) {
|
|
5550
5550
|
if (response.status !== 408 || signal?.aborted) return void 0;
|
|
5551
5551
|
const value = await readResponseErrorJson(response, signal);
|
|
5552
|
-
if (!record$
|
|
5552
|
+
if (!record$4(value)) return void 0;
|
|
5553
5553
|
const error = Object.hasOwn(value, "error") ? value.error : value;
|
|
5554
|
-
if (!record$
|
|
5554
|
+
if (!record$4(error) || error.code !== "user_request_timeout" || error.message !== observedMessage || value.code !== void 0 && value.code !== error.code || value.message !== void 0 && value.message !== error.message) return void 0;
|
|
5555
5555
|
return `COPILOT_REQUEST_BODY_TIMEOUT: Copilot returned HTTP 408 / user_request_timeout while reading the request body; this is not context-window overflow. ${body === void 0 ? "Request body size unavailable." : `Request body: ${Buffer.byteLength(body, "utf8")} UTF-8 bytes (not context tokens).`} Native retry policy is unchanged. If retries exhaust, explicitly compact the conversation or reduce attachments/tool output before retrying; also check network/proxy health and GitHub service status. A larger client timeout does not change this server timeout. No history was trimmed or model switched.`;
|
|
5556
5556
|
}
|
|
5557
5557
|
//#endregion
|
|
@@ -5888,7 +5888,7 @@ var Budget = class {
|
|
|
5888
5888
|
if (this.consumed > ACCOUNT_MODEL_CATALOG_LIMITS.maxBytes) fail("CATALOG_TOO_LARGE", true);
|
|
5889
5889
|
}
|
|
5890
5890
|
};
|
|
5891
|
-
function record$
|
|
5891
|
+
function record$3(value, code) {
|
|
5892
5892
|
if (typeof value !== "object" || value === null || Array.isArray(value)) fail(code);
|
|
5893
5893
|
return value;
|
|
5894
5894
|
}
|
|
@@ -5938,11 +5938,11 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
5938
5938
|
if (options.availableModelIds?.has(id) !== true) fail("MISSING_POLICY");
|
|
5939
5939
|
policySource = "account-available-id";
|
|
5940
5940
|
} else {
|
|
5941
|
-
if (text(field(record$
|
|
5941
|
+
if (text(field(record$3(rawPolicy, "INVALID_POLICY"), "state", budget), 64, "INVALID_POLICY", budget) !== "enabled") fail("POLICY_NOT_ENABLED");
|
|
5942
5942
|
policySource = "server-enabled";
|
|
5943
5943
|
}
|
|
5944
|
-
const capabilities = record$
|
|
5945
|
-
const supports = record$
|
|
5944
|
+
const capabilities = record$3(field(raw, "capabilities", budget), "INVALID_CAPABILITIES");
|
|
5945
|
+
const supports = record$3(field(capabilities, "supports", budget), "INVALID_SUPPORTS");
|
|
5946
5946
|
const streaming = field(supports, "streaming", budget);
|
|
5947
5947
|
if (streaming === false) fail("STREAMING_UNSUPPORTED");
|
|
5948
5948
|
if (streaming !== true) fail("INVALID_SUPPORTS");
|
|
@@ -5963,7 +5963,7 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
5963
5963
|
if (selected === void 0) fail(unsupportedEndpointCount === 0 && endpoints.includes("ws:/responses") ? "WEBSOCKET_ONLY" : "UNSUPPORTED_ENDPOINTS");
|
|
5964
5964
|
const rawLimits = field(capabilities, "limits", budget);
|
|
5965
5965
|
if (rawLimits === void 0) fail("MISSING_LIMITS");
|
|
5966
|
-
const limits = record$
|
|
5966
|
+
const limits = record$3(rawLimits, "INVALID_LIMITS");
|
|
5967
5967
|
const maxContext = optionalPositive(limits, "max_context_window_tokens", "INVALID_LIMITS", budget);
|
|
5968
5968
|
const maxInputTokens = optionalPositive(limits, "max_prompt_tokens", "INVALID_LIMITS", budget);
|
|
5969
5969
|
if (maxContext === void 0 && maxInputTokens === void 0) fail("MISSING_CONTEXT_LIMIT");
|
|
@@ -5981,7 +5981,7 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
5981
5981
|
if (vision === true) {
|
|
5982
5982
|
const rawVisionLimits = field(limits, "vision", budget);
|
|
5983
5983
|
if (rawVisionLimits !== void 0) {
|
|
5984
|
-
const rawMediaTypes = field(record$
|
|
5984
|
+
const rawMediaTypes = field(record$3(rawVisionLimits, "INVALID_VISION_LIMITS"), "supported_media_types", budget);
|
|
5985
5985
|
if (rawMediaTypes !== void 0) {
|
|
5986
5986
|
const mediaTypes = stringList(rawMediaTypes, ACCOUNT_MODEL_CATALOG_LIMITS.maxMediaTypes, 128, "INVALID_VISION_LIMITS", budget);
|
|
5987
5987
|
const mime = /^[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*\/[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*$/iu;
|
|
@@ -6041,7 +6041,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
|
|
|
6041
6041
|
fail("INVALID_JSON", true);
|
|
6042
6042
|
}
|
|
6043
6043
|
}
|
|
6044
|
-
const data = field(record$
|
|
6044
|
+
const data = field(record$3(raw, "INVALID_CATALOG"), "data", budget);
|
|
6045
6045
|
if (!Array.isArray(data)) fail("INVALID_CATALOG");
|
|
6046
6046
|
const count = field(data, "length", budget);
|
|
6047
6047
|
if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0) fail("INVALID_CATALOG");
|
|
@@ -6064,7 +6064,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
|
|
|
6064
6064
|
for (let index = 0; index < count; index++) {
|
|
6065
6065
|
let id;
|
|
6066
6066
|
try {
|
|
6067
|
-
const candidate = record$
|
|
6067
|
+
const candidate = record$3(field(data, String(index), budget), "INVALID_MODEL");
|
|
6068
6068
|
const candidateId = text(field(candidate, "id", budget), ACCOUNT_MODEL_CATALOG_LIMITS.maxIdLength, "INVALID_ID", budget);
|
|
6069
6069
|
if (!identifier.test(candidateId)) fail("INVALID_ID");
|
|
6070
6070
|
id = candidateId;
|
|
@@ -6495,6 +6495,25 @@ function createAccountModelSource(dependencies) {
|
|
|
6495
6495
|
return new AccountModelSource(dependencies);
|
|
6496
6496
|
}
|
|
6497
6497
|
//#endregion
|
|
6498
|
+
//#region lib/types/agent-compaction.js
|
|
6499
|
+
function record$2(value) {
|
|
6500
|
+
return typeof value === "object" && value !== null;
|
|
6501
|
+
}
|
|
6502
|
+
/** Resolve the owning preset's service without reaching into Core's service registry. */
|
|
6503
|
+
function agentCompaction(agent) {
|
|
6504
|
+
if (typeof agent.ctx?.get !== "function") throw new LlmError("COPILOT_COMPACTION_AGENT_CONTEXT_UNAVAILABLE", "INVALID_REQUEST");
|
|
6505
|
+
const presets = agent.ctx.get("agentPresets");
|
|
6506
|
+
if (presets !== void 0) {
|
|
6507
|
+
if (!record$2(presets) || typeof presets.composedPreset !== "function" || typeof presets.serviceFor !== "function") throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
|
|
6508
|
+
const preset = presets.composedPreset(agent.ctx);
|
|
6509
|
+
if (preset !== void 0) {
|
|
6510
|
+
if (typeof preset !== "string" || preset.trim().length === 0) throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
|
|
6511
|
+
return presets.serviceFor(agent, "compaction");
|
|
6512
|
+
}
|
|
6513
|
+
}
|
|
6514
|
+
return agent.ctx.get("compaction");
|
|
6515
|
+
}
|
|
6516
|
+
//#endregion
|
|
6498
6517
|
//#region lib/types/compaction-pressure.js
|
|
6499
6518
|
function object$1(value) {
|
|
6500
6519
|
return typeof value === "object" && value !== null ? value : void 0;
|
|
@@ -6541,7 +6560,7 @@ function installCopilotCompactionPressure(ctx, callbacks) {
|
|
|
6541
6560
|
if (header === void 0 || !callConfigEquals(header.config, request)) return void 0;
|
|
6542
6561
|
const budget = callbacks.resolve(request);
|
|
6543
6562
|
if (budget === void 0 || !positiveInteger(budget.inputBudgetTokens)) return void 0;
|
|
6544
|
-
const compaction = object$1(
|
|
6563
|
+
const compaction = object$1(agentCompaction(owner));
|
|
6545
6564
|
const config = object$1(compaction?.config);
|
|
6546
6565
|
if (config?.auto === false) return void 0;
|
|
6547
6566
|
if (config?.auto !== true || typeof compaction?.compactIfNeeded !== "function") {
|
|
@@ -7022,7 +7041,7 @@ function buildRoutingContext(ctx, agent, turn, messages, budgetPolicyConfig) {
|
|
|
7022
7041
|
return value;
|
|
7023
7042
|
};
|
|
7024
7043
|
const sessionId = typeof agent.session?.id === "string" ? agent.session.id : void 0;
|
|
7025
|
-
const compaction =
|
|
7044
|
+
const compaction = agentCompaction(agent);
|
|
7026
7045
|
const compactionConfig = record(compaction) && record(compaction.config) ? compaction.config : void 0;
|
|
7027
7046
|
const compactionAvailable = compaction !== void 0 && compactionConfig?.auto !== false && (typeof compactionConfig?.maxOverflowRetries !== "number" || compactionConfig.maxOverflowRetries > 0);
|
|
7028
7047
|
const hasCompactionSummary = messages.some((m) => record(m) && (record(m.source) && (m.source.kind === "compaction" || m.source.kind === "compact-checkpoint") || typeof m.surfaceOp === "object"));
|
package/lib/remote.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import type { TurnSelection } from './turn-selection.ts';
|
|
3
|
-
export declare function TurnSelectionCard({ selection, locale, incomplete }: {
|
|
3
|
+
export declare function TurnSelectionCard({ selection, locale, incomplete, readState, retry }: {
|
|
4
4
|
selection: TurnSelection;
|
|
5
5
|
locale?: string;
|
|
6
6
|
incomplete?: boolean;
|
|
7
|
+
readState?: 'loading' | 'ready' | 'failed';
|
|
8
|
+
retry?: () => void;
|
|
7
9
|
}): ReactElement;
|
|
8
10
|
//# sourceMappingURL=turn-selection-card.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-github-copilot",
|
|
3
3
|
"description": "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
|
|
4
|
-
"version": "0.4.0-alpha.
|
|
4
|
+
"version": "0.4.0-alpha.77",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"registry": "https://registry.npmjs.org/",
|