dsh-github-copilot 0.4.0-alpha.98 → 0.4.0

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.
Files changed (110) hide show
  1. package/AGENTS.md +97 -17
  2. package/CHANGELOG.md +217 -0
  3. package/CONTRIBUTING.md +9 -0
  4. package/README.md +108 -18
  5. package/README.zh.md +99 -18
  6. package/deployment-baseline.json +234 -8
  7. package/docs/account-management-experience.md +143 -0
  8. package/docs/auto-high-cost.md +154 -0
  9. package/docs/auto-iteration-review.json +22 -0
  10. package/docs/auto-review-sampling.md +60 -0
  11. package/docs/auto-task-routing.md +23 -7
  12. package/docs/automatic-model-routing.md +33 -5
  13. package/docs/copilot-accounts.md +376 -0
  14. package/docs/copilot-compaction.md +23 -2
  15. package/docs/copilot-usage.md +24 -4
  16. package/docs/evidence-driven-iteration.md +86 -0
  17. package/docs/images/copilot-accounts-credits.png +0 -0
  18. package/docs/images/copilot-accounts.png +0 -0
  19. package/docs/images/copilot-current-provenance.json +39 -0
  20. package/docs/images/copilot-model-preferences.png +0 -0
  21. package/docs/images/copilot-search-routing.png +0 -0
  22. package/docs/images/copilot-session-continuation.png +0 -0
  23. package/docs/manual-compaction-recovery.md +50 -7
  24. package/docs/mockups/copilot-account-dropdown.html +71 -0
  25. package/docs/mockups/copilot-account-management.html +393 -0
  26. package/docs/model-compatibility-acceptance.md +34 -16
  27. package/docs/official-first-020-rc2.md +1 -0
  28. package/docs/plugin-diagnostics.md +452 -0
  29. package/docs/session-continuation.md +141 -0
  30. package/docs/session-search-routing.md +1 -1
  31. package/docs/single-route-migration.md +5 -4
  32. package/lib/client.js +4415 -846
  33. package/lib/client.js.map +1 -1
  34. package/lib/diagnostics-analysis-io.js +78 -0
  35. package/lib/diagnostics-analysis.js +425 -0
  36. package/lib/diagnostics-types-FVf6zjob.js +182 -0
  37. package/lib/index.js +10391 -6015
  38. package/lib/manual-compaction-recovery.js +163 -38
  39. package/lib/remote.js +593 -34
  40. package/lib/routed-web.js +1 -1
  41. package/lib/{search-routing-jzNYveyK.js → search-routing-CV2hs8as.js} +139 -139
  42. package/lib/types/account-dropdown.d.ts +22 -0
  43. package/lib/types/account-model-auth.d.ts +1 -1
  44. package/lib/types/authorization-code-clipboard.d.ts +4 -0
  45. package/lib/types/authorization-controller.d.ts +2 -0
  46. package/lib/types/auto-allocation-card.d.ts +9 -0
  47. package/lib/types/auto-allocation-evidence.d.ts +38 -0
  48. package/lib/types/auto-allocation.d.ts +24 -0
  49. package/lib/types/auto-model-host.d.ts +2 -0
  50. package/lib/types/auto-model-routing.d.ts +6 -2
  51. package/lib/types/auto-review-sampling.d.ts +6 -0
  52. package/lib/types/auto-task-assessment.d.ts +1 -1
  53. package/lib/types/auto-task-classifier.d.ts +2 -2
  54. package/lib/types/background-compaction.d.ts +2 -2
  55. package/lib/types/client.d.ts +19 -3
  56. package/lib/types/compaction-continuation-ui.d.ts +29 -0
  57. package/lib/types/compaction-continuation.d.ts +48 -0
  58. package/lib/types/compaction-input-estimate.d.ts +24 -0
  59. package/lib/types/compaction-replay.d.ts +18 -0
  60. package/lib/types/composer-notice-style.d.ts +7 -0
  61. package/lib/types/config.d.ts +42 -2
  62. package/lib/types/context-evidence-ui.d.ts +18 -1
  63. package/lib/types/context-evidence.d.ts +152 -4
  64. package/lib/types/copilot-account-presentation.d.ts +7 -0
  65. package/lib/types/copilot-accounts-card.d.ts +43 -0
  66. package/lib/types/copilot-accounts-host.d.ts +93 -0
  67. package/lib/types/copilot-accounts-remote.d.ts +85 -0
  68. package/lib/types/copilot-accounts-types.d.ts +43 -0
  69. package/lib/types/copilot-auth.d.ts +3 -1
  70. package/lib/types/copilot-usage-card.d.ts +23 -0
  71. package/lib/types/copilot-usage-host.d.ts +9 -1
  72. package/lib/types/copilot-usage-remote.d.ts +2 -1
  73. package/lib/types/copilot-usage-types.d.ts +1 -0
  74. package/lib/types/diagnostics-analysis-io.d.ts +23 -0
  75. package/lib/types/diagnostics-analysis.d.ts +295 -0
  76. package/lib/types/diagnostics-card.d.ts +11 -0
  77. package/lib/types/diagnostics-client.d.ts +13 -0
  78. package/lib/types/diagnostics-collector.d.ts +36 -0
  79. package/lib/types/diagnostics-host.d.ts +72 -0
  80. package/lib/types/diagnostics-remote.d.ts +109 -0
  81. package/lib/types/diagnostics-types.d.ts +431 -0
  82. package/lib/types/manual-compaction-recovery.d.ts +18 -3
  83. package/lib/types/model-preferences-card.d.ts +1 -1
  84. package/lib/types/native-settings-style.d.ts +10 -0
  85. package/lib/types/parent-model-follow-card.d.ts +2 -11
  86. package/lib/types/preview-provider.d.ts +6 -0
  87. package/lib/types/preview-route.d.ts +7 -5
  88. package/lib/types/remote.d.ts +9 -6
  89. package/lib/types/replay-recovery-host.d.ts +2 -2
  90. package/lib/types/replay-recovery-ui.d.ts +3 -1
  91. package/lib/types/request-body-evidence.d.ts +3 -1
  92. package/lib/types/responses-replay-compat.d.ts +2 -1
  93. package/lib/types/responses-request-compression.d.ts +33 -0
  94. package/lib/types/session-accounts-controller.d.ts +20 -0
  95. package/lib/types/session-accounts-host.d.ts +33 -0
  96. package/lib/types/session-accounts-remote.d.ts +114 -0
  97. package/lib/types/session-accounts.d.ts +38 -0
  98. package/lib/types/session-continuation-host.d.ts +45 -0
  99. package/lib/types/session-continuation-remote.d.ts +22 -0
  100. package/lib/types/session-continuation-types.d.ts +62 -0
  101. package/lib/types/session-continuation-ui.d.ts +49 -0
  102. package/lib/types/session-continuation.d.ts +14 -0
  103. package/lib/types/turn-request-models.d.ts +55 -0
  104. package/lib/types/turn-selection-card.d.ts +15 -1
  105. package/lib/types/turn-selection-host.d.ts +23 -0
  106. package/lib/types/turn-selection-remote.d.ts +4 -0
  107. package/lib/types/turn-selection.d.ts +19 -4
  108. package/package.json +19 -3
  109. package/scripts/analyze-diagnostics.mjs +91 -0
  110. package/scripts/iteration-review.mjs +53 -0
package/lib/remote.js CHANGED
@@ -12,7 +12,7 @@ function strictRemoteCodec(typeSymbol, schema) {
12
12
  //#endregion
13
13
  //#region lib/types/dual-model-remote.js
14
14
  const id = z.string().min(1).max(512);
15
- const revision = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
15
+ const revision$1 = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
16
16
  const DualModelConfigSchema = z.object({
17
17
  enabled: z.boolean(),
18
18
  plannerModel: z.string().max(512),
@@ -22,7 +22,7 @@ const DualModelViewSchema = z.object({
22
22
  supported: z.boolean(),
23
23
  diagnostic: z.string().min(1).max(128).optional(),
24
24
  writable: z.boolean(),
25
- revision: revision.nullable(),
25
+ revision: revision$1.nullable(),
26
26
  configuration: DualModelConfigSchema,
27
27
  models: z.array(z.object({
28
28
  id,
@@ -35,15 +35,15 @@ const DualModelViewSchema = z.object({
35
35
  }).strict();
36
36
  const DualModelSaveSchema = z.object({
37
37
  configuration: DualModelConfigSchema,
38
- expectedRevision: revision
38
+ expectedRevision: revision$1
39
39
  }).strict();
40
40
  const DualModelCreateSchema = z.object({
41
41
  requestId: z.string().uuid(),
42
42
  workspaceId: id,
43
- expectedRevision: revision
43
+ expectedRevision: revision$1
44
44
  }).strict();
45
45
  const DualModelCreateResultSchema = z.object({ sessionId: id }).strict();
46
- const contribution$5 = {
46
+ const contribution$9 = {
47
47
  package: "dsh-github-copilot",
48
48
  descriptors: [
49
49
  {
@@ -85,7 +85,7 @@ const contribution$5 = {
85
85
  }
86
86
  ]
87
87
  };
88
- const contribution$4 = {
88
+ const contribution$8 = {
89
89
  package: "dsh-github-copilot",
90
90
  descriptors: [{
91
91
  id: "dsh-github-copilot:githubCopilotSearchRouting.providers",
@@ -128,10 +128,45 @@ const COPILOT_USAGE_DIAGNOSTICS = [
128
128
  "COPILOT_USAGE_RATE_LIMITED"
129
129
  ];
130
130
  //#endregion
131
+ //#region lib/types/copilot-accounts-types.js
132
+ const COPILOT_ACCOUNT_ID_PATTERN = /^(?:canonical|[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$/u;
133
+ const GITHUB_ACCOUNT_LOGIN_PATTERN = /^[a-zA-Z0-9](?:[a-zA-Z0-9_-]*[a-zA-Z0-9])?$/u;
134
+ const COPILOT_ACCOUNTS_DIAGNOSTICS = [
135
+ "COPILOT_ACCOUNTS_SELECTOR_INVALID",
136
+ "COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE",
137
+ "COPILOT_ACCOUNTS_SELECTED_MISSING",
138
+ "COPILOT_ACCOUNTS_CREDENTIALS_UNAVAILABLE",
139
+ "COPILOT_ACCOUNTS_CHANGED",
140
+ "COPILOT_ACCOUNTS_BUSY",
141
+ "COPILOT_ACCOUNTS_CONFLICT",
142
+ "COPILOT_ACCOUNTS_COMMIT_UNCERTAIN",
143
+ "COPILOT_ACCOUNTS_MODELS_FAILED",
144
+ "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE",
145
+ "COPILOT_ACCOUNTS_IDENTITY_INVALID",
146
+ "COPILOT_ACCOUNTS_IDENTITY_TIMEOUT",
147
+ "COPILOT_ACCOUNTS_IDENTITY_TLS",
148
+ "COPILOT_ACCOUNTS_IDENTITY_NETWORK",
149
+ "COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED",
150
+ "COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED",
151
+ "COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR",
152
+ "COPILOT_ACCOUNTS_IDENTITY_CHANGED",
153
+ "COPILOT_ACCOUNTS_DUPLICATE",
154
+ "COPILOT_ACCOUNTS_ENTERPRISE_UNSUPPORTED",
155
+ "COPILOT_ACCOUNTS_ROUTE_BLOCKED",
156
+ "COPILOT_ACCOUNTS_EVIDENCE_INCOMPLETE",
157
+ "COPILOT_ACCOUNTS_LIMIT",
158
+ "COPILOT_ACCOUNTS_AUTH_FAILED",
159
+ "COPILOT_ACCOUNTS_AUTH_UNAVAILABLE",
160
+ "COPILOT_ACCOUNTS_ACTIVE_REMOVE_BLOCKED",
161
+ "COPILOT_ACCOUNTS_REMOVE_FAILED",
162
+ "COPILOT_ACCOUNTS_DISPOSED"
163
+ ];
164
+ //#endregion
131
165
  //#region lib/types/copilot-usage-remote.js
132
166
  const amount = z.number().finite().nonnegative().max(COPILOT_USAGE_MAX_AMOUNT);
133
167
  const timestamp = z.number().int().nonnegative().max(COPILOT_USAGE_MAX_TIMESTAMP);
134
168
  const CopilotUsageViewSchema = z.object({
169
+ accountId: z.string().max(36).regex(COPILOT_ACCOUNT_ID_PATTERN).optional(),
135
170
  state: z.enum([
136
171
  "ready",
137
172
  "stale",
@@ -181,7 +216,7 @@ const CopilotUsageViewSchema = z.object({
181
216
  if (view.remaining !== void 0 && view.percentUsed !== void 0 && Math.abs((1 - view.remaining / view.limit) * 100 - view.percentUsed) > 1) invalid();
182
217
  }
183
218
  });
184
- const contribution$3 = {
219
+ const contribution$7 = {
185
220
  package: "dsh-github-copilot",
186
221
  descriptors: ["get", "refresh"].map((method) => ({
187
222
  id: `dsh-github-copilot:githubCopilotUsage.${method}`,
@@ -251,6 +286,51 @@ const TaskAssessmentSchema = z.object({
251
286
  ])).max(7)
252
287
  }).strict();
253
288
  //#endregion
289
+ //#region lib/types/auto-allocation.js
290
+ const AUTO_ALLOCATION_POLICY = "high-cost-v1";
291
+ const AutoAllocationSchema = z.object({
292
+ policyVersion: z.literal(AUTO_ALLOCATION_POLICY),
293
+ selectedModelId: z.string().min(1).max(512),
294
+ candidates: z.array(z.object({
295
+ modelId: z.string().min(1).max(512),
296
+ highCost: z.boolean(),
297
+ previous: z.boolean(),
298
+ weight: z.number().positive().max(1.5),
299
+ expectedShare: z.number().positive().max(1)
300
+ }).strict()).min(1).max(512)
301
+ }).strict().refine((value) => {
302
+ const total = value.candidates.reduce((sum, row) => sum + row.weight, 0);
303
+ return new Set(value.candidates.map((row) => row.modelId)).size === value.candidates.length && value.candidates.some((row) => row.modelId === value.selectedModelId) && value.candidates.filter((row) => row.previous).length <= 1 && value.candidates.every((row) => row.weight === (row.highCost ? 2 : 10) * (row.previous ? 1.5 : 1) / 10 && Math.abs(row.expectedShare - row.weight / total) <= 1e-12);
304
+ }, { message: "Invalid allocation policy evidence" });
305
+ //#endregion
306
+ //#region lib/types/auto-allocation-evidence.js
307
+ const AutoAllocationSummarySchema = z.object({
308
+ policyVersion: z.literal(AUTO_ALLOCATION_POLICY),
309
+ scope: z.literal("viewed-session-host-lifetime"),
310
+ status: z.enum(["observed", "not-collected"]),
311
+ retainedDecisions: z.number().int().nonnegative().max(128),
312
+ noFitDecisions: z.number().int().nonnegative().max(128),
313
+ rowsTruncated: z.boolean(),
314
+ completeHistory: z.literal(false),
315
+ observationStart: z.number().int().nonnegative().nullable(),
316
+ observationEnd: z.number().int().nonnegative().nullable(),
317
+ rows: z.array(z.object({
318
+ modelId: z.string().min(1).max(512),
319
+ category: z.enum([
320
+ "powerful",
321
+ "versatile",
322
+ "lightweight",
323
+ "unknown"
324
+ ]),
325
+ highCost: z.boolean(),
326
+ previous: z.boolean(),
327
+ weight: z.number().positive().max(1.5),
328
+ opportunities: z.number().int().positive().max(128),
329
+ expectedSelections: z.number().nonnegative().max(128),
330
+ selections: z.number().int().nonnegative().max(128)
331
+ }).strict()).max(512)
332
+ }).strict();
333
+ //#endregion
254
334
  //#region lib/types/turn-selection.js
255
335
  const ExplanationSchema = z.object({
256
336
  assessment: TaskAssessmentSchema.extend({
@@ -280,10 +360,12 @@ const ExplanationSchema = z.object({
280
360
  method: z.enum([
281
361
  "continuity",
282
362
  "equal-distribution",
363
+ "weighted-distribution",
283
364
  "only-candidate",
284
365
  "no-fit"
285
366
  ]),
286
- fallback: z.boolean()
367
+ fallback: z.boolean(),
368
+ allocation: AutoAllocationSchema.optional()
287
369
  }).strict();
288
370
  const TurnSelectionSchema = z.discriminatedUnion("mode", [
289
371
  z.object({ mode: z.literal("unknown") }).strict(),
@@ -307,29 +389,85 @@ const TurnSelectionSchema = z.discriminatedUnion("mode", [
307
389
  }).strict()
308
390
  ]);
309
391
  //#endregion
392
+ //#region lib/types/turn-request-models.js
393
+ const count = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
394
+ const route = z.object({
395
+ provider: z.string().trim().min(1).max(1024),
396
+ model: z.string().trim().min(1).max(1024)
397
+ }).strict();
398
+ const RequestedModelsSchema = z.object({
399
+ routes: z.array(route).max(32),
400
+ incomplete: z.boolean()
401
+ }).strict();
402
+ const row = RequestedModelsSchema.extend({ turn: count }).strict();
403
+ z.object({
404
+ active: z.object({
405
+ turn: count,
406
+ step: count.nullable()
407
+ }).strict().nullable(),
408
+ turns: z.array(row).max(128)
409
+ }).strict();
410
+ //#endregion
310
411
  //#region lib/types/turn-selection-remote.js
311
- const contribution$2 = {
412
+ const contribution$6 = {
312
413
  package: "dsh-github-copilot",
313
- descriptors: [{
314
- id: "dsh-github-copilot:githubCopilotTurnSelection.get",
315
- namespace: "githubCopilotTurnSelection",
316
- service: "githubCopilotTurnSelection",
317
- method: "get",
318
- invocation: { kind: "direct" },
319
- parameters: [{
320
- name: "agent",
321
- wire: "agentId",
322
- source: "lookup",
323
- lookup: "agent",
324
- codec: strictRemoteCodec("@deepseek-ai/dsh-session/types#SessionId", z.string().min(1).max(256))
325
- }, {
326
- name: "turn",
327
- wire: "turn",
328
- source: "json",
329
- codec: strictRemoteCodec("dsh-github-copilot#TurnSelectionTurn", z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER))
330
- }],
331
- result: strictRemoteCodec("dsh-github-copilot#TurnSelection", TurnSelectionSchema)
332
- }]
414
+ descriptors: [
415
+ {
416
+ id: "dsh-github-copilot:githubCopilotTurnSelection.get",
417
+ namespace: "githubCopilotTurnSelection",
418
+ service: "githubCopilotTurnSelection",
419
+ method: "get",
420
+ invocation: { kind: "direct" },
421
+ parameters: [{
422
+ name: "agent",
423
+ wire: "agentId",
424
+ source: "lookup",
425
+ lookup: "agent",
426
+ codec: strictRemoteCodec("@deepseek-ai/dsh-session/types#SessionId", z.string().min(1).max(256))
427
+ }, {
428
+ name: "turn",
429
+ wire: "turn",
430
+ source: "json",
431
+ codec: strictRemoteCodec("dsh-github-copilot#TurnSelectionTurn", z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER))
432
+ }],
433
+ result: strictRemoteCodec("dsh-github-copilot#TurnSelection", TurnSelectionSchema)
434
+ },
435
+ {
436
+ id: "dsh-github-copilot:githubCopilotTurnSelection.requestedModels",
437
+ namespace: "githubCopilotTurnSelection",
438
+ service: "githubCopilotTurnSelection",
439
+ method: "requestedModels",
440
+ invocation: { kind: "direct" },
441
+ parameters: [{
442
+ name: "agent",
443
+ wire: "agentId",
444
+ source: "lookup",
445
+ lookup: "agent",
446
+ codec: strictRemoteCodec("@deepseek-ai/dsh-session/types#SessionId", z.string().min(1).max(256))
447
+ }, {
448
+ name: "turn",
449
+ wire: "turn",
450
+ source: "json",
451
+ codec: strictRemoteCodec("dsh-github-copilot#TurnSelectionTurn", z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER))
452
+ }],
453
+ result: strictRemoteCodec("dsh-github-copilot#RequestedModels", RequestedModelsSchema)
454
+ },
455
+ {
456
+ id: "dsh-github-copilot:githubCopilotTurnSelection.allocationSummary",
457
+ namespace: "githubCopilotTurnSelection",
458
+ service: "githubCopilotTurnSelection",
459
+ method: "allocationSummary",
460
+ invocation: { kind: "direct" },
461
+ parameters: [{
462
+ name: "agent",
463
+ wire: "agentId",
464
+ source: "lookup",
465
+ lookup: "agent",
466
+ codec: strictRemoteCodec("@deepseek-ai/dsh-session/types#SessionId", z.string().min(1).max(256))
467
+ }],
468
+ result: strictRemoteCodec("dsh-github-copilot#AutoAllocationSummary", AutoAllocationSummarySchema)
469
+ }
470
+ ]
333
471
  };
334
472
  //#endregion
335
473
  //#region lib/types/replay-recovery-types.js
@@ -344,14 +482,14 @@ const ReplayRecoveryViewSchema = z.discriminatedUnion("state", [z.object({ state
344
482
  }).strict()]);
345
483
  //#endregion
346
484
  //#region lib/types/replay-recovery-remote.js
347
- const agent = {
485
+ const agent$1 = {
348
486
  name: "agent",
349
487
  wire: "agentId",
350
488
  source: "lookup",
351
489
  lookup: "agent",
352
490
  codec: strictRemoteCodec("@deepseek-ai/dsh-session/types#SessionId", z.string().min(1).max(256))
353
491
  };
354
- const contribution$1 = {
492
+ const contribution$5 = {
355
493
  package: "dsh-github-copilot",
356
494
  descriptors: [
357
495
  {
@@ -360,7 +498,7 @@ const contribution$1 = {
360
498
  service: "githubCopilotReplayRecovery",
361
499
  method: "get",
362
500
  invocation: { kind: "direct" },
363
- parameters: [agent],
501
+ parameters: [agent$1],
364
502
  result: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryView", ReplayRecoveryViewSchema)
365
503
  },
366
504
  {
@@ -370,7 +508,7 @@ const contribution$1 = {
370
508
  method: "authorize",
371
509
  invocation: { kind: "direct" },
372
510
  parameters: [
373
- agent,
511
+ agent$1,
374
512
  {
375
513
  name: "revision",
376
514
  wire: "revision",
@@ -393,7 +531,7 @@ const contribution$1 = {
393
531
  method: "setEnabled",
394
532
  invocation: { kind: "direct" },
395
533
  parameters: [
396
- agent,
534
+ agent$1,
397
535
  {
398
536
  name: "revision",
399
537
  wire: "revision",
@@ -412,6 +550,403 @@ const contribution$1 = {
412
550
  ]
413
551
  };
414
552
  //#endregion
553
+ //#region lib/types/copilot-accounts-remote.js
554
+ const CopilotAccountIdSchema = z.string().max(36).regex(COPILOT_ACCOUNT_ID_PATTERN);
555
+ const revision = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
556
+ const CopilotAccountsViewSchema = z.object({
557
+ state: z.enum(["ready", "error"]),
558
+ activeAccountId: CopilotAccountIdSchema,
559
+ revision: revision.optional(),
560
+ writable: z.boolean(),
561
+ switchable: z.boolean(),
562
+ accounts: z.array(z.object({
563
+ id: CopilotAccountIdSchema,
564
+ configured: z.boolean(),
565
+ identityState: z.enum([
566
+ "ready",
567
+ "unavailable",
568
+ "unknown"
569
+ ]),
570
+ identity: z.object({
571
+ login: z.string().min(1).max(39).regex(GITHUB_ACCOUNT_LOGIN_PATTERN),
572
+ userId: z.number().int().positive().max(Number.MAX_SAFE_INTEGER)
573
+ }).strict().optional()
574
+ }).strict()).max(32),
575
+ operation: z.enum([
576
+ "authorizing",
577
+ "verifying",
578
+ "switching"
579
+ ]).optional(),
580
+ notices: z.array(z.object({
581
+ message: z.string().min(1).max(512),
582
+ url: z.literal("https://github.com/login/device").optional(),
583
+ code: z.string().min(1).max(32).regex(/^[A-Z0-9-]+$/u).optional()
584
+ }).strict()).max(8),
585
+ diagnostic: z.enum(COPILOT_ACCOUNTS_DIAGNOSTICS).optional()
586
+ }).strict().superRefine((view, ctx) => {
587
+ const invalid = () => ctx.addIssue({
588
+ code: "custom",
589
+ message: "Invalid account evidence"
590
+ });
591
+ if (view.state === "error" !== (view.diagnostic !== void 0)) invalid();
592
+ if (view.switchable && (!view.writable || view.operation !== void 0 || view.state !== "ready" && view.diagnostic !== "COPILOT_ACCOUNTS_SELECTED_MISSING")) invalid();
593
+ if (view.writable && view.revision === void 0) invalid();
594
+ if (new Set(view.accounts.map((row) => row.id)).size !== view.accounts.length) invalid();
595
+ for (const row of view.accounts) {
596
+ if (row.identityState === "ready" !== (row.identity !== void 0)) invalid();
597
+ if (row.identity !== void 0 && !row.configured) invalid();
598
+ }
599
+ });
600
+ const contribution$4 = {
601
+ package: "dsh-github-copilot",
602
+ descriptors: [
603
+ "get",
604
+ "refreshIdentity",
605
+ "ensureIdentity",
606
+ "add",
607
+ "cancel",
608
+ "switchAccount",
609
+ "removeAccount",
610
+ "reauthorize"
611
+ ].map((method) => ({
612
+ id: `dsh-github-copilot:githubCopilotAccounts.${method}`,
613
+ namespace: "githubCopilotAccounts",
614
+ service: "githubCopilotAccounts",
615
+ method,
616
+ invocation: { kind: "direct" },
617
+ parameters: method === "switchAccount" || method === "removeAccount" || method === "reauthorize" ? [{
618
+ name: "accountId",
619
+ wire: "accountId",
620
+ source: "json",
621
+ codec: strictRemoteCodec("dsh-github-copilot#CopilotAccountId", CopilotAccountIdSchema)
622
+ }, {
623
+ name: "expectedRevision",
624
+ wire: "expectedRevision",
625
+ source: "json",
626
+ codec: strictRemoteCodec("dsh-github-copilot#CopilotAccountsRevision", revision)
627
+ }] : [],
628
+ result: strictRemoteCodec("dsh-github-copilot#CopilotAccountsView", CopilotAccountsViewSchema)
629
+ }))
630
+ };
631
+ //#endregion
632
+ //#region lib/types/session-accounts-remote.js
633
+ const SessionAccountViewSchema = z.object({
634
+ source: z.enum(["global", "session"]),
635
+ accountId: CopilotAccountIdSchema,
636
+ globalAccountId: CopilotAccountIdSchema,
637
+ runningAccountId: CopilotAccountIdSchema.optional(),
638
+ accounts: CopilotAccountsViewSchema
639
+ }).strict().refine((view) => view.accountId === view.accounts.activeAccountId, { message: "Session account identity mismatch" });
640
+ const TurnAccountViewSchema = z.discriminatedUnion("state", [z.object({ state: z.literal("unknown") }).strict(), z.object({
641
+ state: z.literal("recorded"),
642
+ accountId: CopilotAccountIdSchema,
643
+ source: z.enum(["global", "session"]),
644
+ identity: CopilotAccountsViewSchema.shape.accounts.element.shape.identity
645
+ }).strict()]);
646
+ const agent = {
647
+ name: "agent",
648
+ wire: "agentId",
649
+ source: "lookup",
650
+ lookup: "agent",
651
+ codec: strictRemoteCodec("@deepseek-ai/dsh-session/types#SessionId", z.string().min(1).max(256))
652
+ };
653
+ const contribution$3 = {
654
+ package: "dsh-github-copilot",
655
+ descriptors: [
656
+ "get",
657
+ "set",
658
+ "refreshIdentity",
659
+ "ensureIdentity",
660
+ "usage",
661
+ "refreshUsage",
662
+ "turn"
663
+ ].map((method) => ({
664
+ id: `dsh-github-copilot:githubCopilotSessionAccount.${method}`,
665
+ namespace: "githubCopilotSessionAccount",
666
+ service: "githubCopilotSessionAccount",
667
+ method,
668
+ invocation: { kind: "direct" },
669
+ parameters: [agent, ...method === "set" ? [{
670
+ name: "accountId",
671
+ wire: "accountId",
672
+ source: "json",
673
+ codec: strictRemoteCodec("dsh-github-copilot#SessionAccountChoice", CopilotAccountIdSchema.nullable())
674
+ }, {
675
+ name: "revision",
676
+ wire: "revision",
677
+ source: "json",
678
+ codec: strictRemoteCodec("dsh-github-copilot#SessionAccountRevision", z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER))
679
+ }] : method === "turn" ? [{
680
+ name: "turn",
681
+ wire: "turn",
682
+ source: "json",
683
+ codec: strictRemoteCodec("dsh-github-copilot#SessionAccountTurn", z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER))
684
+ }] : []],
685
+ result: method === "usage" || method === "refreshUsage" ? strictRemoteCodec("dsh-github-copilot#CopilotUsageView", CopilotUsageViewSchema) : method === "turn" ? strictRemoteCodec("dsh-github-copilot#TurnAccountView", TurnAccountViewSchema) : strictRemoteCodec("dsh-github-copilot#SessionAccountView", SessionAccountViewSchema)
686
+ }))
687
+ };
688
+ //#endregion
689
+ //#region lib/types/session-continuation-types.js
690
+ const CompactionContinuationStatusSchema = z.object({
691
+ id: z.string().min(1).max(256),
692
+ state: z.enum([
693
+ "running",
694
+ "completed",
695
+ "failed",
696
+ "cancelled",
697
+ "blocked"
698
+ ])
699
+ }).strict();
700
+ z.object({
701
+ id: z.string().nullable(),
702
+ running: z.boolean()
703
+ }).strict();
704
+ const SessionContinuationPreferenceSchema = z.object({
705
+ sessionId: z.string().min(1).max(256).refine((value) => !/[\p{Cc}\p{Cf}]/u.test(value)),
706
+ version: z.literal(1),
707
+ consentedAt: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
708
+ enabled: z.boolean().optional()
709
+ }).strict();
710
+ z.array(SessionContinuationPreferenceSchema).max(2048).refine((rows) => new Set(rows.map((row) => row.sessionId)).size === rows.length);
711
+ z.array(z.object({
712
+ enabled: z.boolean(),
713
+ changedAt: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
714
+ }).strict()).max(2048).refine((rows) => rows.every((row, index) => index === 0 || row.changedAt > rows[index - 1].changedAt));
715
+ const ContinuationDefaultViewSchema = z.object({
716
+ enabled: z.boolean(),
717
+ revision: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
718
+ }).strict();
719
+ const SessionContinuationViewSchema = z.object({
720
+ enabled: z.boolean(),
721
+ revision: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
722
+ activeTurnEnabled: z.boolean().optional(),
723
+ source: z.enum(["default", "session"]).optional(),
724
+ nextTurnAuthorized: z.boolean().optional(),
725
+ compaction: CompactionContinuationStatusSchema.optional()
726
+ }).strict();
727
+ //#endregion
728
+ //#region lib/types/session-continuation-remote.js
729
+ const contribution$2 = {
730
+ package: "dsh-github-copilot",
731
+ descriptors: [
732
+ "get",
733
+ "set",
734
+ "authorizeNext",
735
+ "defaults",
736
+ "setDefault"
737
+ ].map((method) => ({
738
+ id: `dsh-github-copilot:githubCopilotSessionContinuation.${method}`,
739
+ namespace: "githubCopilotSessionContinuation",
740
+ service: "githubCopilotSessionContinuation",
741
+ method,
742
+ invocation: { kind: "direct" },
743
+ parameters: [...method === "defaults" || method === "setDefault" ? [] : [{
744
+ name: "agent",
745
+ wire: "agentId",
746
+ source: "lookup",
747
+ lookup: "agent",
748
+ codec: strictRemoteCodec("@deepseek-ai/dsh-session/types#SessionId", z.string().min(1).max(256))
749
+ }], ...method === "set" || method === "authorizeNext" || method === "setDefault" ? [{
750
+ name: "revision",
751
+ wire: "revision",
752
+ source: "json",
753
+ codec: strictRemoteCodec("dsh-github-copilot#SessionContinuationRevision", z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER))
754
+ }, {
755
+ name: "enabled",
756
+ wire: "enabled",
757
+ source: "json",
758
+ codec: strictRemoteCodec("dsh-github-copilot#SessionContinuationEnabled", method === "set" ? z.boolean().nullable() : z.boolean())
759
+ }] : []],
760
+ result: method === "defaults" || method === "setDefault" ? strictRemoteCodec("dsh-github-copilot#ContinuationDefaultView", ContinuationDefaultViewSchema) : strictRemoteCodec("dsh-github-copilot#SessionContinuationView", SessionContinuationViewSchema)
761
+ }))
762
+ };
763
+ //#endregion
764
+ //#region lib/types/diagnostics-types.js
765
+ const DIAGNOSTICS_OPERATIONS = [
766
+ "account-global-switch",
767
+ "account-session-select",
768
+ "account-session-inherit",
769
+ "identity-read",
770
+ "identity-flight",
771
+ "compaction",
772
+ "compaction-summary",
773
+ "collection"
774
+ ];
775
+ const DIAGNOSTICS_STAGES = [
776
+ "admitted",
777
+ "rpc-invoked",
778
+ "host-received",
779
+ "identity-validation",
780
+ "model-validation",
781
+ "cas",
782
+ "readback",
783
+ "response-received",
784
+ "decoded",
785
+ "client-settled",
786
+ "summary-attempt",
787
+ "checkpoint-committed",
788
+ "ended",
789
+ "cache-hit",
790
+ "joined-flight",
791
+ "cooldown",
792
+ "dispatched"
793
+ ];
794
+ const DIAGNOSTICS_METRICS = [
795
+ "started",
796
+ "stage",
797
+ "success",
798
+ "no-op",
799
+ "cancelled",
800
+ "policy-rejected",
801
+ "revoked",
802
+ "environment-fault",
803
+ "failed",
804
+ "unknown",
805
+ "interrupted",
806
+ "dropped",
807
+ "paused",
808
+ "expired",
809
+ "clock-discontinuity",
810
+ "pending-sample"
811
+ ];
812
+ const DIAGNOSTICS_REASONS = [
813
+ "none",
814
+ "unknown",
815
+ "rpc-unavailable",
816
+ "decode-invalid",
817
+ "COPILOT_ACCOUNTS_BUSY",
818
+ "COPILOT_ACCOUNTS_CONFLICT",
819
+ "COPILOT_ACCOUNTS_CHANGED",
820
+ "COPILOT_ACCOUNTS_COMMIT_UNCERTAIN",
821
+ "COPILOT_ACCOUNTS_IDENTITY_TIMEOUT",
822
+ "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE",
823
+ "COPILOT_ACCOUNTS_MODELS_FAILED",
824
+ "COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE",
825
+ "COPILOT_ACCOUNTS_IDENTITY_TLS",
826
+ "COPILOT_ACCOUNTS_IDENTITY_NETWORK",
827
+ "COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED",
828
+ "COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED",
829
+ "COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR",
830
+ "COPILOT_ACCOUNTS_IDENTITY_INVALID",
831
+ "COPILOT_SESSION_ACCOUNTS_UNAVAILABLE",
832
+ "COPILOT_SESSION_ACCOUNTS_SETTINGS_UNAVAILABLE",
833
+ "COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN",
834
+ "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH",
835
+ "CONTEXT_WINDOW_EXCEEDED",
836
+ "COPILOT_MANUAL_RECOVERY_FIXED_PREFIX",
837
+ "COPILOT_MANUAL_RECOVERY_INDIVISIBLE",
838
+ "COPILOT_MANUAL_RECOVERY_CALL_LIMIT",
839
+ "COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY",
840
+ "COPILOT_MANUAL_RECOVERY_UNBALANCED"
841
+ ];
842
+ const DIAGNOSTICS_MAX_ROWS = 4096;
843
+ const DIAGNOSTICS_MAX_BYTES = 2097152;
844
+ const integer = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
845
+ const version = z.string().max(64).regex(/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/);
846
+ const DiagnosticsRowSchema = z.object({
847
+ hour: integer.multipleOf(36e5),
848
+ version,
849
+ layer: z.enum(["client", "host"]),
850
+ operation: z.enum(DIAGNOSTICS_OPERATIONS),
851
+ stage: z.enum(DIAGNOSTICS_STAGES),
852
+ metric: z.enum(DIAGNOSTICS_METRICS),
853
+ reason: z.enum(DIAGNOSTICS_REASONS),
854
+ bucket: z.number().int().min(0).max(7),
855
+ count: integer.min(1)
856
+ }).strict();
857
+ const DiagnosticsPendingSchema = z.object({
858
+ version,
859
+ operation: z.enum(DIAGNOSTICS_OPERATIONS),
860
+ stage: z.enum(DIAGNOSTICS_STAGES),
861
+ bucket: z.number().int().min(0).max(7),
862
+ count: integer.min(1).max(128)
863
+ }).strict();
864
+ const DiagnosticsSnapshotSchema = z.object({
865
+ schemaVersion: z.literal(1),
866
+ coverageVersion: z.literal(1),
867
+ epoch: integer,
868
+ updatedAt: integer,
869
+ rows: z.array(DiagnosticsRowSchema).max(DIAGNOSTICS_MAX_ROWS),
870
+ pending: z.array(DiagnosticsPendingSchema).max(128),
871
+ dropped: integer,
872
+ clientDropped: integer,
873
+ clientUnconfirmed: integer,
874
+ saturated: integer,
875
+ evicted: integer,
876
+ interrupted: integer
877
+ }).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");
878
+ const DiagnosticsViewSchema = z.object({
879
+ enabled: z.boolean(),
880
+ state: z.enum([
881
+ "loading",
882
+ "ready",
883
+ "unavailable",
884
+ "error"
885
+ ]),
886
+ diagnostic: z.enum([
887
+ "none",
888
+ "storage-unavailable",
889
+ "storage-invalid",
890
+ "storage-write-failed",
891
+ "profile-unavailable",
892
+ "settings-unavailable",
893
+ "settings-conflict",
894
+ "client-report-failed",
895
+ "client-report-revoked",
896
+ "closed"
897
+ ]),
898
+ persistedAt: integer.optional(),
899
+ dirty: z.boolean(),
900
+ snapshot: DiagnosticsSnapshotSchema
901
+ }).strict();
902
+ //#endregion
903
+ //#region lib/types/diagnostics-remote.js
904
+ const ClientDiagnosticsBatchSchema = z.object({
905
+ epoch: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
906
+ rows: z.array(DiagnosticsRowSchema.refine((row) => row.layer === "client")).max(128),
907
+ dropped: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional(),
908
+ unconfirmed: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()
909
+ }).strict();
910
+ const result$1 = strictRemoteCodec("dsh-github-copilot#DiagnosticsView", DiagnosticsViewSchema);
911
+ const contribution$1 = {
912
+ package: "dsh-github-copilot",
913
+ descriptors: [
914
+ {
915
+ method: "get",
916
+ parameters: []
917
+ },
918
+ {
919
+ method: "clear",
920
+ parameters: []
921
+ },
922
+ {
923
+ method: "setEnabled",
924
+ parameters: [{
925
+ name: "enabled",
926
+ wire: "enabled",
927
+ source: "json",
928
+ codec: strictRemoteCodec("dsh-github-copilot#DiagnosticsEnabled", z.boolean())
929
+ }]
930
+ },
931
+ {
932
+ method: "recordClient",
933
+ parameters: [{
934
+ name: "batch",
935
+ wire: "batch",
936
+ source: "json",
937
+ codec: strictRemoteCodec("dsh-github-copilot#ClientDiagnosticsBatch", ClientDiagnosticsBatchSchema)
938
+ }]
939
+ }
940
+ ].map((descriptor) => ({
941
+ ...descriptor,
942
+ id: `dsh-github-copilot:githubCopilotDiagnostics.${descriptor.method}`,
943
+ namespace: "githubCopilotDiagnostics",
944
+ service: "githubCopilotDiagnostics",
945
+ invocation: { kind: "direct" },
946
+ result: result$1
947
+ }))
948
+ };
949
+ //#endregion
415
950
  //#region lib/types/remote.js
416
951
  /**
417
952
  * Client-safe Remote contribution for the plugin-owned authorization bridge.
@@ -479,6 +1014,7 @@ const GitHubCopilotAuthorizationViewSchema = z.object({
479
1014
  excludedModelIds: z.array(z.string().min(1).max(512)).max(512),
480
1015
  lockedModelIds: z.array(z.string().min(1).max(512)).max(512),
481
1016
  unavailableExcludedModelIds: z.array(z.string().min(1).max(512)).max(512),
1017
+ highCostModelIds: z.array(z.string().min(1).max(512)).max(512).optional(),
482
1018
  error: z.enum([
483
1019
  "COPILOT_MODEL_PREFERENCES_UNAVAILABLE",
484
1020
  "COPILOT_MODEL_SETTINGS_UNAVAILABLE",
@@ -611,6 +1147,25 @@ const contribution = {
611
1147
  }],
612
1148
  result: strictRemoteCodec("dsh-github-copilot#GitHubCopilotModelPreferencesView", GitHubCopilotModelPreferencesViewSchema)
613
1149
  },
1150
+ {
1151
+ id: "dsh-github-copilot:githubCopilot.setModelHighCost",
1152
+ service: "githubCopilotAuthorization",
1153
+ namespace: "githubCopilot",
1154
+ method: "setModelHighCost",
1155
+ invocation: direct,
1156
+ parameters: [{
1157
+ name: "modelId",
1158
+ wire: "modelId",
1159
+ source: "json",
1160
+ codec: strictRemoteCodec("dsh-github-copilot#GitHubCopilotModelId", z.string().min(1).max(512))
1161
+ }, {
1162
+ name: "highCost",
1163
+ wire: "highCost",
1164
+ source: "json",
1165
+ codec: strictRemoteCodec("dsh-github-copilot#GitHubCopilotModelHighCost", z.boolean())
1166
+ }],
1167
+ result: strictRemoteCodec("dsh-github-copilot#GitHubCopilotModelPreferencesView", GitHubCopilotModelPreferencesViewSchema)
1168
+ },
614
1169
  {
615
1170
  id: "dsh-github-copilot:githubCopilot.migrationStatus",
616
1171
  service: "githubCopilotAuthorization",
@@ -620,6 +1175,10 @@ const contribution = {
620
1175
  parameters: [],
621
1176
  result: strictRemoteCodec(GITHUB_COPILOT_MIGRATION_STATUS_TYPE_SYMBOL, GitHubCopilotMigrationStatusSchema)
622
1177
  },
1178
+ ...contribution$9.descriptors,
1179
+ ...contribution$8.descriptors,
1180
+ ...contribution$7.descriptors,
1181
+ ...contribution$6.descriptors,
623
1182
  ...contribution$5.descriptors,
624
1183
  ...contribution$4.descriptors,
625
1184
  ...contribution$3.descriptors,