dsh-github-copilot 0.4.0-alpha.129 → 0.4.0-alpha.132
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 +3 -1
- package/CHANGELOG.md +17 -0
- package/README.md +37 -45
- package/README.zh.md +33 -40
- package/deployment-baseline.json +16 -1
- package/docs/images/copilot-accounts-credits.png +0 -0
- package/docs/images/copilot-accounts.png +0 -0
- package/docs/images/copilot-current-provenance.json +36 -0
- package/docs/images/copilot-model-preferences.png +0 -0
- package/docs/images/copilot-search-routing.png +0 -0
- package/docs/model-compatibility-acceptance.md +2 -0
- package/docs/official-first-020-rc2.md +1 -0
- package/docs/plugin-diagnostics.md +64 -0
- package/docs/session-search-routing.md +1 -1
- package/docs/single-route-migration.md +5 -4
- package/lib/client.js +1 -1
- package/lib/diagnostics-analysis-io.js +78 -0
- package/lib/diagnostics-analysis.js +425 -0
- package/lib/diagnostics-types-FVf6zjob.js +182 -0
- package/lib/index.js +10 -2
- package/lib/manual-compaction-recovery.js +2 -1
- package/lib/request-budget-DLY_aRq0.js +87 -0
- package/lib/types/account-model-catalog.d.ts +7 -0
- package/lib/types/diagnostics-analysis-io.d.ts +23 -0
- package/lib/types/diagnostics-analysis.d.ts +295 -0
- package/lib/types/preview-provider.d.ts +1 -0
- package/package.json +3 -1
- package/scripts/analyze-diagnostics.mjs +91 -0
- package/lib/request-budget-Cui2hCi1.js +0 -268
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region lib/types/diagnostics-types.js
|
|
3
|
+
const DIAGNOSTICS_OPERATIONS = [
|
|
4
|
+
"account-global-switch",
|
|
5
|
+
"account-session-select",
|
|
6
|
+
"account-session-inherit",
|
|
7
|
+
"identity-read",
|
|
8
|
+
"identity-flight",
|
|
9
|
+
"compaction",
|
|
10
|
+
"compaction-summary",
|
|
11
|
+
"collection"
|
|
12
|
+
];
|
|
13
|
+
const DIAGNOSTICS_STAGES = [
|
|
14
|
+
"admitted",
|
|
15
|
+
"rpc-invoked",
|
|
16
|
+
"host-received",
|
|
17
|
+
"identity-validation",
|
|
18
|
+
"model-validation",
|
|
19
|
+
"cas",
|
|
20
|
+
"readback",
|
|
21
|
+
"response-received",
|
|
22
|
+
"decoded",
|
|
23
|
+
"client-settled",
|
|
24
|
+
"summary-attempt",
|
|
25
|
+
"checkpoint-committed",
|
|
26
|
+
"ended",
|
|
27
|
+
"cache-hit",
|
|
28
|
+
"joined-flight",
|
|
29
|
+
"cooldown",
|
|
30
|
+
"dispatched"
|
|
31
|
+
];
|
|
32
|
+
const DIAGNOSTICS_METRICS = [
|
|
33
|
+
"started",
|
|
34
|
+
"stage",
|
|
35
|
+
"success",
|
|
36
|
+
"no-op",
|
|
37
|
+
"cancelled",
|
|
38
|
+
"policy-rejected",
|
|
39
|
+
"revoked",
|
|
40
|
+
"environment-fault",
|
|
41
|
+
"failed",
|
|
42
|
+
"unknown",
|
|
43
|
+
"interrupted",
|
|
44
|
+
"dropped",
|
|
45
|
+
"paused",
|
|
46
|
+
"expired",
|
|
47
|
+
"clock-discontinuity",
|
|
48
|
+
"pending-sample"
|
|
49
|
+
];
|
|
50
|
+
const DIAGNOSTICS_REASONS = [
|
|
51
|
+
"none",
|
|
52
|
+
"unknown",
|
|
53
|
+
"rpc-unavailable",
|
|
54
|
+
"decode-invalid",
|
|
55
|
+
"COPILOT_ACCOUNTS_BUSY",
|
|
56
|
+
"COPILOT_ACCOUNTS_CONFLICT",
|
|
57
|
+
"COPILOT_ACCOUNTS_CHANGED",
|
|
58
|
+
"COPILOT_ACCOUNTS_COMMIT_UNCERTAIN",
|
|
59
|
+
"COPILOT_ACCOUNTS_IDENTITY_TIMEOUT",
|
|
60
|
+
"COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE",
|
|
61
|
+
"COPILOT_ACCOUNTS_MODELS_FAILED",
|
|
62
|
+
"COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE",
|
|
63
|
+
"COPILOT_ACCOUNTS_IDENTITY_TLS",
|
|
64
|
+
"COPILOT_ACCOUNTS_IDENTITY_NETWORK",
|
|
65
|
+
"COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED",
|
|
66
|
+
"COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED",
|
|
67
|
+
"COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR",
|
|
68
|
+
"COPILOT_ACCOUNTS_IDENTITY_INVALID",
|
|
69
|
+
"COPILOT_SESSION_ACCOUNTS_UNAVAILABLE",
|
|
70
|
+
"COPILOT_SESSION_ACCOUNTS_SETTINGS_UNAVAILABLE",
|
|
71
|
+
"COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN",
|
|
72
|
+
"COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH",
|
|
73
|
+
"CONTEXT_WINDOW_EXCEEDED",
|
|
74
|
+
"COPILOT_MANUAL_RECOVERY_FIXED_PREFIX",
|
|
75
|
+
"COPILOT_MANUAL_RECOVERY_INDIVISIBLE",
|
|
76
|
+
"COPILOT_MANUAL_RECOVERY_CALL_LIMIT",
|
|
77
|
+
"COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY",
|
|
78
|
+
"COPILOT_MANUAL_RECOVERY_UNBALANCED"
|
|
79
|
+
];
|
|
80
|
+
const DIAGNOSTICS_MAX_ROWS = 4096;
|
|
81
|
+
const DIAGNOSTICS_MAX_BYTES = 2097152;
|
|
82
|
+
const DIAGNOSTICS_RETENTION_MS = 12096e5;
|
|
83
|
+
const integer = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
84
|
+
const version = z.string().max(64).regex(/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/);
|
|
85
|
+
const DiagnosticsRowSchema = z.object({
|
|
86
|
+
hour: integer.multipleOf(36e5),
|
|
87
|
+
version,
|
|
88
|
+
layer: z.enum(["client", "host"]),
|
|
89
|
+
operation: z.enum(DIAGNOSTICS_OPERATIONS),
|
|
90
|
+
stage: z.enum(DIAGNOSTICS_STAGES),
|
|
91
|
+
metric: z.enum(DIAGNOSTICS_METRICS),
|
|
92
|
+
reason: z.enum(DIAGNOSTICS_REASONS),
|
|
93
|
+
bucket: z.number().int().min(0).max(7),
|
|
94
|
+
count: integer.min(1)
|
|
95
|
+
}).strict();
|
|
96
|
+
const DiagnosticsPendingSchema = z.object({
|
|
97
|
+
version,
|
|
98
|
+
operation: z.enum(DIAGNOSTICS_OPERATIONS),
|
|
99
|
+
stage: z.enum(DIAGNOSTICS_STAGES),
|
|
100
|
+
bucket: z.number().int().min(0).max(7),
|
|
101
|
+
count: integer.min(1).max(128)
|
|
102
|
+
}).strict();
|
|
103
|
+
const DiagnosticsSnapshotSchema = z.object({
|
|
104
|
+
schemaVersion: z.literal(1),
|
|
105
|
+
coverageVersion: z.literal(1),
|
|
106
|
+
epoch: integer,
|
|
107
|
+
updatedAt: integer,
|
|
108
|
+
rows: z.array(DiagnosticsRowSchema).max(DIAGNOSTICS_MAX_ROWS),
|
|
109
|
+
pending: z.array(DiagnosticsPendingSchema).max(128),
|
|
110
|
+
dropped: integer,
|
|
111
|
+
clientDropped: integer,
|
|
112
|
+
clientUnconfirmed: integer,
|
|
113
|
+
saturated: integer,
|
|
114
|
+
evicted: integer,
|
|
115
|
+
interrupted: integer
|
|
116
|
+
}).strict().refine((value) => value.pending.reduce((sum, row) => sum + row.count, 0) <= 128, "Diagnostics pending capacity exceeded").refine((value) => JSON.stringify(value).length <= DIAGNOSTICS_MAX_BYTES, "Diagnostics capacity exceeded");
|
|
117
|
+
const DiagnosticsViewSchema = z.object({
|
|
118
|
+
enabled: z.boolean(),
|
|
119
|
+
state: z.enum([
|
|
120
|
+
"loading",
|
|
121
|
+
"ready",
|
|
122
|
+
"unavailable",
|
|
123
|
+
"error"
|
|
124
|
+
]),
|
|
125
|
+
diagnostic: z.enum([
|
|
126
|
+
"none",
|
|
127
|
+
"storage-unavailable",
|
|
128
|
+
"storage-invalid",
|
|
129
|
+
"storage-write-failed",
|
|
130
|
+
"profile-unavailable",
|
|
131
|
+
"settings-unavailable",
|
|
132
|
+
"settings-conflict",
|
|
133
|
+
"client-report-failed",
|
|
134
|
+
"client-report-revoked",
|
|
135
|
+
"closed"
|
|
136
|
+
]),
|
|
137
|
+
persistedAt: integer.optional(),
|
|
138
|
+
dirty: z.boolean(),
|
|
139
|
+
snapshot: DiagnosticsSnapshotSchema
|
|
140
|
+
}).strict();
|
|
141
|
+
function diagnosticsBucket(ms) {
|
|
142
|
+
return [
|
|
143
|
+
100,
|
|
144
|
+
500,
|
|
145
|
+
1e3,
|
|
146
|
+
5e3,
|
|
147
|
+
15e3,
|
|
148
|
+
6e4,
|
|
149
|
+
3e5
|
|
150
|
+
].findIndex((bound) => ms < bound) === -1 ? 7 : [
|
|
151
|
+
100,
|
|
152
|
+
500,
|
|
153
|
+
1e3,
|
|
154
|
+
5e3,
|
|
155
|
+
15e3,
|
|
156
|
+
6e4,
|
|
157
|
+
3e5
|
|
158
|
+
].findIndex((bound) => ms < bound);
|
|
159
|
+
}
|
|
160
|
+
function diagnosticsReason(error) {
|
|
161
|
+
const seen = /* @__PURE__ */ new Set();
|
|
162
|
+
for (let depth = 0; depth < 8 && error instanceof Error && !seen.has(error); depth++) {
|
|
163
|
+
seen.add(error);
|
|
164
|
+
const nativeCode = "code" in error ? error.code : void 0;
|
|
165
|
+
const typed = DIAGNOSTICS_REASONS.find((code) => code !== "none" && code !== "unknown" && code === nativeCode);
|
|
166
|
+
if (typed !== void 0) return typed;
|
|
167
|
+
const message = error.message.slice(0, 4096);
|
|
168
|
+
for (const code of DIAGNOSTICS_REASONS) if (code.startsWith("COPILOT_") || code === "CONTEXT_WINDOW_EXCEEDED") {
|
|
169
|
+
if (new RegExp(`(?:^|[^A-Za-z0-9_])${code}(?:$|[^A-Za-z0-9_])`).test(message)) return code;
|
|
170
|
+
}
|
|
171
|
+
error = error.cause;
|
|
172
|
+
}
|
|
173
|
+
return "unknown";
|
|
174
|
+
}
|
|
175
|
+
function diagnosticsOutcome(reason) {
|
|
176
|
+
if (reason === "COPILOT_ACCOUNTS_BUSY" || reason === "COPILOT_ACCOUNTS_CONFLICT") return "policy-rejected";
|
|
177
|
+
if (reason === "COPILOT_ACCOUNTS_CHANGED") return "revoked";
|
|
178
|
+
if (reason.endsWith("SETTINGS_UNAVAILABLE") || reason === "COPILOT_SESSION_ACCOUNTS_UNAVAILABLE") return "environment-fault";
|
|
179
|
+
return "failed";
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
export { DiagnosticsPendingSchema as a, DiagnosticsViewSchema as c, diagnosticsReason as d, DIAGNOSTICS_RETENTION_MS as i, diagnosticsBucket as l, DIAGNOSTICS_OPERATIONS as n, DiagnosticsRowSchema as o, DIAGNOSTICS_REASONS as r, DiagnosticsSnapshotSchema as s, DIAGNOSTICS_MAX_ROWS as t, diagnosticsOutcome as u };
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as DiagnosticsViewSchema, d as diagnosticsReason, i as DIAGNOSTICS_RETENTION_MS, l as diagnosticsBucket, o as DiagnosticsRowSchema, s as DiagnosticsSnapshotSchema, u as diagnosticsOutcome } from "./diagnostics-types-FVf6zjob.js";
|
|
2
2
|
import { C as providerErrorMessage, D as onSettingsNamespaceUpdated, E as readCopilotCatalog, O as readConfigValue, S as isAbortError, T as isPluginPreviewProvider, _ as sameCandidates, a as COPILOT_HOSTED_SEARCH_PROVIDER_ID, b as currentSearchSelection, c as applyRequestAuth, d as ANTHROPIC_WEB_SEARCH_TOOL_TYPE, f as GITHUB_COPILOT_CREDENTIAL_KEY$1, g as candidatesForRoute, h as WEB_SEARCH_TOOL_TYPE, i as describeSearchBackend, k as readSettingsNamespace, l as normalizeRequestAuth, m as SearchPlan, n as routeSessionSearch, o as GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID, p as RESPONSES_WEB_SEARCH_TOOL_TYPE, r as DescribedSearchFallbackError, s as createTraditionalSearchProvider, t as isCopilotSearchSelection, u as providerRequestHeaders, v as currentChatRoute, w as readBounded, x as abortable$1, y as currentSearchInitiator } from "./search-routing-CV2hs8as.js";
|
|
3
3
|
import { a as GITHUB_COPILOT_PREVIEW_PROVIDER_ID, i as GITHUB_COPILOT_CREDENTIAL_KEY, n as GITHUB_COPILOT_AUTO_INTELLIGENCE_MODEL_ID, o as GITHUB_COPILOT_PROVIDER_ID, r as GITHUB_COPILOT_AUTO_MODEL_ID, s as autoModelPreference, t as GITHUB_COPILOT_AUTO_EFFICIENCY_MODEL_ID } from "./copilot-identity-DRZY_d2X.js";
|
|
4
|
+
import { a as selectCompactionReasoning, i as resolveRequestBudgetPolicy, n as assessRequestBudget, r as calculateRequestBudget, t as DEFAULT_REQUEST_BUDGET_POLICY } from "./request-budget-DLY_aRq0.js";
|
|
4
5
|
import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
import AuthorizationService from "@deepseek-ai/dsh-authorization";
|
|
@@ -310,7 +311,7 @@ const result$1 = strictRemoteCodec("dsh-github-copilot#DiagnosticsView", Diagnos
|
|
|
310
311
|
var package_default = {
|
|
311
312
|
name: "dsh-github-copilot",
|
|
312
313
|
description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
|
|
313
|
-
version: "0.4.0-alpha.
|
|
314
|
+
version: "0.4.0-alpha.132",
|
|
314
315
|
publishConfig: {
|
|
315
316
|
"access": "public",
|
|
316
317
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -386,6 +387,7 @@ var package_default = {
|
|
|
386
387
|
"docs/evidence-driven-iteration.md",
|
|
387
388
|
"docs/plugin-diagnostics.md",
|
|
388
389
|
"docs/auto-iteration-review.json",
|
|
390
|
+
"scripts/analyze-diagnostics.mjs",
|
|
389
391
|
"scripts/iteration-review.mjs",
|
|
390
392
|
"docs/image-input-compatibility.md",
|
|
391
393
|
"output/auto-model-mockup/index.html",
|
|
@@ -421,6 +423,7 @@ var package_default = {
|
|
|
421
423
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
422
424
|
"typecheck:tests": "tsc -p tsconfig.tests.json",
|
|
423
425
|
"test:scripts": "node --test \"tests/scripts/*.test.mjs\"",
|
|
426
|
+
"diagnostics:analyze": "node scripts/analyze-diagnostics.mjs",
|
|
424
427
|
"agent:describe": "node scripts/agent.mjs describe --json",
|
|
425
428
|
"agent:doctor": "node scripts/agent.mjs doctor --json",
|
|
426
429
|
"agent:plan": "node scripts/agent.mjs plan",
|
|
@@ -2276,6 +2279,8 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
2276
2279
|
const efforts = rawEfforts === void 0 ? [] : stringList(rawEfforts, ACCOUNT_MODEL_CATALOG_LIMITS.maxEfforts, ACCOUNT_MODEL_CATALOG_LIMITS.maxEffortLength, "INVALID_REASONING", budget);
|
|
2277
2280
|
const adaptiveThinking = field(supports, "adaptive_thinking", budget);
|
|
2278
2281
|
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");
|
|
2279
2284
|
const minThinkingBudget = optionalPositive(supports, "min_thinking_budget", "INVALID_REASONING", budget);
|
|
2280
2285
|
const maxThinkingBudget = optionalPositive(supports, "max_thinking_budget", "INVALID_REASONING", budget);
|
|
2281
2286
|
if (minThinkingBudget !== void 0 && maxThinkingBudget !== void 0 && minThinkingBudget > maxThinkingBudget) fail$1("INVALID_REASONING");
|
|
@@ -2310,6 +2315,7 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
2310
2315
|
...minThinkingBudget === void 0 ? {} : { minThinkingBudget },
|
|
2311
2316
|
...maxThinkingBudget === void 0 ? {} : { maxThinkingBudget }
|
|
2312
2317
|
}),
|
|
2318
|
+
sampling: Object.freeze({ temperature: thinking === true ? "unsupported" : thinking === false ? "supported" : "unknown" }),
|
|
2313
2319
|
evidence: Object.freeze({
|
|
2314
2320
|
endpoints: Object.freeze(endpoints),
|
|
2315
2321
|
unsupportedEndpointCount,
|
|
@@ -3696,6 +3702,7 @@ function accountModelFromDescriptor(descriptor, baseURL) {
|
|
|
3696
3702
|
reasoning: supported.length > 0,
|
|
3697
3703
|
thinkingLevelMap: Object.freeze(map),
|
|
3698
3704
|
unmappedReasoningEfforts: Object.freeze(unmapped),
|
|
3705
|
+
temperatureCompatibility: descriptor.sampling.temperature,
|
|
3699
3706
|
...descriptor.reasoning.minThinkingBudget === void 0 ? {} : { minThinkingBudget: descriptor.reasoning.minThinkingBudget },
|
|
3700
3707
|
...descriptor.reasoning.maxThinkingBudget === void 0 ? {} : { maxThinkingBudget: descriptor.reasoning.maxThinkingBudget },
|
|
3701
3708
|
headers: copilotPublicHeaders(),
|
|
@@ -3923,6 +3930,7 @@ function createAccountProvider(descriptors, guard, baseURL) {
|
|
|
3923
3930
|
fetch: observeResponse
|
|
3924
3931
|
} : {
|
|
3925
3932
|
...options,
|
|
3933
|
+
...responses && entry.temperatureCompatibility === "unsupported" ? { temperature: void 0 } : {},
|
|
3926
3934
|
signal: liveness?.signal ?? lease.signal,
|
|
3927
3935
|
headers,
|
|
3928
3936
|
fetch: observeResponse,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as diagnosticsReason, u as diagnosticsOutcome } from "./diagnostics-types-FVf6zjob.js";
|
|
2
2
|
import "./copilot-identity-DRZY_d2X.js";
|
|
3
|
+
import { i as resolveRequestBudgetPolicy, r as calculateRequestBudget } from "./request-budget-DLY_aRq0.js";
|
|
3
4
|
import z from "@deepseek-ai/schemastery";
|
|
4
5
|
import { LlmError, createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
5
6
|
import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//#region lib/types/request-budget.js
|
|
2
|
+
/** The safety allowance matches the pinned native SDK; pressure is a separate opt-in check. */
|
|
3
|
+
const DEFAULT_REQUEST_BUDGET_POLICY = Object.freeze({
|
|
4
|
+
safetyTokens: 4096,
|
|
5
|
+
pressureRatio: .9,
|
|
6
|
+
compactionReasoning: "prefer-low"
|
|
7
|
+
});
|
|
8
|
+
/** Validate deployment policy before applying defaults; unknown keys fail rather than silently drift. */
|
|
9
|
+
function resolveRequestBudgetPolicy(config = {}) {
|
|
10
|
+
const keys = /* @__PURE__ */ new Set([
|
|
11
|
+
"safetyTokens",
|
|
12
|
+
"pressureRatio",
|
|
13
|
+
"compactionReasoning"
|
|
14
|
+
]);
|
|
15
|
+
for (const key of Object.keys(config)) if (!keys.has(key)) throw new Error(`COPILOT_REQUEST_BUDGET_POLICY_INVALID: unknown setting ${key}`);
|
|
16
|
+
const safetyTokens = config.safetyTokens === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.safetyTokens : config.safetyTokens;
|
|
17
|
+
const pressureRatio = config.pressureRatio === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.pressureRatio : config.pressureRatio;
|
|
18
|
+
const compactionReasoning = config.compactionReasoning === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning : config.compactionReasoning;
|
|
19
|
+
if (!Number.isSafeInteger(safetyTokens) || safetyTokens < 0) throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: safetyTokens must be a non-negative safe integer");
|
|
20
|
+
if (!Number.isFinite(pressureRatio) || pressureRatio <= 0 || pressureRatio > 1) throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: pressureRatio must be greater than zero and at most one");
|
|
21
|
+
if (compactionReasoning !== "prefer-low" && compactionReasoning !== "preserve") throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: unsupported compactionReasoning");
|
|
22
|
+
return Object.freeze({
|
|
23
|
+
safetyTokens,
|
|
24
|
+
pressureRatio,
|
|
25
|
+
compactionReasoning
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function failure(code, message) {
|
|
29
|
+
return Object.freeze({
|
|
30
|
+
ok: false,
|
|
31
|
+
code,
|
|
32
|
+
message: `${code}: ${message}`
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function positiveInteger(value) {
|
|
36
|
+
return Number.isSafeInteger(value) && value > 0;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reserve output under the combined context and independently enforce the prompt ceiling.
|
|
40
|
+
* `policy` must come from resolveRequestBudgetPolicy; no caller cap or catalog object is changed.
|
|
41
|
+
*/
|
|
42
|
+
function calculateRequestBudget(limits, requestedMaxTokens, policy = DEFAULT_REQUEST_BUDGET_POLICY) {
|
|
43
|
+
const { contextWindow, maxInputTokens, maxTokens } = limits;
|
|
44
|
+
if (!positiveInteger(contextWindow) || !positiveInteger(maxTokens) || maxInputTokens !== void 0 && !positiveInteger(maxInputTokens)) return failure("COPILOT_REQUEST_INVALID_LIMITS", "model token capacities must be positive safe integers");
|
|
45
|
+
if (requestedMaxTokens !== void 0 && !positiveInteger(requestedMaxTokens)) return failure("COPILOT_REQUEST_INVALID_OUTPUT_LIMIT", "request output cap must be a positive safe integer");
|
|
46
|
+
const outputReservation = requestedMaxTokens ?? maxTokens;
|
|
47
|
+
if (outputReservation > maxTokens) return failure("COPILOT_REQUEST_OUTPUT_LIMIT_EXCEEDED", `request output cap ${outputReservation} exceeds model output capacity ${maxTokens}`);
|
|
48
|
+
const contextInputLimit = contextWindow - outputReservation;
|
|
49
|
+
const limitingFactor = maxInputTokens !== void 0 && maxInputTokens <= contextInputLimit ? "prompt" : "context";
|
|
50
|
+
const hardInputLimit = Math.min(maxInputTokens ?? contextInputLimit, contextInputLimit) - policy.safetyTokens;
|
|
51
|
+
if (hardInputLimit <= 0) return failure("COPILOT_REQUEST_NO_INPUT_HEADROOM", "output reservation and safety allowance leave no positive input budget");
|
|
52
|
+
return Object.freeze({
|
|
53
|
+
ok: true,
|
|
54
|
+
budget: Object.freeze({
|
|
55
|
+
contextWindow,
|
|
56
|
+
...maxInputTokens === void 0 ? {} : { maxInputTokens },
|
|
57
|
+
maxOutputTokens: maxTokens,
|
|
58
|
+
outputReservation,
|
|
59
|
+
hardInputLimit,
|
|
60
|
+
pressureInputLimit: Math.floor(hardInputLimit * policy.pressureRatio),
|
|
61
|
+
limitingFactor
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check an estimated full prompt; estimates are not provider-exact token counts.
|
|
67
|
+
* Enable pressure only for an owned ordinary loop call with a compaction recovery path.
|
|
68
|
+
* Auxiliary and agentless calls use hard admission, including compaction itself.
|
|
69
|
+
*/
|
|
70
|
+
function assessRequestBudget(estimatedInput, budget, pressure = false) {
|
|
71
|
+
if (!Number.isFinite(estimatedInput) || estimatedInput < 0 || estimatedInput > Number.MAX_SAFE_INTEGER) return failure("COPILOT_REQUEST_INVALID_ESTIMATE", "estimated input must be finite, non-negative, and safely representable");
|
|
72
|
+
const input = Math.ceil(estimatedInput);
|
|
73
|
+
if (input > budget.hardInputLimit) return failure(budget.limitingFactor === "prompt" ? "COPILOT_REQUEST_INPUT_LIMIT_EXCEEDED" : "COPILOT_REQUEST_CONTEXT_LIMIT_EXCEEDED", `estimated input ${input} exceeds input budget ${budget.hardInputLimit} with output reservation ${budget.outputReservation}`);
|
|
74
|
+
if (pressure && input > budget.pressureInputLimit) return failure("COPILOT_REQUEST_PRESSURE_EXCEEDED", `estimated input ${input} exceeds proactive compaction budget ${budget.pressureInputLimit}`);
|
|
75
|
+
return Object.freeze({ ok: true });
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Select a low-cost supported effort only for a caller-confirmed compaction request.
|
|
79
|
+
* A supplied effort, including a materialized provider default, wins unchanged; native validation
|
|
80
|
+
* remains authoritative. Unsupported low-cost controls preserve the provider default, never off/none.
|
|
81
|
+
*/
|
|
82
|
+
function selectCompactionReasoning(supportedEfforts, requestedEffort, mode = DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning) {
|
|
83
|
+
if (requestedEffort !== void 0 || mode === "preserve") return requestedEffort;
|
|
84
|
+
return supportedEfforts.find((effort) => effort === "minimal") ?? supportedEfforts.find((effort) => effort === "low");
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { selectCompactionReasoning as a, resolveRequestBudgetPolicy as i, assessRequestBudget as n, calculateRequestBudget as r, DEFAULT_REQUEST_BUDGET_POLICY as t };
|
|
@@ -33,6 +33,13 @@ export interface AccountModelDescriptor {
|
|
|
33
33
|
readonly input: readonly ('text' | 'image')[];
|
|
34
34
|
readonly category?: AccountModelCategory;
|
|
35
35
|
readonly reasoning: AccountModelReasoning;
|
|
36
|
+
readonly sampling: {
|
|
37
|
+
/**
|
|
38
|
+
* GitHub's explicit thinking capability is the supplier-owned compatibility
|
|
39
|
+
* fact used by its official OpenAI endpoint to omit temperature.
|
|
40
|
+
*/
|
|
41
|
+
readonly temperature: 'supported' | 'unsupported' | 'unknown';
|
|
42
|
+
};
|
|
36
43
|
readonly evidence: {
|
|
37
44
|
/** Recognized endpoint literals only, never arbitrary URLs or query strings. */
|
|
38
45
|
readonly endpoints: readonly RecognizedEndpoint[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const DIAGNOSTICS_ANALYSIS_MAX_INPUT_BYTES: number;
|
|
2
|
+
interface FileStat {
|
|
3
|
+
isFile(): boolean;
|
|
4
|
+
isSymbolicLink(): boolean;
|
|
5
|
+
size: number;
|
|
6
|
+
mtimeMs: number;
|
|
7
|
+
dev: number;
|
|
8
|
+
ino: number;
|
|
9
|
+
}
|
|
10
|
+
interface ReadHandle {
|
|
11
|
+
stat(): Promise<FileStat>;
|
|
12
|
+
read(buffer: Buffer, offset: number, length: number, position: number): Promise<{
|
|
13
|
+
bytesRead: number;
|
|
14
|
+
}>;
|
|
15
|
+
close(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export interface DiagnosticsAnalysisFileSystem {
|
|
18
|
+
lstat(path: string): Promise<FileStat>;
|
|
19
|
+
open(path: string, flags: 'r'): Promise<ReadHandle>;
|
|
20
|
+
}
|
|
21
|
+
export declare function readBoundedDiagnosticsFile(filePath: string, io?: DiagnosticsAnalysisFileSystem): Promise<string>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=diagnostics-analysis-io.d.ts.map
|