dsh-github-copilot 0.4.2-alpha.3 → 0.4.2-alpha.4
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 +1 -1
- package/CHANGELOG.md +15 -0
- package/README.md +13 -7
- package/README.zh.md +11 -7
- package/deployment-baseline.json +6 -1
- package/docs/plugin-diagnostics.md +67 -8
- package/lib/client.js +164 -19
- package/lib/client.js.map +1 -1
- package/lib/diagnostics-analysis.js +4 -2
- package/lib/{diagnostics-types-Bl3QCfR0.js → diagnostics-types-CpyhNCSg.js} +106 -13
- package/lib/index.js +222 -5
- package/lib/manual-compaction-recovery.js +1 -1
- package/lib/remote.js +113 -12
- package/lib/types/config.d.ts +6 -2
- package/lib/types/copilot-usage-remote.d.ts +1 -1
- package/lib/types/diagnostics-analysis.d.ts +1 -0
- package/lib/types/diagnostics-collector.d.ts +6 -0
- package/lib/types/diagnostics-host.d.ts +51 -1
- package/lib/types/diagnostics-remote.d.ts +3 -2
- package/lib/types/diagnostics-types.d.ts +183 -6
- package/lib/types/preview-provider.d.ts +6 -0
- package/lib/types/remote.d.ts +1 -1
- package/lib/types/request-diagnostics.d.ts +190 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DiagnosticsPendingSchema, c as DiagnosticsViewSchema, n as DIAGNOSTICS_OPERATIONS, r as DIAGNOSTICS_REASONS, s as DiagnosticsSnapshotSchema } from "./diagnostics-types-
|
|
1
|
+
import { a as DiagnosticsPendingSchema, c as DiagnosticsViewSchema, n as DIAGNOSTICS_OPERATIONS, r as DIAGNOSTICS_REASONS, s as DiagnosticsSnapshotSchema } from "./diagnostics-types-CpyhNCSg.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region lib/types/diagnostics-analysis.js
|
|
4
4
|
const RETENTION_MS = 12096e5;
|
|
@@ -42,7 +42,8 @@ const gaps = [
|
|
|
42
42
|
"no-collection-coverage-clock",
|
|
43
43
|
"no-calibrated-alert-thresholds",
|
|
44
44
|
"no-baseline-trend",
|
|
45
|
-
"no-root-cause-proof"
|
|
45
|
+
"no-root-cause-proof",
|
|
46
|
+
"request-observations-not-analyzed"
|
|
46
47
|
];
|
|
47
48
|
const intervals = [
|
|
48
49
|
{
|
|
@@ -326,6 +327,7 @@ function analyzeSnapshot(input, options) {
|
|
|
326
327
|
if (snapshot.pending.length) gapSet.add("stored-pending-is-not-live");
|
|
327
328
|
}
|
|
328
329
|
if (!populations.length) gapSet.add("no-retained-operation-observations");
|
|
330
|
+
if (snapshot.requests !== void 0) gapSet.add("request-observations-not-analyzed");
|
|
329
331
|
if (!populations.some((row) => [
|
|
330
332
|
"account-global-switch",
|
|
331
333
|
"account-session-select",
|
|
@@ -111,10 +111,10 @@ function allocateAutoModel(pool, highCostModelIds, previousModelId, seed) {
|
|
|
111
111
|
const AUTO_ALLOCATION_DIAGNOSTIC_MAX_ROWS = 1024;
|
|
112
112
|
const AUTO_ALLOCATION_DIAGNOSTIC_RETENTION_MS = 12096e5;
|
|
113
113
|
const dayMs = 864e5;
|
|
114
|
-
const integer$
|
|
114
|
+
const integer$2 = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
115
115
|
const version$1 = z.string().max(64).regex(/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/);
|
|
116
116
|
const allocationRow = z.object({
|
|
117
|
-
day: integer$
|
|
117
|
+
day: integer$2.multipleOf(dayMs),
|
|
118
118
|
version: version$1,
|
|
119
119
|
policyVersion: z.string().min(1).max(64),
|
|
120
120
|
modelId: z.string().min(1).max(512),
|
|
@@ -141,12 +141,12 @@ const allocationRow = z.object({
|
|
|
141
141
|
highCost: z.boolean(),
|
|
142
142
|
previous: z.boolean(),
|
|
143
143
|
weight: z.number().positive().max(1.5),
|
|
144
|
-
opportunities: integer$
|
|
144
|
+
opportunities: integer$2.min(1),
|
|
145
145
|
expectedSelections: z.number().finite().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
146
|
-
selections: integer$
|
|
146
|
+
selections: integer$2
|
|
147
147
|
}).strict();
|
|
148
148
|
const noFitRow = z.object({
|
|
149
|
-
day: integer$
|
|
149
|
+
day: integer$2.multipleOf(dayMs),
|
|
150
150
|
version: version$1,
|
|
151
151
|
policyVersion: z.string().min(1).max(64),
|
|
152
152
|
targetCategory: z.enum([
|
|
@@ -167,20 +167,20 @@ const noFitRow = z.object({
|
|
|
167
167
|
"unknown"
|
|
168
168
|
]),
|
|
169
169
|
assessmentSource: z.enum(["local", "semantic"]),
|
|
170
|
-
decisions: integer$
|
|
170
|
+
decisions: integer$2.min(1)
|
|
171
171
|
}).strict();
|
|
172
172
|
const AutoAllocationDiagnosticsSchema = z.object({
|
|
173
173
|
status: z.enum(["observed", "not-collected"]),
|
|
174
174
|
rows: z.array(allocationRow).max(AUTO_ALLOCATION_DIAGNOSTIC_MAX_ROWS),
|
|
175
175
|
noFitRows: z.array(noFitRow).max(AUTO_ALLOCATION_DIAGNOSTIC_MAX_ROWS),
|
|
176
|
-
observationStart: integer$
|
|
177
|
-
observationEnd: integer$
|
|
176
|
+
observationStart: integer$2.nullable(),
|
|
177
|
+
observationEnd: integer$2.nullable(),
|
|
178
178
|
completeHistory: z.literal(false),
|
|
179
179
|
rowsTruncated: z.boolean(),
|
|
180
|
-
dropped: integer$
|
|
181
|
-
expired: integer$
|
|
182
|
-
saturated: integer$
|
|
183
|
-
restarts: integer$
|
|
180
|
+
dropped: integer$2,
|
|
181
|
+
expired: integer$2,
|
|
182
|
+
saturated: integer$2,
|
|
183
|
+
restarts: integer$2
|
|
184
184
|
}).strict().refine((value) => JSON.stringify(value).length <= 15e5, "Auto allocation diagnostic capacity exceeded").refine((value) => value.rows.length + value.noFitRows.length <= AUTO_ALLOCATION_DIAGNOSTIC_MAX_ROWS, "Auto allocation row capacity exceeded").refine(({ observationStart, observationEnd }) => observationStart === null ? observationEnd === null : observationEnd !== null && observationEnd >= observationStart, "Auto allocation observation window is inconsistent");
|
|
185
185
|
function emptyAutoAllocationDiagnostics() {
|
|
186
186
|
return {
|
|
@@ -324,6 +324,97 @@ var AutoAllocationDiagnosticsCollector = class {
|
|
|
324
324
|
}
|
|
325
325
|
};
|
|
326
326
|
//#endregion
|
|
327
|
+
//#region lib/types/request-diagnostics.js
|
|
328
|
+
const integer$1 = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
329
|
+
const composition = z.discriminatedUnion("state", [z.object({
|
|
330
|
+
state: z.literal("complete"),
|
|
331
|
+
totalBytes: integer$1,
|
|
332
|
+
conversationBytes: integer$1,
|
|
333
|
+
toolSchemaBytes: integer$1,
|
|
334
|
+
systemBytes: integer$1,
|
|
335
|
+
otherBytes: integer$1,
|
|
336
|
+
imageBlockBytes: integer$1,
|
|
337
|
+
opaqueReplayBytes: integer$1,
|
|
338
|
+
remainingConversationBytes: integer$1
|
|
339
|
+
}).strict(), z.object({
|
|
340
|
+
state: z.enum([
|
|
341
|
+
"unavailable",
|
|
342
|
+
"size-limit",
|
|
343
|
+
"work-limit",
|
|
344
|
+
"invalid-json",
|
|
345
|
+
"unsupported-shape"
|
|
346
|
+
]),
|
|
347
|
+
totalBytes: integer$1.optional()
|
|
348
|
+
}).strict()]);
|
|
349
|
+
const upload = z.discriminatedUnion("state", [
|
|
350
|
+
z.object({
|
|
351
|
+
state: z.literal("observed"),
|
|
352
|
+
bodyWrite: z.enum(["observed", "not-observed"]),
|
|
353
|
+
bodyWriteCompleteMs: integer$1.optional(),
|
|
354
|
+
nativeResponseHeadersMs: integer$1.optional(),
|
|
355
|
+
alpn: z.enum([
|
|
356
|
+
"h2",
|
|
357
|
+
"http/1.1",
|
|
358
|
+
"unavailable"
|
|
359
|
+
]),
|
|
360
|
+
nodeWritableBufferBytes: integer$1.optional()
|
|
361
|
+
}).strict(),
|
|
362
|
+
z.object({ state: z.enum(["unavailable", "work-limit"]) }).strict(),
|
|
363
|
+
z.object({
|
|
364
|
+
state: z.literal("ambiguous"),
|
|
365
|
+
requestCount: integer$1
|
|
366
|
+
}).strict()
|
|
367
|
+
]);
|
|
368
|
+
const REQUEST_DIAGNOSTICS_RETENTION_MS = 864e5;
|
|
369
|
+
const RequestDiagnosticSchema = z.object({
|
|
370
|
+
streamId: z.string().uuid(),
|
|
371
|
+
dispatchIndex: integer$1.min(1),
|
|
372
|
+
version: z.string().max(64).regex(/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/),
|
|
373
|
+
startedAt: integer$1,
|
|
374
|
+
elapsedMs: integer$1,
|
|
375
|
+
model: z.string().max(128).regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/),
|
|
376
|
+
protocol: z.enum([
|
|
377
|
+
"openai-responses",
|
|
378
|
+
"openai-completions",
|
|
379
|
+
"anthropic-messages"
|
|
380
|
+
]),
|
|
381
|
+
composition,
|
|
382
|
+
encoding: z.enum([
|
|
383
|
+
"identity",
|
|
384
|
+
"gzip",
|
|
385
|
+
"unknown"
|
|
386
|
+
]),
|
|
387
|
+
wireBytes: integer$1.optional(),
|
|
388
|
+
upload: upload.optional(),
|
|
389
|
+
responseHeadersMs: integer$1.optional(),
|
|
390
|
+
httpStatus: integer$1.min(100).max(599).optional(),
|
|
391
|
+
outcome: z.enum([
|
|
392
|
+
"http-error",
|
|
393
|
+
"transport-error",
|
|
394
|
+
"stream-done",
|
|
395
|
+
"stream-error",
|
|
396
|
+
"cancelled",
|
|
397
|
+
"interrupted"
|
|
398
|
+
]),
|
|
399
|
+
reason: z.enum([
|
|
400
|
+
"none",
|
|
401
|
+
"unknown",
|
|
402
|
+
"request-body-timeout",
|
|
403
|
+
"caller-abort",
|
|
404
|
+
"credential-changed",
|
|
405
|
+
"disposed",
|
|
406
|
+
"byte-idle-timeout",
|
|
407
|
+
"signal-abort"
|
|
408
|
+
])
|
|
409
|
+
}).strict();
|
|
410
|
+
const RequestDiagnosticsSchema = z.object({
|
|
411
|
+
rows: z.array(RequestDiagnosticSchema).max(128),
|
|
412
|
+
dropped: integer$1,
|
|
413
|
+
evicted: integer$1,
|
|
414
|
+
pending: integer$1.max(128).optional(),
|
|
415
|
+
interruptedOnReopen: integer$1.optional()
|
|
416
|
+
}).strict();
|
|
417
|
+
//#endregion
|
|
327
418
|
//#region lib/types/diagnostics-types.js
|
|
328
419
|
const DIAGNOSTICS_OPERATIONS = [
|
|
329
420
|
"account-global-switch",
|
|
@@ -432,6 +523,7 @@ const DiagnosticsSnapshotSchema = z.object({
|
|
|
432
523
|
updatedAt: integer,
|
|
433
524
|
rows: z.array(DiagnosticsRowSchema).max(DIAGNOSTICS_MAX_ROWS),
|
|
434
525
|
autoAllocation: AutoAllocationDiagnosticsSchema.optional(),
|
|
526
|
+
requests: RequestDiagnosticsSchema.optional(),
|
|
435
527
|
pending: z.array(DiagnosticsPendingSchema).max(128),
|
|
436
528
|
dropped: integer,
|
|
437
529
|
clientDropped: integer,
|
|
@@ -443,6 +535,7 @@ const DiagnosticsSnapshotSchema = z.object({
|
|
|
443
535
|
const DiagnosticsViewSchema = z.object({
|
|
444
536
|
enabled: z.boolean(),
|
|
445
537
|
autoAllocationEnabled: z.boolean(),
|
|
538
|
+
requestEnabled: z.boolean().optional(),
|
|
446
539
|
state: z.enum([
|
|
447
540
|
"loading",
|
|
448
541
|
"ready",
|
|
@@ -506,4 +599,4 @@ function diagnosticsOutcome(reason) {
|
|
|
506
599
|
return "failed";
|
|
507
600
|
}
|
|
508
601
|
//#endregion
|
|
509
|
-
export {
|
|
602
|
+
export { normalizeExcludedModelIds as S, AutoAllocationSchema as _, DiagnosticsPendingSchema as a, ModelExclusionTurns as b, DiagnosticsViewSchema as c, diagnosticsReason as d, REQUEST_DIAGNOSTICS_RETENTION_MS as f, AUTO_ALLOCATION_POLICY as g, emptyAutoAllocationDiagnostics as h, DIAGNOSTICS_RETENTION_MS as i, diagnosticsBucket as l, AutoAllocationDiagnosticsCollector as m, DIAGNOSTICS_OPERATIONS as n, DiagnosticsRowSchema as o, RequestDiagnosticSchema as p, DIAGNOSTICS_REASONS as r, DiagnosticsSnapshotSchema as s, DIAGNOSTICS_MAX_ROWS as t, diagnosticsOutcome as u, allocateAutoModel as v, excludedModelSet as x, normalizeHighCostModelIds as y };
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
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";
|
|
2
|
-
import { _ as
|
|
2
|
+
import { S as normalizeExcludedModelIds, _ as AutoAllocationSchema, b as ModelExclusionTurns, c as DiagnosticsViewSchema, d as diagnosticsReason, f as REQUEST_DIAGNOSTICS_RETENTION_MS, g as AUTO_ALLOCATION_POLICY, h as emptyAutoAllocationDiagnostics, i as DIAGNOSTICS_RETENTION_MS, l as diagnosticsBucket, m as AutoAllocationDiagnosticsCollector, o as DiagnosticsRowSchema, p as RequestDiagnosticSchema, s as DiagnosticsSnapshotSchema, u as diagnosticsOutcome, v as allocateAutoModel, x as excludedModelSet, y as normalizeHighCostModelIds } from "./diagnostics-types-CpyhNCSg.js";
|
|
3
3
|
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";
|
|
4
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";
|
|
5
5
|
import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
@@ -57,6 +57,8 @@ var DiagnosticsCollector = class {
|
|
|
57
57
|
live = /* @__PURE__ */ new Set();
|
|
58
58
|
enabled = false;
|
|
59
59
|
autoAllocationEnabled = false;
|
|
60
|
+
requestEnabled = false;
|
|
61
|
+
requestHandles = /* @__PURE__ */ new Set();
|
|
60
62
|
lastWall = 0;
|
|
61
63
|
autoAllocation;
|
|
62
64
|
constructor(version, layer, changed = () => {}, wall = Date.now, mono = () => performance.now()) {
|
|
@@ -77,6 +79,12 @@ var DiagnosticsCollector = class {
|
|
|
77
79
|
this.increment("interrupted", pending.count);
|
|
78
80
|
}
|
|
79
81
|
this.data.pending = [];
|
|
82
|
+
if (this.data.requests) {
|
|
83
|
+
const requests = this.data.requests;
|
|
84
|
+
requests.interruptedOnReopen = Math.min(Number.MAX_SAFE_INTEGER, (requests.interruptedOnReopen ?? 0) + (requests.pending ?? 0));
|
|
85
|
+
requests.pending = 0;
|
|
86
|
+
this.changed();
|
|
87
|
+
}
|
|
80
88
|
this.expire();
|
|
81
89
|
}
|
|
82
90
|
setEnabled(enabled) {
|
|
@@ -103,6 +111,7 @@ var DiagnosticsCollector = class {
|
|
|
103
111
|
const epoch = this.data.epoch + 1;
|
|
104
112
|
if (!Number.isSafeInteger(epoch)) throw new Error("COPILOT_DIAGNOSTICS_EPOCH_LIMIT");
|
|
105
113
|
this.live.clear();
|
|
114
|
+
this.requestHandles.clear();
|
|
106
115
|
this.autoAllocation.clear();
|
|
107
116
|
this.data = {
|
|
108
117
|
...emptyDiagnostics(),
|
|
@@ -153,6 +162,13 @@ var DiagnosticsCollector = class {
|
|
|
153
162
|
this.increment("evicted", this.data.rows.length - kept.length);
|
|
154
163
|
if (kept.length !== this.data.rows.length) this.changed();
|
|
155
164
|
this.data.rows = kept;
|
|
165
|
+
const requests = this.data.requests;
|
|
166
|
+
if (requests) {
|
|
167
|
+
const retained = requests.rows.filter((row) => row.startedAt > now - REQUEST_DIAGNOSTICS_RETENTION_MS);
|
|
168
|
+
requests.evicted = Math.min(Number.MAX_SAFE_INTEGER, requests.evicted + requests.rows.length - retained.length);
|
|
169
|
+
if (retained.length !== requests.rows.length) this.changed();
|
|
170
|
+
requests.rows = retained;
|
|
171
|
+
}
|
|
156
172
|
}
|
|
157
173
|
add(operation, stage, metric, reason, bucket, count = 1, version = this.version) {
|
|
158
174
|
this.expire();
|
|
@@ -211,6 +227,10 @@ var DiagnosticsCollector = class {
|
|
|
211
227
|
}
|
|
212
228
|
return DiagnosticsSnapshotSchema.parse({
|
|
213
229
|
...this.data,
|
|
230
|
+
...this.data.requests ? { requests: {
|
|
231
|
+
...this.data.requests,
|
|
232
|
+
pending: this.requestHandles.size
|
|
233
|
+
} } : {},
|
|
214
234
|
autoAllocation: this.autoAllocation.snapshot(),
|
|
215
235
|
updatedAt: this.wall(),
|
|
216
236
|
pending
|
|
@@ -219,6 +239,84 @@ var DiagnosticsCollector = class {
|
|
|
219
239
|
close() {
|
|
220
240
|
this.setEnabled(false);
|
|
221
241
|
this.setAutoAllocationEnabled(false);
|
|
242
|
+
this.setRequestEnabled(false);
|
|
243
|
+
}
|
|
244
|
+
setRequestEnabled(enabled) {
|
|
245
|
+
if (this.requestEnabled && !enabled) for (const handle of this.requestHandles) handle.finish("interrupted", "unknown");
|
|
246
|
+
this.requestEnabled = enabled;
|
|
247
|
+
}
|
|
248
|
+
beginRequest(start) {
|
|
249
|
+
if (!this.requestEnabled) return void 0;
|
|
250
|
+
const requests = this.data.requests ??= {
|
|
251
|
+
rows: [],
|
|
252
|
+
dropped: 0,
|
|
253
|
+
evicted: 0
|
|
254
|
+
};
|
|
255
|
+
if (this.requestHandles.size >= 128) {
|
|
256
|
+
requests.dropped = Math.min(Number.MAX_SAFE_INTEGER, requests.dropped + 1);
|
|
257
|
+
this.changed();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const startedAt = this.wall(), startedMono = this.mono();
|
|
261
|
+
const base = {
|
|
262
|
+
...start,
|
|
263
|
+
version: this.version,
|
|
264
|
+
startedAt,
|
|
265
|
+
model: /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(start.model) ? start.model : "unknown"
|
|
266
|
+
};
|
|
267
|
+
let headers = {};
|
|
268
|
+
const handle = {
|
|
269
|
+
headers: (httpStatus, ms, upload) => {
|
|
270
|
+
if (!this.requestHandles.has(handle)) return;
|
|
271
|
+
headers = {
|
|
272
|
+
...httpStatus === void 0 ? {} : { httpStatus },
|
|
273
|
+
...ms === void 0 ? {} : { responseHeadersMs: Math.round(ms) },
|
|
274
|
+
...upload ? { upload } : {}
|
|
275
|
+
};
|
|
276
|
+
},
|
|
277
|
+
finish: (outcome, reason = "none") => {
|
|
278
|
+
if (!this.requestHandles.delete(handle)) return;
|
|
279
|
+
this.expire();
|
|
280
|
+
const current = this.data.requests;
|
|
281
|
+
if (!current) return;
|
|
282
|
+
const parsed = RequestDiagnosticSchema.safeParse({
|
|
283
|
+
...base,
|
|
284
|
+
...headers,
|
|
285
|
+
elapsedMs: Math.max(0, Math.round(this.mono() - startedMono)),
|
|
286
|
+
outcome,
|
|
287
|
+
reason
|
|
288
|
+
});
|
|
289
|
+
if (!parsed.success) {
|
|
290
|
+
current.dropped = Math.min(Number.MAX_SAFE_INTEGER, current.dropped + 1);
|
|
291
|
+
this.changed();
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const rows = [...current.rows, parsed.data];
|
|
295
|
+
const evicted = rows.length > 128 ? 1 : 0;
|
|
296
|
+
if (evicted) {
|
|
297
|
+
let oldest = 0;
|
|
298
|
+
for (let index = 1; index < rows.length; index++) if (rows[index].startedAt < rows[oldest].startedAt) oldest = index;
|
|
299
|
+
rows.splice(oldest, 1);
|
|
300
|
+
}
|
|
301
|
+
const candidate = {
|
|
302
|
+
...this.data,
|
|
303
|
+
requests: {
|
|
304
|
+
...current,
|
|
305
|
+
rows,
|
|
306
|
+
evicted: Math.min(Number.MAX_SAFE_INTEGER, current.evicted + evicted)
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
if (DiagnosticsSnapshotSchema.safeParse(candidate).success) this.data = candidate;
|
|
310
|
+
else current.dropped = Math.min(Number.MAX_SAFE_INTEGER, current.dropped + 1);
|
|
311
|
+
this.changed();
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
this.requestHandles.add(handle);
|
|
315
|
+
this.changed();
|
|
316
|
+
return handle;
|
|
317
|
+
}
|
|
318
|
+
isRequestEnabled() {
|
|
319
|
+
return this.requestEnabled;
|
|
222
320
|
}
|
|
223
321
|
noteDropped() {
|
|
224
322
|
if (this.enabled) {
|
|
@@ -331,6 +429,15 @@ const result$1 = strictRemoteCodec("dsh-github-copilot#DiagnosticsView", Diagnos
|
|
|
331
429
|
codec: strictRemoteCodec("dsh-github-copilot#AutoAllocationDiagnosticsEnabled", z.boolean())
|
|
332
430
|
}]
|
|
333
431
|
},
|
|
432
|
+
{
|
|
433
|
+
method: "setRequestEnabled",
|
|
434
|
+
parameters: [{
|
|
435
|
+
name: "enabled",
|
|
436
|
+
wire: "enabled",
|
|
437
|
+
source: "json",
|
|
438
|
+
codec: strictRemoteCodec("dsh-github-copilot#RequestDiagnosticsEnabled", z.boolean())
|
|
439
|
+
}]
|
|
440
|
+
},
|
|
334
441
|
{
|
|
335
442
|
method: "recordClient",
|
|
336
443
|
parameters: [{
|
|
@@ -353,7 +460,7 @@ const result$1 = strictRemoteCodec("dsh-github-copilot#DiagnosticsView", Diagnos
|
|
|
353
460
|
var package_default = {
|
|
354
461
|
name: "dsh-github-copilot",
|
|
355
462
|
description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
|
|
356
|
-
version: "0.4.2-alpha.
|
|
463
|
+
version: "0.4.2-alpha.4",
|
|
357
464
|
releaseNotes: "CHANGELOG.md",
|
|
358
465
|
publishConfig: {
|
|
359
466
|
"access": "public",
|
|
@@ -648,6 +755,7 @@ let DiagnosticsController = (() => {
|
|
|
648
755
|
let _classSuper = TypertRemoteService;
|
|
649
756
|
let _instanceExtraInitializers = [];
|
|
650
757
|
let _get_decorators;
|
|
758
|
+
let _setRequestEnabled_decorators;
|
|
651
759
|
let _setEnabled_decorators;
|
|
652
760
|
let _setAutoAllocationEnabled_decorators;
|
|
653
761
|
let _clear_decorators;
|
|
@@ -656,6 +764,7 @@ let DiagnosticsController = (() => {
|
|
|
656
764
|
static {
|
|
657
765
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
658
766
|
_get_decorators = [Remote];
|
|
767
|
+
_setRequestEnabled_decorators = [Remote];
|
|
659
768
|
_setEnabled_decorators = [Remote];
|
|
660
769
|
_setAutoAllocationEnabled_decorators = [Remote];
|
|
661
770
|
_clear_decorators = [Remote];
|
|
@@ -671,6 +780,17 @@ let DiagnosticsController = (() => {
|
|
|
671
780
|
},
|
|
672
781
|
metadata: _metadata
|
|
673
782
|
}, null, _instanceExtraInitializers);
|
|
783
|
+
__esDecorate$9(this, null, _setRequestEnabled_decorators, {
|
|
784
|
+
kind: "method",
|
|
785
|
+
name: "setRequestEnabled",
|
|
786
|
+
static: false,
|
|
787
|
+
private: false,
|
|
788
|
+
access: {
|
|
789
|
+
has: (obj) => "setRequestEnabled" in obj,
|
|
790
|
+
get: (obj) => obj.setRequestEnabled
|
|
791
|
+
},
|
|
792
|
+
metadata: _metadata
|
|
793
|
+
}, null, _instanceExtraInitializers);
|
|
674
794
|
__esDecorate$9(this, null, _setEnabled_decorators, {
|
|
675
795
|
kind: "method",
|
|
676
796
|
name: "setEnabled",
|
|
@@ -728,6 +848,7 @@ let DiagnosticsController = (() => {
|
|
|
728
848
|
problem = "storage-unavailable";
|
|
729
849
|
enabled = false;
|
|
730
850
|
autoAllocationEnabled = false;
|
|
851
|
+
requestEnabled = false;
|
|
731
852
|
dirty = false;
|
|
732
853
|
persistedAt;
|
|
733
854
|
revision = 0;
|
|
@@ -745,8 +866,10 @@ let DiagnosticsController = (() => {
|
|
|
745
866
|
const value = ctx.get("settings")?.describe({ redactSecrets: true }).find((row) => row.ns === "github-copilot")?.value;
|
|
746
867
|
this.enabled = typeof value === "object" && value !== null && "diagnosticsEnabled" in value && value.diagnosticsEnabled === true;
|
|
747
868
|
this.autoAllocationEnabled = typeof value === "object" && value !== null && "autoAllocationDiagnosticsEnabled" in value && value.autoAllocationDiagnosticsEnabled === true;
|
|
869
|
+
this.requestEnabled = typeof value === "object" && value !== null && "requestDiagnosticsEnabled" in value && value.requestDiagnosticsEnabled === true;
|
|
748
870
|
this.collector.setEnabled(this.enabled && this.state === "ready");
|
|
749
871
|
this.collector.setAutoAllocationEnabled(this.autoAllocationEnabled && this.state === "ready");
|
|
872
|
+
this.collector.setRequestEnabled(this.requestEnabled && this.state === "ready");
|
|
750
873
|
if (!this.enabled) this.brackets.clear();
|
|
751
874
|
};
|
|
752
875
|
ctx.inject(["settings"], (scope) => {
|
|
@@ -777,6 +900,7 @@ let DiagnosticsController = (() => {
|
|
|
777
900
|
this.problem = error instanceof Error && error.message === "COPILOT_DIAGNOSTICS_PROFILE_UNAVAILABLE" ? "profile-unavailable" : typeof error === "object" && error !== null && "code" in error && (error.code === "invalid-record" || error.code === "malformed-medium" || error.code === "version-mismatch") ? "storage-invalid" : "storage-unavailable";
|
|
778
901
|
this.collector.setEnabled(false);
|
|
779
902
|
this.collector.setAutoAllocationEnabled(false);
|
|
903
|
+
this.collector.setRequestEnabled(false);
|
|
780
904
|
ctx.logger.warn("[github-copilot] COPILOT_DIAGNOSTICS_STORAGE_UNAVAILABLE");
|
|
781
905
|
}
|
|
782
906
|
if (this.closed) return;
|
|
@@ -874,6 +998,7 @@ let DiagnosticsController = (() => {
|
|
|
874
998
|
return {
|
|
875
999
|
enabled: this.enabled,
|
|
876
1000
|
autoAllocationEnabled: this.autoAllocationEnabled,
|
|
1001
|
+
requestEnabled: this.requestEnabled,
|
|
877
1002
|
state: this.state,
|
|
878
1003
|
diagnostic: this.problem,
|
|
879
1004
|
...this.persistedAt === void 0 ? {} : { persistedAt: this.persistedAt },
|
|
@@ -881,6 +1006,30 @@ let DiagnosticsController = (() => {
|
|
|
881
1006
|
snapshot: this.collector.snapshot()
|
|
882
1007
|
};
|
|
883
1008
|
}
|
|
1009
|
+
async setRequestEnabled(enabled) {
|
|
1010
|
+
if (typeof enabled !== "boolean") throw new Error("COPILOT_DIAGNOSTICS_INVALID_CONTROL");
|
|
1011
|
+
if (this.settingsBusy) throw new Error("COPILOT_DIAGNOSTICS_CONTROL_BUSY");
|
|
1012
|
+
if (enabled && !this.domain) throw new Error("COPILOT_DIAGNOSTICS_STORAGE_UNAVAILABLE");
|
|
1013
|
+
this.settingsBusy = true;
|
|
1014
|
+
try {
|
|
1015
|
+
const settings = this.ctx.get("settings");
|
|
1016
|
+
const row = settings?.describe({ redactSecrets: true }).find((item) => item.ns === "github-copilot");
|
|
1017
|
+
if (!settings || !row) throw new Error("COPILOT_DIAGNOSTICS_SETTINGS_UNAVAILABLE");
|
|
1018
|
+
await settings.mutate("github-copilot", [{
|
|
1019
|
+
op: "set",
|
|
1020
|
+
path: ["requestDiagnosticsEnabled"],
|
|
1021
|
+
value: enabled
|
|
1022
|
+
}], row.revision);
|
|
1023
|
+
const saved = settings.describe({ redactSecrets: true }).find((item) => item.ns === "github-copilot")?.value;
|
|
1024
|
+
if (typeof saved !== "object" || saved === null || !("requestDiagnosticsEnabled" in saved) || saved.requestDiagnosticsEnabled !== enabled) throw new Error("COPILOT_DIAGNOSTICS_SETTINGS_COMMIT_UNCERTAIN");
|
|
1025
|
+
this.requestEnabled = enabled;
|
|
1026
|
+
this.collector.setRequestEnabled(enabled && this.state === "ready");
|
|
1027
|
+
await this.flush();
|
|
1028
|
+
return this.get();
|
|
1029
|
+
} finally {
|
|
1030
|
+
this.settingsBusy = false;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
884
1033
|
async setEnabled(enabled) {
|
|
885
1034
|
if (typeof enabled !== "boolean") throw new Error("COPILOT_DIAGNOSTICS_INVALID_CONTROL");
|
|
886
1035
|
if (this.settingsBusy) throw new Error("COPILOT_DIAGNOSTICS_CONTROL_BUSY");
|
|
@@ -4016,6 +4165,29 @@ function createAccountProvider(descriptors, guard, baseURL) {
|
|
|
4016
4165
|
}
|
|
4017
4166
|
} : options.onPayload;
|
|
4018
4167
|
const fetch = options.fetch ?? globalThis.fetch;
|
|
4168
|
+
const streamId = randomUUID();
|
|
4169
|
+
let dispatchIndex = 0;
|
|
4170
|
+
let requestDiagnostic;
|
|
4171
|
+
let dispatchSignal;
|
|
4172
|
+
let diagnosticsFailed = false;
|
|
4173
|
+
const observeDiagnostics = (observe) => {
|
|
4174
|
+
try {
|
|
4175
|
+
return observe();
|
|
4176
|
+
} catch {
|
|
4177
|
+
if (!diagnosticsFailed) {
|
|
4178
|
+
diagnosticsFailed = true;
|
|
4179
|
+
guard.requestDiagnostics?.failed();
|
|
4180
|
+
}
|
|
4181
|
+
return;
|
|
4182
|
+
}
|
|
4183
|
+
};
|
|
4184
|
+
const abortReason = () => {
|
|
4185
|
+
if (options.signal?.aborted) return "caller-abort";
|
|
4186
|
+
if (lease.signal.reason instanceof ManagedWireAbortError) return lease.signal.reason.code === "COPILOT_PREVIEW_DISPOSED" ? "disposed" : "credential-changed";
|
|
4187
|
+
if (liveness?.signal.reason instanceof CopilotStreamIdleError) return "byte-idle-timeout";
|
|
4188
|
+
return lease.signal.aborted || dispatchSignal?.aborted ? "signal-abort" : "unknown";
|
|
4189
|
+
};
|
|
4190
|
+
const diagnosticAborted = () => lease.signal.aborted || options.signal?.aborted === true || liveness?.signal.aborted === true || dispatchSignal?.aborted === true;
|
|
4019
4191
|
const observeResponse = async (input, init) => {
|
|
4020
4192
|
guard.requestCheckpoint?.();
|
|
4021
4193
|
guard.onRequestBodyTimeout?.(void 0);
|
|
@@ -4043,28 +4215,57 @@ function createAccountProvider(descriptors, guard, baseURL) {
|
|
|
4043
4215
|
compression = prepared.evidence;
|
|
4044
4216
|
}
|
|
4045
4217
|
lease.dispatch?.();
|
|
4218
|
+
dispatchSignal = dispatchInit?.signal ?? void 0;
|
|
4046
4219
|
liveness?.beginRequest(originalBody);
|
|
4220
|
+
dispatchIndex++;
|
|
4221
|
+
observeDiagnostics(() => requestDiagnostic?.finish("interrupted", "unknown"));
|
|
4222
|
+
requestDiagnostic = void 0;
|
|
4223
|
+
if (observeDiagnostics(() => guard.requestDiagnostics?.enabled())) requestDiagnostic = observeDiagnostics(() => {
|
|
4224
|
+
const wireBody = dispatchInit?.body;
|
|
4225
|
+
const wireBytes = typeof wireBody === "string" ? Buffer.byteLength(wireBody, "utf8") : ArrayBuffer.isView(wireBody) ? wireBody.byteLength : wireBody instanceof ArrayBuffer ? wireBody.byteLength : void 0;
|
|
4226
|
+
return guard.requestDiagnostics?.begin({
|
|
4227
|
+
streamId,
|
|
4228
|
+
dispatchIndex,
|
|
4229
|
+
model: model.id,
|
|
4230
|
+
protocol: entry.api,
|
|
4231
|
+
composition: requestBodyEvidence(originalBody, entry.api),
|
|
4232
|
+
encoding: compression?.encoding ?? (typeof wireBody === "string" && !new Headers(dispatchInit?.headers).has("content-encoding") ? "identity" : "unknown"),
|
|
4233
|
+
...wireBytes === void 0 ? {} : { wireBytes }
|
|
4234
|
+
});
|
|
4235
|
+
});
|
|
4047
4236
|
let response;
|
|
4048
|
-
const upload = guard.onRequestBodyTimeout === void 0 ? void 0 : createRequestUploadObserver();
|
|
4237
|
+
const upload = guard.onRequestBodyTimeout === void 0 && requestDiagnostic === void 0 ? void 0 : createRequestUploadObserver();
|
|
4049
4238
|
const startedAt = performance.now();
|
|
4050
4239
|
try {
|
|
4051
4240
|
response = await (upload === void 0 ? fetch(dispatchInput, dispatchInit) : upload.run(() => fetch(dispatchInput, dispatchInit)));
|
|
4052
4241
|
} catch (error) {
|
|
4242
|
+
observeDiagnostics(() => requestDiagnostic?.headers(void 0, void 0, upload?.snapshot()));
|
|
4243
|
+
observeDiagnostics(() => requestDiagnostic?.finish(diagnosticAborted() ? "cancelled" : "transport-error", abortReason()));
|
|
4244
|
+
requestDiagnostic = void 0;
|
|
4053
4245
|
retry?.observe(void 0, 0);
|
|
4054
4246
|
throw error;
|
|
4055
4247
|
} finally {
|
|
4056
4248
|
upload?.close();
|
|
4057
4249
|
}
|
|
4058
4250
|
const responseHeadersMs = performance.now() - startedAt;
|
|
4251
|
+
observeDiagnostics(() => requestDiagnostic?.headers(response.status, responseHeadersMs, upload?.snapshot()));
|
|
4059
4252
|
retry?.observe(originalBody, response.status);
|
|
4060
|
-
if (response.status === 408 && guard.onRequestBodyTimeout !== void 0) {
|
|
4253
|
+
if (response.status === 408 && (guard.onRequestBodyTimeout !== void 0 || requestDiagnostic !== void 0)) {
|
|
4061
4254
|
const diagnostic = await requestBodyTimeoutDiagnostic(response, originalBody, lease.signal, {
|
|
4062
4255
|
protocol: entry.api,
|
|
4063
4256
|
responseHeadersMs,
|
|
4064
4257
|
...upload === void 0 ? {} : { upload: upload.snapshot() },
|
|
4065
4258
|
...compression === void 0 ? {} : { compression }
|
|
4066
4259
|
});
|
|
4067
|
-
if (!lease.signal.aborted && !options.signal?.aborted) guard.onRequestBodyTimeout(diagnostic);
|
|
4260
|
+
if (!lease.signal.aborted && !options.signal?.aborted) guard.onRequestBodyTimeout?.(diagnostic);
|
|
4261
|
+
if (diagnostic !== void 0) {
|
|
4262
|
+
observeDiagnostics(() => requestDiagnostic?.finish("http-error", "request-body-timeout"));
|
|
4263
|
+
requestDiagnostic = void 0;
|
|
4264
|
+
}
|
|
4265
|
+
}
|
|
4266
|
+
if (response.status >= 400) {
|
|
4267
|
+
observeDiagnostics(() => requestDiagnostic?.finish("http-error", "unknown"));
|
|
4268
|
+
requestDiagnostic = void 0;
|
|
4068
4269
|
}
|
|
4069
4270
|
if (response.status === 401) {
|
|
4070
4271
|
if (responses && await isCopilotInputItemScopeError(response, lease.signal)) {
|
|
@@ -4098,10 +4299,19 @@ function createAccountProvider(descriptors, guard, baseURL) {
|
|
|
4098
4299
|
try {
|
|
4099
4300
|
for await (const event of native.streamSimple(model, context, wireOptions)) {
|
|
4100
4301
|
reportIdleFailure();
|
|
4302
|
+
if (event.type === "done") {
|
|
4303
|
+
observeDiagnostics(() => requestDiagnostic?.finish("stream-done"));
|
|
4304
|
+
requestDiagnostic = void 0;
|
|
4305
|
+
} else if (event.type === "error") {
|
|
4306
|
+
const cancelled = diagnosticAborted();
|
|
4307
|
+
observeDiagnostics(() => requestDiagnostic?.finish(cancelled ? "cancelled" : "stream-error", cancelled ? abortReason() : "unknown"));
|
|
4308
|
+
requestDiagnostic = void 0;
|
|
4309
|
+
}
|
|
4101
4310
|
if (event.type === "error" && event.reason === "aborted" && lease.signal.reason instanceof ManagedWireAbortError) guard.onWireAbort?.(lease.signal.reason.code);
|
|
4102
4311
|
yield event;
|
|
4103
4312
|
}
|
|
4104
4313
|
} finally {
|
|
4314
|
+
observeDiagnostics(() => requestDiagnostic?.finish("interrupted", "unknown"));
|
|
4105
4315
|
reportIdleFailure();
|
|
4106
4316
|
liveness?.dispose();
|
|
4107
4317
|
if (lease.signal.aborted || options.signal?.aborted) retry?.observe(void 0, 0);
|
|
@@ -6984,6 +7194,7 @@ function readInlineConfig(config) {
|
|
|
6984
7194
|
...config,
|
|
6985
7195
|
diagnosticsEnabled: readConfigValue(config.diagnosticsEnabled),
|
|
6986
7196
|
autoAllocationDiagnosticsEnabled: readConfigValue(config.autoAllocationDiagnosticsEnabled),
|
|
7197
|
+
requestDiagnosticsEnabled: readConfigValue(config.requestDiagnosticsEnabled),
|
|
6987
7198
|
continuationDefaultHistory: defaults === void 0 ? void 0 : Array.from(defaults, (row) => ({
|
|
6988
7199
|
enabled: row.enabled,
|
|
6989
7200
|
changedAt: row.changedAt
|
|
@@ -7017,6 +7228,7 @@ const MAX_TIMEOUT_MS = 2147483647;
|
|
|
7017
7228
|
const Config = z$1.object({
|
|
7018
7229
|
diagnosticsEnabled: z$1.boolean().default(false).hidden().volatile(),
|
|
7019
7230
|
autoAllocationDiagnosticsEnabled: z$1.boolean().default(false).hidden().volatile(),
|
|
7231
|
+
requestDiagnosticsEnabled: z$1.boolean().default(false).hidden().volatile(),
|
|
7020
7232
|
enabled: z$1.boolean().default(true),
|
|
7021
7233
|
providers: z$1.array(z$1.string()).default([]),
|
|
7022
7234
|
includeSources: z$1.boolean().default(true),
|
|
@@ -13585,6 +13797,11 @@ function createAccountRuntime(ctx, config, binding, exclusionTurns, replayRecove
|
|
|
13585
13797
|
const guard = {
|
|
13586
13798
|
...lifetime.guard(lease),
|
|
13587
13799
|
...hooks,
|
|
13800
|
+
requestDiagnostics: {
|
|
13801
|
+
enabled: () => ctx.get("githubCopilotDiagnostics")?.collector.isRequestEnabled() === true,
|
|
13802
|
+
begin: (start) => ctx.get("githubCopilotDiagnostics")?.collector.beginRequest(start),
|
|
13803
|
+
failed: () => ctx.logger.warn("[github-copilot] COPILOT_REQUEST_DIAGNOSTICS_FAILED")
|
|
13804
|
+
},
|
|
13588
13805
|
responsesRequestCompression: settings?.responsesRequestCompression === true && (template.transport === void 0 || template.transport === "sse"),
|
|
13589
13806
|
responsesOmitTemperature: settings?.responsesOmitTemperature === true,
|
|
13590
13807
|
onReplayFailure(error) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./copilot-identity-DRZY_d2X.js";
|
|
2
|
-
import { d as diagnosticsReason, u as diagnosticsOutcome } from "./diagnostics-types-
|
|
2
|
+
import { d as diagnosticsReason, u as diagnosticsOutcome } from "./diagnostics-types-CpyhNCSg.js";
|
|
3
3
|
import { i as resolveRequestBudgetPolicy, r as calculateRequestBudget } from "./request-budget-DLY_aRq0.js";
|
|
4
4
|
import z from "@deepseek-ai/schemastery";
|
|
5
5
|
import { LlmError, createUserMessage } from "@deepseek-ai/dsh-llm";
|