dsh-github-copilot 0.4.1 → 0.4.2-alpha.2

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.
@@ -52,8 +52,8 @@ export declare const ContextEvidenceSchema: z.ZodObject<{
52
52
  }, z.core.$strict>>;
53
53
  request: z.ZodEnum<{
54
54
  unknown: "unknown";
55
- cancelled: "cancelled";
56
55
  failed: "failed";
56
+ cancelled: "cancelled";
57
57
  pending: "pending";
58
58
  idle: "idle";
59
59
  succeeded: "succeeded";
@@ -131,8 +131,8 @@ export declare const contextEvidenceDefinition: {
131
131
  }, z.core.$strict>>;
132
132
  request: z.ZodEnum<{
133
133
  unknown: "unknown";
134
- cancelled: "cancelled";
135
134
  failed: "failed";
135
+ cancelled: "cancelled";
136
136
  pending: "pending";
137
137
  idle: "idle";
138
138
  succeeded: "succeeded";
@@ -197,8 +197,8 @@ export declare const contextEvidenceDefinition: {
197
197
  }, z.core.$strict>>;
198
198
  request: z.ZodEnum<{
199
199
  unknown: "unknown";
200
- cancelled: "cancelled";
201
200
  failed: "failed";
201
+ cancelled: "cancelled";
202
202
  pending: "pending";
203
203
  idle: "idle";
204
204
  succeeded: "succeeded";
@@ -243,7 +243,7 @@ export declare const contextEvidenceDefinition: {
243
243
  turn: number;
244
244
  step: number;
245
245
  } | null;
246
- request: "unknown" | "cancelled" | "failed" | "pending" | "idle" | "succeeded";
246
+ request: "unknown" | "failed" | "cancelled" | "pending" | "idle" | "succeeded";
247
247
  } | null | undefined;
248
248
  activeStep?: {
249
249
  turn: number;
@@ -236,8 +236,8 @@ export declare const DiagnosticsAnalysisReportSchema: z.ZodObject<{
236
236
  }>;
237
237
  metric: z.ZodEnum<{
238
238
  unknown: "unknown";
239
- "environment-fault": "environment-fault";
240
239
  failed: "failed";
240
+ "environment-fault": "environment-fault";
241
241
  }>;
242
242
  reason: z.ZodEnum<{
243
243
  none: "none";
@@ -1,4 +1,5 @@
1
1
  import type { DiagnosticsOperation, DiagnosticsStage, DiagnosticsOutcome, DiagnosticsReason, DiagnosticsRow, DiagnosticsSnapshot } from './diagnostics-types.ts';
2
+ import type { AutoSelectionExplanation } from './auto-model-routing.ts';
2
3
  export interface DiagnosticsHandle {
3
4
  stage(stage: DiagnosticsStage): void;
4
5
  finish(outcome: DiagnosticsOutcome, reason?: DiagnosticsReason): void;
@@ -14,7 +15,9 @@ export declare class DiagnosticsCollector {
14
15
  private data;
15
16
  private readonly live;
16
17
  private enabled;
18
+ private autoAllocationEnabled;
17
19
  private lastWall;
20
+ private readonly autoAllocation;
18
21
  constructor(version: string, layer: 'client' | 'host', changed?: () => void, wall?: () => number, mono?: () => number);
19
22
  restore(snapshot: DiagnosticsSnapshot): void;
20
23
  setEnabled(enabled: boolean): void;
@@ -31,6 +34,8 @@ export declare class DiagnosticsCollector {
31
34
  close(): void;
32
35
  noteDropped(): void;
33
36
  noteClientGaps(dropped: number, unconfirmed: number): void;
37
+ recordAutoAllocation(explanation: AutoSelectionExplanation): void;
38
+ setAutoAllocationEnabled(enabled: boolean): void;
34
39
  mergeClient(rows: readonly DiagnosticsRow[]): void;
35
40
  }
36
41
  //# sourceMappingURL=diagnostics-collector.d.ts.map
@@ -20,7 +20,7 @@ export declare const diagnosticsDomain: {
20
20
  layer: "client" | "host";
21
21
  operation: "compaction" | "account-global-switch" | "account-session-select" | "account-session-inherit" | "identity-read" | "identity-flight" | "compaction-summary" | "collection";
22
22
  stage: "ended" | "admitted" | "rpc-invoked" | "host-received" | "identity-validation" | "model-validation" | "cas" | "readback" | "response-received" | "decoded" | "client-settled" | "summary-attempt" | "checkpoint-committed" | "cache-hit" | "joined-flight" | "cooldown" | "dispatched";
23
- metric: "paused" | "unknown" | "started" | "stage" | "success" | "no-op" | "cancelled" | "policy-rejected" | "revoked" | "environment-fault" | "failed" | "interrupted" | "dropped" | "expired" | "clock-discontinuity" | "pending-sample";
23
+ metric: "paused" | "unknown" | "success" | "stage" | "failed" | "dropped" | "expired" | "started" | "no-op" | "cancelled" | "policy-rejected" | "revoked" | "environment-fault" | "interrupted" | "clock-discontinuity" | "pending-sample";
24
24
  reason: "none" | "COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE" | "COPILOT_ACCOUNTS_CHANGED" | "COPILOT_ACCOUNTS_BUSY" | "COPILOT_ACCOUNTS_CONFLICT" | "COPILOT_ACCOUNTS_COMMIT_UNCERTAIN" | "COPILOT_ACCOUNTS_MODELS_FAILED" | "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE" | "COPILOT_ACCOUNTS_IDENTITY_INVALID" | "COPILOT_ACCOUNTS_IDENTITY_TIMEOUT" | "COPILOT_ACCOUNTS_IDENTITY_TLS" | "COPILOT_ACCOUNTS_IDENTITY_NETWORK" | "COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED" | "COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED" | "COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR" | "unknown" | "rpc-unavailable" | "decode-invalid" | "COPILOT_SESSION_ACCOUNTS_UNAVAILABLE" | "COPILOT_SESSION_ACCOUNTS_SETTINGS_UNAVAILABLE" | "COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN" | "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH" | "CONTEXT_WINDOW_EXCEEDED" | "COPILOT_MANUAL_RECOVERY_FIXED_PREFIX" | "COPILOT_MANUAL_RECOVERY_INDIVISIBLE" | "COPILOT_MANUAL_RECOVERY_CALL_LIMIT" | "COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY" | "COPILOT_MANUAL_RECOVERY_UNBALANCED";
25
25
  bucket: number;
26
26
  count: number;
@@ -38,6 +38,45 @@ export declare const diagnosticsDomain: {
38
38
  saturated: number;
39
39
  evicted: number;
40
40
  interrupted: number;
41
+ autoAllocation?: {
42
+ status: "observed" | "not-collected";
43
+ rows: {
44
+ day: number;
45
+ version: string;
46
+ policyVersion: string;
47
+ modelId: string;
48
+ targetCategory: "powerful" | "versatile" | "lightweight";
49
+ category: "unknown" | "powerful" | "versatile" | "lightweight";
50
+ demand: "unknown" | "simple" | "routine" | "complex";
51
+ assessmentSource: "local" | "semantic";
52
+ method: "weighted-distribution" | "only-candidate";
53
+ fallback: boolean;
54
+ highCost: boolean;
55
+ previous: boolean;
56
+ weight: number;
57
+ opportunities: number;
58
+ expectedSelections: number;
59
+ selections: number;
60
+ }[];
61
+ noFitRows: {
62
+ day: number;
63
+ version: string;
64
+ policyVersion: string;
65
+ targetCategory: "powerful" | "versatile" | "lightweight";
66
+ category: "unknown" | "powerful" | "versatile" | "lightweight";
67
+ demand: "unknown" | "simple" | "routine" | "complex";
68
+ assessmentSource: "local" | "semantic";
69
+ decisions: number;
70
+ }[];
71
+ observationStart: number | null;
72
+ observationEnd: number | null;
73
+ completeHistory: false;
74
+ rowsTruncated: boolean;
75
+ dropped: number;
76
+ expired: number;
77
+ saturated: number;
78
+ restarts: number;
79
+ } | undefined;
41
80
  }>;
42
81
  };
43
82
  export declare function diagnosticsDomainForProfile(profileId: string): typeof diagnosticsDomain;
@@ -54,6 +93,7 @@ export declare class DiagnosticsController extends TypertRemoteService {
54
93
  private state;
55
94
  private problem;
56
95
  private enabled;
96
+ private autoAllocationEnabled;
57
97
  private dirty;
58
98
  private persistedAt;
59
99
  private revision;
@@ -66,6 +106,7 @@ export declare class DiagnosticsController extends TypertRemoteService {
66
106
  markCompactionCancelled(session: object): void;
67
107
  get(): DiagnosticsView;
68
108
  setEnabled(enabled: boolean): Promise<DiagnosticsView>;
109
+ setAutoAllocationEnabled(enabled: boolean): Promise<DiagnosticsView>;
69
110
  clear(): Promise<DiagnosticsView>;
70
111
  recordClient(batch: ClientDiagnosticsBatch): Promise<DiagnosticsView>;
71
112
  }
@@ -42,18 +42,18 @@ export declare const ClientDiagnosticsBatchSchema: z.ZodObject<{
42
42
  metric: z.ZodEnum<{
43
43
  paused: "paused";
44
44
  unknown: "unknown";
45
- started: "started";
46
- stage: "stage";
47
45
  success: "success";
46
+ stage: "stage";
47
+ failed: "failed";
48
+ dropped: "dropped";
49
+ expired: "expired";
50
+ started: "started";
48
51
  "no-op": "no-op";
49
52
  cancelled: "cancelled";
50
53
  "policy-rejected": "policy-rejected";
51
54
  revoked: "revoked";
52
55
  "environment-fault": "environment-fault";
53
- failed: "failed";
54
56
  interrupted: "interrupted";
55
- dropped: "dropped";
56
- expired: "expired";
57
57
  "clock-discontinuity": "clock-discontinuity";
58
58
  "pending-sample": "pending-sample";
59
59
  }>;
@@ -99,6 +99,7 @@ declare module '@deepseek-ai/dsh-typert-protocol' {
99
99
  githubCopilotDiagnostics: {
100
100
  get(): Promise<RemoteResult<DiagnosticsView>>;
101
101
  setEnabled(enabled: boolean): Promise<RemoteResult<DiagnosticsView>>;
102
+ setAutoAllocationEnabled(enabled: boolean): Promise<RemoteResult<DiagnosticsView>>;
102
103
  clear(): Promise<RemoteResult<DiagnosticsView>>;
103
104
  recordClient(batch: ClientDiagnosticsBatch): Promise<RemoteResult<DiagnosticsView>>;
104
105
  };
@@ -46,18 +46,18 @@ export declare const DiagnosticsRowSchema: z.ZodObject<{
46
46
  metric: z.ZodEnum<{
47
47
  paused: "paused";
48
48
  unknown: "unknown";
49
- started: "started";
50
- stage: "stage";
51
49
  success: "success";
50
+ stage: "stage";
51
+ failed: "failed";
52
+ dropped: "dropped";
53
+ expired: "expired";
54
+ started: "started";
52
55
  "no-op": "no-op";
53
56
  cancelled: "cancelled";
54
57
  "policy-rejected": "policy-rejected";
55
58
  revoked: "revoked";
56
59
  "environment-fault": "environment-fault";
57
- failed: "failed";
58
60
  interrupted: "interrupted";
59
- dropped: "dropped";
60
- expired: "expired";
61
61
  "clock-discontinuity": "clock-discontinuity";
62
62
  "pending-sample": "pending-sample";
63
63
  }>;
@@ -172,18 +172,18 @@ export declare const DiagnosticsSnapshotSchema: z.ZodObject<{
172
172
  metric: z.ZodEnum<{
173
173
  paused: "paused";
174
174
  unknown: "unknown";
175
- started: "started";
176
- stage: "stage";
177
175
  success: "success";
176
+ stage: "stage";
177
+ failed: "failed";
178
+ dropped: "dropped";
179
+ expired: "expired";
180
+ started: "started";
178
181
  "no-op": "no-op";
179
182
  cancelled: "cancelled";
180
183
  "policy-rejected": "policy-rejected";
181
184
  revoked: "revoked";
182
185
  "environment-fault": "environment-fault";
183
- failed: "failed";
184
186
  interrupted: "interrupted";
185
- dropped: "dropped";
186
- expired: "expired";
187
187
  "clock-discontinuity": "clock-discontinuity";
188
188
  "pending-sample": "pending-sample";
189
189
  }>;
@@ -220,6 +220,85 @@ export declare const DiagnosticsSnapshotSchema: z.ZodObject<{
220
220
  bucket: z.ZodNumber;
221
221
  count: z.ZodNumber;
222
222
  }, z.core.$strict>>;
223
+ autoAllocation: z.ZodOptional<z.ZodObject<{
224
+ status: z.ZodEnum<{
225
+ observed: "observed";
226
+ "not-collected": "not-collected";
227
+ }>;
228
+ rows: z.ZodArray<z.ZodObject<{
229
+ day: z.ZodNumber;
230
+ version: z.ZodString;
231
+ policyVersion: z.ZodString;
232
+ modelId: z.ZodString;
233
+ targetCategory: z.ZodEnum<{
234
+ powerful: "powerful";
235
+ versatile: "versatile";
236
+ lightweight: "lightweight";
237
+ }>;
238
+ category: z.ZodEnum<{
239
+ unknown: "unknown";
240
+ powerful: "powerful";
241
+ versatile: "versatile";
242
+ lightweight: "lightweight";
243
+ }>;
244
+ demand: z.ZodEnum<{
245
+ unknown: "unknown";
246
+ simple: "simple";
247
+ routine: "routine";
248
+ complex: "complex";
249
+ }>;
250
+ assessmentSource: z.ZodEnum<{
251
+ local: "local";
252
+ semantic: "semantic";
253
+ }>;
254
+ method: z.ZodEnum<{
255
+ "weighted-distribution": "weighted-distribution";
256
+ "only-candidate": "only-candidate";
257
+ }>;
258
+ fallback: z.ZodBoolean;
259
+ highCost: z.ZodBoolean;
260
+ previous: z.ZodBoolean;
261
+ weight: z.ZodNumber;
262
+ opportunities: z.ZodNumber;
263
+ expectedSelections: z.ZodNumber;
264
+ selections: z.ZodNumber;
265
+ }, z.core.$strict>>;
266
+ noFitRows: z.ZodArray<z.ZodObject<{
267
+ day: z.ZodNumber;
268
+ version: z.ZodString;
269
+ policyVersion: z.ZodString;
270
+ targetCategory: z.ZodEnum<{
271
+ powerful: "powerful";
272
+ versatile: "versatile";
273
+ lightweight: "lightweight";
274
+ }>;
275
+ category: z.ZodEnum<{
276
+ unknown: "unknown";
277
+ powerful: "powerful";
278
+ versatile: "versatile";
279
+ lightweight: "lightweight";
280
+ }>;
281
+ demand: z.ZodEnum<{
282
+ unknown: "unknown";
283
+ simple: "simple";
284
+ routine: "routine";
285
+ complex: "complex";
286
+ }>;
287
+ assessmentSource: z.ZodEnum<{
288
+ local: "local";
289
+ semantic: "semantic";
290
+ }>;
291
+ decisions: z.ZodNumber;
292
+ }, z.core.$strict>>;
293
+ observationStart: z.ZodNullable<z.ZodNumber>;
294
+ observationEnd: z.ZodNullable<z.ZodNumber>;
295
+ completeHistory: z.ZodLiteral<false>;
296
+ rowsTruncated: z.ZodBoolean;
297
+ dropped: z.ZodNumber;
298
+ expired: z.ZodNumber;
299
+ saturated: z.ZodNumber;
300
+ restarts: z.ZodNumber;
301
+ }, z.core.$strict>>;
223
302
  pending: z.ZodArray<z.ZodObject<{
224
303
  version: z.ZodString;
225
304
  operation: z.ZodEnum<{
@@ -263,6 +342,7 @@ export declare const DiagnosticsSnapshotSchema: z.ZodObject<{
263
342
  }, z.core.$strict>;
264
343
  export declare const DiagnosticsViewSchema: z.ZodObject<{
265
344
  enabled: z.ZodBoolean;
345
+ autoAllocationEnabled: z.ZodBoolean;
266
346
  state: z.ZodEnum<{
267
347
  error: "error";
268
348
  ready: "ready";
@@ -327,18 +407,18 @@ export declare const DiagnosticsViewSchema: z.ZodObject<{
327
407
  metric: z.ZodEnum<{
328
408
  paused: "paused";
329
409
  unknown: "unknown";
330
- started: "started";
331
- stage: "stage";
332
410
  success: "success";
411
+ stage: "stage";
412
+ failed: "failed";
413
+ dropped: "dropped";
414
+ expired: "expired";
415
+ started: "started";
333
416
  "no-op": "no-op";
334
417
  cancelled: "cancelled";
335
418
  "policy-rejected": "policy-rejected";
336
419
  revoked: "revoked";
337
420
  "environment-fault": "environment-fault";
338
- failed: "failed";
339
421
  interrupted: "interrupted";
340
- dropped: "dropped";
341
- expired: "expired";
342
422
  "clock-discontinuity": "clock-discontinuity";
343
423
  "pending-sample": "pending-sample";
344
424
  }>;
@@ -375,6 +455,85 @@ export declare const DiagnosticsViewSchema: z.ZodObject<{
375
455
  bucket: z.ZodNumber;
376
456
  count: z.ZodNumber;
377
457
  }, z.core.$strict>>;
458
+ autoAllocation: z.ZodOptional<z.ZodObject<{
459
+ status: z.ZodEnum<{
460
+ observed: "observed";
461
+ "not-collected": "not-collected";
462
+ }>;
463
+ rows: z.ZodArray<z.ZodObject<{
464
+ day: z.ZodNumber;
465
+ version: z.ZodString;
466
+ policyVersion: z.ZodString;
467
+ modelId: z.ZodString;
468
+ targetCategory: z.ZodEnum<{
469
+ powerful: "powerful";
470
+ versatile: "versatile";
471
+ lightweight: "lightweight";
472
+ }>;
473
+ category: z.ZodEnum<{
474
+ unknown: "unknown";
475
+ powerful: "powerful";
476
+ versatile: "versatile";
477
+ lightweight: "lightweight";
478
+ }>;
479
+ demand: z.ZodEnum<{
480
+ unknown: "unknown";
481
+ simple: "simple";
482
+ routine: "routine";
483
+ complex: "complex";
484
+ }>;
485
+ assessmentSource: z.ZodEnum<{
486
+ local: "local";
487
+ semantic: "semantic";
488
+ }>;
489
+ method: z.ZodEnum<{
490
+ "weighted-distribution": "weighted-distribution";
491
+ "only-candidate": "only-candidate";
492
+ }>;
493
+ fallback: z.ZodBoolean;
494
+ highCost: z.ZodBoolean;
495
+ previous: z.ZodBoolean;
496
+ weight: z.ZodNumber;
497
+ opportunities: z.ZodNumber;
498
+ expectedSelections: z.ZodNumber;
499
+ selections: z.ZodNumber;
500
+ }, z.core.$strict>>;
501
+ noFitRows: z.ZodArray<z.ZodObject<{
502
+ day: z.ZodNumber;
503
+ version: z.ZodString;
504
+ policyVersion: z.ZodString;
505
+ targetCategory: z.ZodEnum<{
506
+ powerful: "powerful";
507
+ versatile: "versatile";
508
+ lightweight: "lightweight";
509
+ }>;
510
+ category: z.ZodEnum<{
511
+ unknown: "unknown";
512
+ powerful: "powerful";
513
+ versatile: "versatile";
514
+ lightweight: "lightweight";
515
+ }>;
516
+ demand: z.ZodEnum<{
517
+ unknown: "unknown";
518
+ simple: "simple";
519
+ routine: "routine";
520
+ complex: "complex";
521
+ }>;
522
+ assessmentSource: z.ZodEnum<{
523
+ local: "local";
524
+ semantic: "semantic";
525
+ }>;
526
+ decisions: z.ZodNumber;
527
+ }, z.core.$strict>>;
528
+ observationStart: z.ZodNullable<z.ZodNumber>;
529
+ observationEnd: z.ZodNullable<z.ZodNumber>;
530
+ completeHistory: z.ZodLiteral<false>;
531
+ rowsTruncated: z.ZodBoolean;
532
+ dropped: z.ZodNumber;
533
+ expired: z.ZodNumber;
534
+ saturated: z.ZodNumber;
535
+ restarts: z.ZodNumber;
536
+ }, z.core.$strict>>;
378
537
  pending: z.ZodArray<z.ZodObject<{
379
538
  version: z.ZodString;
380
539
  operation: z.ZodEnum<{
@@ -4,8 +4,8 @@ export declare const CompactionContinuationStatusSchema: z.ZodObject<{
4
4
  id: z.ZodString;
5
5
  state: z.ZodEnum<{
6
6
  running: "running";
7
- cancelled: "cancelled";
8
7
  failed: "failed";
8
+ cancelled: "cancelled";
9
9
  completed: "completed";
10
10
  blocked: "blocked";
11
11
  }>;
@@ -51,8 +51,8 @@ export declare const SessionContinuationViewSchema: z.ZodObject<{
51
51
  id: z.ZodString;
52
52
  state: z.ZodEnum<{
53
53
  running: "running";
54
- cancelled: "cancelled";
55
54
  failed: "failed";
55
+ cancelled: "cancelled";
56
56
  completed: "completed";
57
57
  blocked: "blocked";
58
58
  }>;
@@ -45,10 +45,10 @@ export declare const TurnSelectionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
45
45
  diagnostic: z.ZodOptional<z.ZodEnum<{
46
46
  disabled: "disabled";
47
47
  unavailable: "unavailable";
48
- failed: "failed";
49
48
  "context-omitted": "context-omitted";
50
49
  "invalid-result": "invalid-result";
51
50
  timeout: "timeout";
51
+ failed: "failed";
52
52
  }>>;
53
53
  semantic: z.ZodOptional<z.ZodObject<{
54
54
  modelId: z.ZodOptional<z.ZodString>;
@@ -123,8 +123,10 @@ export type TurnSelection = {
123
123
  };
124
124
  /** Ephemeral decision evidence only; never session content, model usage or credentials. */
125
125
  export declare class TurnSelectionStore {
126
+ private readonly onAutoDecision?;
126
127
  private readonly agents;
127
128
  private timestamps;
129
+ constructor(onAutoDecision?: ((explanation: AutoSelectionExplanation) => void) | undefined);
128
130
  record(agent: object, turn: number, selection: TurnSelection): void;
129
131
  get(agent: object, turn: number): TurnSelection;
130
132
  allocationSummary(agent: object): AutoAllocationSummary;
package/package.json CHANGED
@@ -1,12 +1,12 @@
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.1",
4
+ "version": "0.4.2-alpha.2",
5
5
  "releaseNotes": "CHANGELOG.md",
6
6
  "publishConfig": {
7
7
  "access": "public",
8
8
  "registry": "https://registry.npmjs.org/",
9
- "tag": "latest"
9
+ "tag": "alpha"
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
@@ -1,182 +0,0 @@
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 };