dsh-github-copilot 0.4.0-alpha.122 → 0.4.0-alpha.123

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/lib/index.js CHANGED
@@ -1,12 +1,12 @@
1
+ import { a as selectCompactionReasoning, c as DiagnosticsRowSchema, d as diagnosticsBucket, f as diagnosticsOutcome, i as resolveRequestBudgetPolicy, l as DiagnosticsSnapshotSchema, n as assessRequestBudget, p as diagnosticsReason, r as calculateRequestBudget, s as DIAGNOSTICS_RETENTION_MS, t as DEFAULT_REQUEST_BUDGET_POLICY, u as DiagnosticsViewSchema } from "./request-budget-Cui2hCi1.js";
2
+ import { C as providerErrorMessage, D as onSettingsNamespaceUpdated, E as readCopilotCatalog, O as readConfigValue, S as isAbortError, T as isPluginPreviewProvider, _ as sameCandidates, a as COPILOT_HOSTED_SEARCH_PROVIDER_ID, b as currentSearchSelection, c as applyRequestAuth, d as ANTHROPIC_WEB_SEARCH_TOOL_TYPE, f as GITHUB_COPILOT_CREDENTIAL_KEY$1, g as candidatesForRoute, h as WEB_SEARCH_TOOL_TYPE, i as describeSearchBackend, k as readSettingsNamespace, l as normalizeRequestAuth, m as SearchPlan, n as routeSessionSearch, o as GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID, p as RESPONSES_WEB_SEARCH_TOOL_TYPE, r as DescribedSearchFallbackError, s as createTraditionalSearchProvider, t as isCopilotSearchSelection, u as providerRequestHeaders, v as currentChatRoute, w as readBounded, x as abortable$1, y as currentSearchInitiator } from "./search-routing-CV2hs8as.js";
1
3
  import { a as GITHUB_COPILOT_PREVIEW_PROVIDER_ID, i as GITHUB_COPILOT_CREDENTIAL_KEY, n as GITHUB_COPILOT_AUTO_INTELLIGENCE_MODEL_ID, o as GITHUB_COPILOT_PROVIDER_ID, r as GITHUB_COPILOT_AUTO_MODEL_ID, s as autoModelPreference, t as GITHUB_COPILOT_AUTO_EFFICIENCY_MODEL_ID } from "./copilot-identity-DRZY_d2X.js";
2
- import { C as providerErrorMessage, D as readSettingsNamespace, E as readConfigValue, O as isPluginPreviewProvider, S as isAbortError, T as onSettingsNamespaceUpdated, _ 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 readCopilotCatalog, 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-CHyF6TbO.js";
3
- import { a as selectCompactionReasoning, i as resolveRequestBudgetPolicy, n as assessRequestBudget, r as calculateRequestBudget, t as DEFAULT_REQUEST_BUDGET_POLICY } from "./request-budget-DLY_aRq0.js";
4
+ import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
5
+ import { z } from "zod";
4
6
  import AuthorizationService from "@deepseek-ai/dsh-authorization";
5
7
  import { createHash, randomUUID } from "node:crypto";
6
8
  import * as dshScope from "@deepseek-ai/dsh-scope";
7
- import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
8
- import z from "@deepseek-ai/schemastery";
9
- import { z as z$1 } from "zod";
9
+ import z$1 from "@deepseek-ai/schemastery";
10
10
  import { getCACertificates } from "node:tls";
11
11
  import { Agent } from "undici";
12
12
  import { createModels, getSupportedThinkingLevels, hasApi, lazyStream } from "@earendil-works/pi-ai";
@@ -22,6 +22,844 @@ import { CONTEXT_WINDOW_EXCEEDED_CODE, LlmError, ReasoningEffortId, attributionH
22
22
  import { setImmediate } from "node:timers/promises";
23
23
  import { Config as Config$1, PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
24
24
  import { estimateContextTokens, estimateMessageTokens } from "@earendil-works/pi-ai/utils/estimate";
25
+ //#region lib/types/diagnostics-collector.js
26
+ const noop = {
27
+ stage() {},
28
+ finish() {}
29
+ };
30
+ function emptyDiagnostics() {
31
+ return {
32
+ schemaVersion: 1,
33
+ coverageVersion: 1,
34
+ epoch: 0,
35
+ updatedAt: 0,
36
+ rows: [],
37
+ pending: [],
38
+ dropped: 0,
39
+ clientDropped: 0,
40
+ clientUnconfirmed: 0,
41
+ saturated: 0,
42
+ evicted: 0,
43
+ interrupted: 0
44
+ };
45
+ }
46
+ /** Only fixed dimensions cross this boundary; live handles never leave the owner. */
47
+ var DiagnosticsCollector = class {
48
+ version;
49
+ layer;
50
+ changed;
51
+ wall;
52
+ mono;
53
+ data = emptyDiagnostics();
54
+ live = /* @__PURE__ */ new Set();
55
+ enabled = false;
56
+ lastWall = 0;
57
+ constructor(version, layer, changed = () => {}, wall = Date.now, mono = () => performance.now()) {
58
+ this.version = version;
59
+ this.layer = layer;
60
+ this.changed = changed;
61
+ this.wall = wall;
62
+ this.mono = mono;
63
+ }
64
+ restore(snapshot) {
65
+ this.data = DiagnosticsSnapshotSchema.parse(snapshot);
66
+ this.lastWall = this.data.updatedAt;
67
+ for (const pending of this.data.pending) {
68
+ this.add(pending.operation, pending.stage, "interrupted", "unknown", pending.bucket, pending.count, pending.version);
69
+ this.increment("interrupted", pending.count);
70
+ }
71
+ this.data.pending = [];
72
+ this.expire();
73
+ }
74
+ setEnabled(enabled) {
75
+ if (enabled === this.enabled) return;
76
+ if (enabled) this.assertCanEnable();
77
+ if (this.enabled && !enabled) {
78
+ for (const live of this.live) this.settle(live, "interrupted", "unknown");
79
+ this.add("collection", "admitted", "paused", "none", 0);
80
+ }
81
+ if (this.data.epoch >= Number.MAX_SAFE_INTEGER) {
82
+ this.enabled = false;
83
+ this.increment("saturated");
84
+ this.changed();
85
+ return;
86
+ }
87
+ this.data.epoch++;
88
+ this.enabled = enabled;
89
+ this.changed();
90
+ }
91
+ assertCanEnable() {
92
+ if (!this.enabled && this.data.epoch >= Number.MAX_SAFE_INTEGER) throw new Error("COPILOT_DIAGNOSTICS_EPOCH_LIMIT");
93
+ }
94
+ clear() {
95
+ const epoch = this.data.epoch + 1;
96
+ if (!Number.isSafeInteger(epoch)) throw new Error("COPILOT_DIAGNOSTICS_EPOCH_LIMIT");
97
+ this.live.clear();
98
+ this.data = {
99
+ ...emptyDiagnostics(),
100
+ epoch
101
+ };
102
+ this.changed();
103
+ }
104
+ begin(operation) {
105
+ if (!this.enabled) return noop;
106
+ if (this.live.size >= 128) {
107
+ this.increment("dropped");
108
+ this.changed();
109
+ return noop;
110
+ }
111
+ const live = {
112
+ operation,
113
+ stage: "admitted",
114
+ start: this.mono(),
115
+ epoch: this.data.epoch
116
+ };
117
+ this.live.add(live);
118
+ this.add(operation, live.stage, "started", "none", 0);
119
+ return {
120
+ stage: (stage) => {
121
+ if (!this.live.has(live) || live.epoch !== this.data.epoch) return;
122
+ live.stage = stage;
123
+ this.add(operation, stage, "stage", "none", this.age(live));
124
+ },
125
+ finish: (outcome, reason = "none") => this.settle(live, outcome, reason)
126
+ };
127
+ }
128
+ settle(live, outcome, reason) {
129
+ if (!this.live.delete(live) || live.epoch !== this.data.epoch) return;
130
+ this.add(live.operation, live.stage, outcome, reason, this.age(live));
131
+ if (outcome === "interrupted") this.increment("interrupted");
132
+ }
133
+ age(live) {
134
+ return diagnosticsBucket(Math.max(0, this.mono() - live.start));
135
+ }
136
+ increment(field, amount = 1) {
137
+ if (field !== "saturated" && this.data[field] > Number.MAX_SAFE_INTEGER - amount) this.data.saturated = Math.min(Number.MAX_SAFE_INTEGER, this.data.saturated + 1);
138
+ this.data[field] = Math.min(Number.MAX_SAFE_INTEGER, this.data[field] + amount);
139
+ }
140
+ expire() {
141
+ const now = this.wall();
142
+ const oldest = Math.floor((now - DIAGNOSTICS_RETENTION_MS) / 36e5) * 36e5;
143
+ const kept = this.data.rows.filter((row) => row.hour > oldest);
144
+ this.increment("evicted", this.data.rows.length - kept.length);
145
+ if (kept.length !== this.data.rows.length) this.changed();
146
+ this.data.rows = kept;
147
+ }
148
+ add(operation, stage, metric, reason, bucket, count = 1, version = this.version) {
149
+ this.expire();
150
+ const now = this.wall();
151
+ const discontinuity = now < this.lastWall;
152
+ this.lastWall = now;
153
+ const row = {
154
+ hour: Math.floor(now / 36e5) * 36e5,
155
+ version,
156
+ layer: this.layer,
157
+ operation,
158
+ stage,
159
+ metric,
160
+ reason,
161
+ bucket,
162
+ count
163
+ };
164
+ const existing = this.data.rows.find((item) => item.hour === row.hour && item.version === row.version && item.layer === row.layer && item.operation === operation && item.stage === stage && item.metric === metric && item.reason === reason && item.bucket === bucket);
165
+ if (existing) {
166
+ if (existing.count > Number.MAX_SAFE_INTEGER - count) this.increment("saturated");
167
+ existing.count = Math.min(Number.MAX_SAFE_INTEGER, existing.count + count);
168
+ } else {
169
+ if (this.data.rows.length >= 4096) {
170
+ const index = this.oldestIndex();
171
+ this.increment("evicted");
172
+ if (row.hour < this.data.rows[index].hour) {
173
+ this.changed();
174
+ return;
175
+ }
176
+ this.data.rows.splice(index, 1);
177
+ }
178
+ this.data.rows.push(row);
179
+ }
180
+ this.changed();
181
+ if (discontinuity) this.add("collection", "admitted", "clock-discontinuity", "unknown", 0);
182
+ }
183
+ oldestIndex() {
184
+ let index = 0;
185
+ for (let candidate = 1; candidate < this.data.rows.length; candidate++) if (this.data.rows[candidate].hour < this.data.rows[index].hour) index = candidate;
186
+ return index;
187
+ }
188
+ snapshot() {
189
+ this.expire();
190
+ const pending = [];
191
+ for (const live of this.live) {
192
+ const bucket = this.age(live);
193
+ const existing = pending.find((row) => row.operation === live.operation && row.stage === live.stage && row.bucket === bucket);
194
+ if (existing) existing.count++;
195
+ else pending.push({
196
+ version: this.version,
197
+ operation: live.operation,
198
+ stage: live.stage,
199
+ bucket,
200
+ count: 1
201
+ });
202
+ }
203
+ return DiagnosticsSnapshotSchema.parse({
204
+ ...this.data,
205
+ updatedAt: this.wall(),
206
+ pending
207
+ });
208
+ }
209
+ close() {
210
+ this.setEnabled(false);
211
+ }
212
+ noteDropped() {
213
+ if (this.enabled) {
214
+ this.increment("dropped");
215
+ this.changed();
216
+ }
217
+ }
218
+ noteClientGaps(dropped, unconfirmed) {
219
+ if (!this.enabled) return;
220
+ this.increment("clientDropped", dropped);
221
+ this.increment("clientUnconfirmed", unconfirmed);
222
+ if (dropped || unconfirmed) this.changed();
223
+ }
224
+ mergeClient(rows) {
225
+ if (!this.enabled) return;
226
+ const now = this.wall();
227
+ for (const row of rows) {
228
+ if (row.layer !== "client" || row.hour > now || row.hour <= now - 12096e5) {
229
+ this.noteDropped();
230
+ continue;
231
+ }
232
+ const existing = this.data.rows.find((item) => Object.keys(row).every((key) => key === "count" || Reflect.get(item, key) === Reflect.get(row, key)));
233
+ if (existing) {
234
+ if (existing.count > Number.MAX_SAFE_INTEGER - row.count) this.increment("saturated");
235
+ existing.count = Math.min(Number.MAX_SAFE_INTEGER, existing.count + row.count);
236
+ } else {
237
+ if (this.data.rows.length >= 4096) {
238
+ const index = this.oldestIndex();
239
+ this.increment("evicted");
240
+ if (row.hour < this.data.rows[index].hour) {
241
+ this.changed();
242
+ continue;
243
+ }
244
+ this.data.rows.splice(index, 1);
245
+ }
246
+ this.data.rows.push({ ...row });
247
+ }
248
+ this.changed();
249
+ }
250
+ }
251
+ };
252
+ //#endregion
253
+ //#region lib/types/remote-codec.js
254
+ /** Client-safe bridge between legacy schema codecs and alpha.2 create factories. */
255
+ function strictRemoteCodec(typeSymbol, schema) {
256
+ return {
257
+ mode: "strict",
258
+ typeSymbol,
259
+ schema,
260
+ create: () => schema
261
+ };
262
+ }
263
+ //#endregion
264
+ //#region lib/types/diagnostics-remote.js
265
+ const ClientDiagnosticsBatchSchema = z.object({
266
+ epoch: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
267
+ rows: z.array(DiagnosticsRowSchema.refine((row) => row.layer === "client")).max(128),
268
+ dropped: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional(),
269
+ unconfirmed: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()
270
+ }).strict();
271
+ const result$1 = strictRemoteCodec("dsh-github-copilot#DiagnosticsView", DiagnosticsViewSchema);
272
+ [
273
+ {
274
+ method: "get",
275
+ parameters: []
276
+ },
277
+ {
278
+ method: "clear",
279
+ parameters: []
280
+ },
281
+ {
282
+ method: "setEnabled",
283
+ parameters: [{
284
+ name: "enabled",
285
+ wire: "enabled",
286
+ source: "json",
287
+ codec: strictRemoteCodec("dsh-github-copilot#DiagnosticsEnabled", z.boolean())
288
+ }]
289
+ },
290
+ {
291
+ method: "recordClient",
292
+ parameters: [{
293
+ name: "batch",
294
+ wire: "batch",
295
+ source: "json",
296
+ codec: strictRemoteCodec("dsh-github-copilot#ClientDiagnosticsBatch", ClientDiagnosticsBatchSchema)
297
+ }]
298
+ }
299
+ ].map((descriptor) => ({
300
+ ...descriptor,
301
+ id: `dsh-github-copilot:githubCopilotDiagnostics.${descriptor.method}`,
302
+ namespace: "githubCopilotDiagnostics",
303
+ service: "githubCopilotDiagnostics",
304
+ invocation: { kind: "direct" },
305
+ result: result$1
306
+ }));
307
+ //#endregion
308
+ //#region package.json
309
+ var package_default = {
310
+ name: "dsh-github-copilot",
311
+ description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
312
+ version: "0.4.0-alpha.123",
313
+ publishConfig: {
314
+ "access": "public",
315
+ "registry": "https://registry.npmjs.org/",
316
+ "tag": "alpha"
317
+ },
318
+ packageManager: "pnpm@11.7.0",
319
+ repository: {
320
+ "type": "git",
321
+ "url": "git+https://github.com/cloga/dsh-github-copilot.git"
322
+ },
323
+ type: "module",
324
+ exports: {
325
+ ".": {
326
+ "types": "./lib/types/index.d.ts",
327
+ "default": "./lib/index.js"
328
+ },
329
+ "./client": {
330
+ "types": "./lib/types/client.d.ts",
331
+ "default": "./lib/client.js"
332
+ },
333
+ "./remote": {
334
+ "types": "./lib/types/remote.d.ts",
335
+ "default": "./lib/remote.js"
336
+ },
337
+ "./web-delegate": {
338
+ "types": "./lib/types/web-delegate.d.ts",
339
+ "default": "./lib/web-delegate.js"
340
+ },
341
+ "./routed-web": {
342
+ "types": "./lib/types/routed-web.d.ts",
343
+ "default": "./lib/routed-web.js"
344
+ },
345
+ "./manual-compaction-recovery": {
346
+ "types": "./lib/types/manual-compaction-recovery.d.ts",
347
+ "default": "./lib/manual-compaction-recovery.js"
348
+ },
349
+ "./deployment-baseline.json": "./deployment-baseline.json",
350
+ "./package.json": "./package.json"
351
+ },
352
+ files: [
353
+ "cordis.patch.yml",
354
+ "deployment-baseline.json",
355
+ "lib/*.js",
356
+ "lib/*.js.map",
357
+ "lib/types/**/*.d.ts",
358
+ "README.md",
359
+ "README.zh.md",
360
+ "CHANGELOG.md",
361
+ "CONTRIBUTING.md",
362
+ "SECURITY.md",
363
+ "AGENTS.md",
364
+ "docs/agent-readiness.md",
365
+ "docs/model-compatibility-acceptance.md",
366
+ "docs/single-route-migration.md",
367
+ "docs/session-search-routing.md",
368
+ "docs/npm-distribution.md",
369
+ "docs/dual-model.md",
370
+ "docs/official-first-016-alpha2.md",
371
+ "docs/official-first-020-rc1.md",
372
+ "docs/official-first-020-rc2.md",
373
+ "docs/web-lifecycle-rc2.md",
374
+ "docs/copilot-compaction.md",
375
+ "docs/manual-compaction-recovery.md",
376
+ "docs/copilot-usage.md",
377
+ "docs/copilot-accounts.md",
378
+ "docs/session-continuation.md",
379
+ "docs/account-management-experience.md",
380
+ "docs/mockups/copilot-account-management.html",
381
+ "docs/mockups/copilot-account-dropdown.html",
382
+ "docs/automatic-model-routing.md",
383
+ "docs/auto-task-routing.md",
384
+ "docs/auto-high-cost.md",
385
+ "docs/evidence-driven-iteration.md",
386
+ "docs/plugin-diagnostics.md",
387
+ "docs/auto-iteration-review.json",
388
+ "scripts/iteration-review.mjs",
389
+ "docs/image-input-compatibility.md",
390
+ "output/auto-model-mockup/index.html",
391
+ "docs/images/dual-model-provenance.json",
392
+ "scripts/check-search-composition.mjs",
393
+ "docs/images/"
394
+ ],
395
+ keywords: [
396
+ "dsh",
397
+ "deepseek-harness",
398
+ "plugin",
399
+ "cordis",
400
+ "github-copilot",
401
+ "oauth",
402
+ "model-provider",
403
+ "hosted-search",
404
+ "web-search",
405
+ "openai-responses",
406
+ "typescript"
407
+ ],
408
+ license: "MIT",
409
+ engines: {
410
+ "node": ">=22.19.0",
411
+ "dsh": "0.2.0-rc.2"
412
+ },
413
+ scripts: {
414
+ "build": "pnpm clean && tsc -p tsconfig.json && tsdown",
415
+ "clean": "node -e \"require('node:fs').rmSync('lib', { recursive: true, force: true })\"",
416
+ "prepare": "tsc -p tsconfig.json && tsdown",
417
+ "prepack": "pnpm verify:baseline",
418
+ "test": "vitest run",
419
+ "test:watch": "vitest",
420
+ "typecheck": "tsc -p tsconfig.json --noEmit",
421
+ "typecheck:tests": "tsc -p tsconfig.tests.json",
422
+ "test:scripts": "node --test \"tests/scripts/*.test.mjs\"",
423
+ "agent:describe": "node scripts/agent.mjs describe --json",
424
+ "agent:doctor": "node scripts/agent.mjs doctor --json",
425
+ "agent:plan": "node scripts/agent.mjs plan",
426
+ "preflight:search": "node scripts/check-search-composition.mjs",
427
+ "verify:agent": "node scripts/verify-agent-contract.mjs",
428
+ "verify:tarball": "node scripts/verify-tarball.mjs",
429
+ "verify:baseline": "node scripts/verify-deployment-baseline.mjs",
430
+ "verify:package": "node scripts/verify-package.mjs",
431
+ "verify:controlled-core": "node scripts/verify-controlled-core.mjs",
432
+ "verify:reasoning-ui": "node scripts/verify-reasoning-presentation.mjs",
433
+ "verify:upstream": "node scripts/verify-upstream-baseline.mjs",
434
+ "release:check": "node scripts/release-policy.mjs",
435
+ "verify": "pnpm verify:agent && pnpm typecheck && pnpm typecheck:tests && pnpm verify:baseline && pnpm build && pnpm test && pnpm test:scripts && pnpm verify:package"
436
+ },
437
+ peerDependencies: {
438
+ "@deepseek-ai/cordis": "^4.0.4",
439
+ "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
440
+ "@deepseek-ai/dsh-agent-default-model": "0.2.0-rc.2",
441
+ "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
442
+ "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
443
+ "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
444
+ "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
445
+ "@deepseek-ai/dsh-authorization": "0.2.0-rc.2",
446
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
447
+ "@deepseek-ai/dsh-client-ui-settings-models": "0.2.0-rc.2",
448
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
449
+ "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
450
+ "@deepseek-ai/dsh-launch-environment": "0.2.0-rc.2",
451
+ "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
452
+ "@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
453
+ "@deepseek-ai/dsh-session": "0.2.0-rc.2",
454
+ "@deepseek-ai/dsh-scope": "0.2.0-rc.2",
455
+ "@deepseek-ai/dsh-settings": "0.2.0-rc.2",
456
+ "@deepseek-ai/dsh-typert-protocol": "0.2.0-rc.2",
457
+ "@deepseek-ai/dsh-web": "0.2.0-rc.2",
458
+ "@deepseek-ai/dsh-web-search-deepseek": "0.2.0-rc.2",
459
+ "@deepseek-ai/schemastery": "^3.18.4"
460
+ },
461
+ peerDependenciesMeta: {
462
+ "@deepseek-ai/dsh-web-search-deepseek": { "optional": true },
463
+ "@deepseek-ai/dsh-launch-environment": { "optional": true },
464
+ "@deepseek-ai/dsh-api-remotes": { "optional": true },
465
+ "@deepseek-ai/dsh-client-ui-renderer": { "optional": true },
466
+ "@deepseek-ai/dsh-client-ui-settings-models": { "optional": true },
467
+ "@deepseek-ai/dsh-client-ui-slots": { "optional": true },
468
+ "@deepseek-ai/dsh-typert-protocol": { "optional": true }
469
+ },
470
+ dependencies: {
471
+ "@earendil-works/pi-ai": "0.87.1",
472
+ "undici": "6.28.1",
473
+ "zod": "4.6.5"
474
+ },
475
+ devDependencies: {
476
+ "@deepseek-ai/cordis": "~4.0.4",
477
+ "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
478
+ "@deepseek-ai/dsh-agent-default-model": "0.2.0-rc.2",
479
+ "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
480
+ "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
481
+ "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
482
+ "@deepseek-ai/dsh-jobs": "0.2.0-rc.2",
483
+ "@deepseek-ai/dsh-api-gateway": "0.2.0-rc.2",
484
+ "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
485
+ "@deepseek-ai/dsh-app-boot": "0.2.0-rc.2",
486
+ "@deepseek-ai/dsh-config-editor": "0.2.0-rc.2",
487
+ "@deepseek-ai/dsh-attachment": "0.2.0-rc.2",
488
+ "@deepseek-ai/dsh-authorization": "0.2.0-rc.2",
489
+ "@deepseek-ai/dsh-client-connection": "0.2.0-rc.2",
490
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
491
+ "@deepseek-ai/dsh-client-ui-settings-models": "0.2.0-rc.2",
492
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
493
+ "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
494
+ "@deepseek-ai/dsh-fs": "0.2.0-rc.2",
495
+ "@deepseek-ai/dsh-launch-environment": "0.2.0-rc.2",
496
+ "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
497
+ "@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
498
+ "@deepseek-ai/dsh-scope": "0.2.0-rc.2",
499
+ "@deepseek-ai/dsh-session": "0.2.0-rc.2",
500
+ "@deepseek-ai/dsh-session-format-catalog": "0.2.0-rc.2",
501
+ "@deepseek-ai/dsh-session-projection": "0.2.0-rc.2",
502
+ "@deepseek-ai/dsh-settings": "0.2.0-rc.2",
503
+ "@deepseek-ai/dsh-storage": "0.2.0-rc.2",
504
+ "@deepseek-ai/dsh-storage-domain": "0.2.0-rc.2",
505
+ "@deepseek-ai/dsh-storage-json": "0.2.0-rc.2",
506
+ "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
507
+ "@deepseek-ai/dsh-tool-web": "0.2.0-rc.2",
508
+ "@deepseek-ai/dsh-tools": "0.2.0-rc.2",
509
+ "@deepseek-ai/dsh-typert-protocol": "0.2.0-rc.2",
510
+ "@deepseek-ai/dsh-typert-registry": "0.2.0-rc.2",
511
+ "@deepseek-ai/dsh-web": "0.2.0-rc.2",
512
+ "@deepseek-ai/dsh-web-search-deepseek": "0.2.0-rc.2",
513
+ "@deepseek-ai/schemastery": "^3.18.4",
514
+ "@types/node": "^22.0.0",
515
+ "@types/react": "~18.3.1",
516
+ "@types/react-dom": "18.3.7",
517
+ "jsdom": "^26.1.0",
518
+ "react": "^18.2.0",
519
+ "react-dom": "18.3.1",
520
+ "tsdown": "^0.22.2",
521
+ "typescript": "^5.9.0",
522
+ "unrun": "^0.3.1",
523
+ "vitest": "^3.2.0"
524
+ },
525
+ main: "lib/index.js",
526
+ types: "lib/types/index.d.ts",
527
+ imports: { "#package.json": "./package.json" },
528
+ dsh: {
529
+ "bundle": { "patch": "./cordis.patch.yml" },
530
+ "client": {
531
+ "external": ["react"],
532
+ "inject": ["@deepseek-ai/dsh-api-remotes", "@deepseek-ai/dsh-client-ui-settings-models"],
533
+ "platform": "web"
534
+ }
535
+ }
536
+ };
537
+ //#endregion
538
+ //#region lib/types/diagnostics-host.js
539
+ var __runInitializers$9 = function(thisArg, initializers, value) {
540
+ var useValue = arguments.length > 2;
541
+ for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
542
+ return useValue ? value : void 0;
543
+ };
544
+ var __esDecorate$9 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
545
+ function accept(f) {
546
+ if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
547
+ return f;
548
+ }
549
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
550
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
551
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
552
+ var _, done = false;
553
+ for (var i = decorators.length - 1; i >= 0; i--) {
554
+ var context = {};
555
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
556
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
557
+ context.addInitializer = function(f) {
558
+ if (done) throw new TypeError("Cannot add initializers after decoration has completed");
559
+ extraInitializers.push(accept(f || null));
560
+ };
561
+ var result = (0, decorators[i])(kind === "accessor" ? {
562
+ get: descriptor.get,
563
+ set: descriptor.set
564
+ } : descriptor[key], context);
565
+ if (kind === "accessor") {
566
+ if (result === void 0) continue;
567
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
568
+ if (_ = accept(result.get)) descriptor.get = _;
569
+ if (_ = accept(result.set)) descriptor.set = _;
570
+ if (_ = accept(result.init)) initializers.unshift(_);
571
+ } else if (_ = accept(result)) {
572
+ if (kind === "field") initializers.unshift(_);
573
+ else descriptor[key] = _;
574
+ }
575
+ }
576
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
577
+ done = true;
578
+ };
579
+ const diagnosticsDomain = {
580
+ name: "github_copilot_diagnostics",
581
+ version: 1,
582
+ tables: {},
583
+ global: {
584
+ schema: DiagnosticsSnapshotSchema,
585
+ initial: emptyDiagnostics()
586
+ }
587
+ };
588
+ function diagnosticsDomainForProfile(profileId) {
589
+ if (!/^[a-zA-Z0-9_-]{1,48}$/.test(profileId)) throw new Error("COPILOT_DIAGNOSTICS_PROFILE_UNAVAILABLE");
590
+ return {
591
+ ...diagnosticsDomain,
592
+ name: `github_copilot_diagnostics_${Buffer.from(profileId).toString("hex")}`
593
+ };
594
+ }
595
+ function beginDiagnostics(ctx, operation) {
596
+ return ctx.get("githubCopilotDiagnostics")?.collector.begin(operation);
597
+ }
598
+ /** Keeps diagnostics durability failures separate from observed business failures. */
599
+ let DiagnosticsController = (() => {
600
+ let _classSuper = TypertRemoteService;
601
+ let _instanceExtraInitializers = [];
602
+ let _get_decorators;
603
+ let _setEnabled_decorators;
604
+ let _clear_decorators;
605
+ let _recordClient_decorators;
606
+ return class DiagnosticsController extends _classSuper {
607
+ static {
608
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
609
+ _get_decorators = [Remote];
610
+ _setEnabled_decorators = [Remote];
611
+ _clear_decorators = [Remote];
612
+ _recordClient_decorators = [Remote];
613
+ __esDecorate$9(this, null, _get_decorators, {
614
+ kind: "method",
615
+ name: "get",
616
+ static: false,
617
+ private: false,
618
+ access: {
619
+ has: (obj) => "get" in obj,
620
+ get: (obj) => obj.get
621
+ },
622
+ metadata: _metadata
623
+ }, null, _instanceExtraInitializers);
624
+ __esDecorate$9(this, null, _setEnabled_decorators, {
625
+ kind: "method",
626
+ name: "setEnabled",
627
+ static: false,
628
+ private: false,
629
+ access: {
630
+ has: (obj) => "setEnabled" in obj,
631
+ get: (obj) => obj.setEnabled
632
+ },
633
+ metadata: _metadata
634
+ }, null, _instanceExtraInitializers);
635
+ __esDecorate$9(this, null, _clear_decorators, {
636
+ kind: "method",
637
+ name: "clear",
638
+ static: false,
639
+ private: false,
640
+ access: {
641
+ has: (obj) => "clear" in obj,
642
+ get: (obj) => obj.clear
643
+ },
644
+ metadata: _metadata
645
+ }, null, _instanceExtraInitializers);
646
+ __esDecorate$9(this, null, _recordClient_decorators, {
647
+ kind: "method",
648
+ name: "recordClient",
649
+ static: false,
650
+ private: false,
651
+ access: {
652
+ has: (obj) => "recordClient" in obj,
653
+ get: (obj) => obj.recordClient
654
+ },
655
+ metadata: _metadata
656
+ }, null, _instanceExtraInitializers);
657
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, {
658
+ enumerable: true,
659
+ configurable: true,
660
+ writable: true,
661
+ value: _metadata
662
+ });
663
+ }
664
+ collector = __runInitializers$9(this, _instanceExtraInitializers);
665
+ domain;
666
+ state = "unavailable";
667
+ problem = "storage-unavailable";
668
+ enabled = false;
669
+ dirty = false;
670
+ persistedAt;
671
+ revision = 0;
672
+ writing;
673
+ closed = false;
674
+ settingsBusy = false;
675
+ brackets = /* @__PURE__ */ new Map();
676
+ constructor(ctx) {
677
+ super(ctx, "githubCopilotDiagnostics");
678
+ this.collector = new DiagnosticsCollector(package_default.version, "host", () => {
679
+ this.dirty = true;
680
+ this.revision++;
681
+ });
682
+ const readEnabled = () => {
683
+ const value = ctx.get("settings")?.describe({ redactSecrets: true }).find((row) => row.ns === "github-copilot")?.value;
684
+ this.enabled = typeof value === "object" && value !== null && "diagnosticsEnabled" in value && value.diagnosticsEnabled === true;
685
+ this.collector.setEnabled(this.enabled && this.state === "ready");
686
+ if (!this.enabled) this.brackets.clear();
687
+ };
688
+ ctx.inject(["settings"], (scope) => {
689
+ readEnabled();
690
+ const dispose = onSettingsNamespaceUpdated(scope, (ns) => {
691
+ if (ns === "github-copilot") readEnabled();
692
+ });
693
+ scope.effect(() => dispose);
694
+ });
695
+ ctx.inject(["storageDomain"], async (scope) => {
696
+ this.state = "loading";
697
+ try {
698
+ const profile = scope.get("profileContext");
699
+ if (!profile) throw new Error("COPILOT_DIAGNOSTICS_PROFILE_UNAVAILABLE");
700
+ const domain = await scope.storageDomain.open(diagnosticsDomainForProfile(profile.name));
701
+ if (this.closed) {
702
+ await domain.close();
703
+ return;
704
+ }
705
+ this.domain = domain;
706
+ this.collector.restore(domain.global.get());
707
+ this.state = "ready";
708
+ this.problem = "none";
709
+ readEnabled();
710
+ await this.flush();
711
+ } catch (error) {
712
+ this.state = "error";
713
+ 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";
714
+ this.collector.setEnabled(false);
715
+ ctx.logger.warn("[github-copilot] COPILOT_DIAGNOSTICS_STORAGE_UNAVAILABLE");
716
+ }
717
+ if (this.closed) return;
718
+ const timer = setInterval(() => {
719
+ this.flush().catch(() => {
720
+ ctx.logger.warn("[github-copilot] COPILOT_DIAGNOSTICS_STORAGE_WRITE_FAILED");
721
+ });
722
+ }, 1e4);
723
+ timer.unref();
724
+ scope.effect(() => async () => {
725
+ clearInterval(timer);
726
+ this.collector.close();
727
+ try {
728
+ await this.flush();
729
+ } finally {
730
+ await this.domain?.close();
731
+ this.domain = void 0;
732
+ this.state = "unavailable";
733
+ this.problem = "storage-unavailable";
734
+ }
735
+ });
736
+ });
737
+ ctx.on("session/event", (session, event) => {
738
+ if (event.type === "compaction/start") {
739
+ if (!this.enabled || this.state !== "ready") return;
740
+ if (this.brackets.has(session) || this.brackets.size >= 128) {
741
+ this.collector.noteDropped();
742
+ return;
743
+ }
744
+ this.brackets.set(session, {
745
+ id: event.data.compactionId,
746
+ committed: false,
747
+ cancelled: false,
748
+ operation: this.collector.begin("compaction")
749
+ });
750
+ }
751
+ const bracket = this.brackets.get(session);
752
+ if (!bracket) return;
753
+ if (event.type === "user/message" && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === bracket.id) {
754
+ bracket.committed = true;
755
+ bracket.operation.stage("checkpoint-committed");
756
+ }
757
+ if (event.type !== "compaction/end" || event.data.compactionId !== bracket.id) return;
758
+ bracket.operation.stage("ended");
759
+ if (bracket.cancelled) bracket.operation.finish("cancelled");
760
+ else if (event.data.error === void 0) bracket.operation.finish(bracket.committed ? "success" : "unknown");
761
+ else {
762
+ const reason = diagnosticsReason(new Error(event.data.error));
763
+ bracket.operation.finish(diagnosticsOutcome(reason), reason);
764
+ }
765
+ this.brackets.delete(session);
766
+ });
767
+ ctx.on("agent/disposed", ({ agent }) => {
768
+ this.brackets.get(agent.session)?.operation.finish("interrupted", "unknown");
769
+ this.brackets.delete(agent.session);
770
+ });
771
+ ctx.effect(() => async () => {
772
+ this.collector.close();
773
+ this.brackets.clear();
774
+ try {
775
+ await this.flush();
776
+ } finally {
777
+ this.closed = true;
778
+ }
779
+ });
780
+ }
781
+ async flush() {
782
+ if (this.writing) {
783
+ await this.writing;
784
+ if (this.dirty) return this.flush();
785
+ return;
786
+ }
787
+ if (!this.domain || !this.dirty || this.closed) return;
788
+ const domain = this.domain;
789
+ const revision = this.revision;
790
+ const snapshot = this.collector.snapshot();
791
+ this.writing = domain.global.set(snapshot).then(() => {
792
+ this.persistedAt = snapshot.updatedAt;
793
+ this.dirty = this.revision !== revision;
794
+ this.state = "ready";
795
+ this.problem = "none";
796
+ }, () => {
797
+ this.problem = "storage-write-failed";
798
+ throw new Error("COPILOT_DIAGNOSTICS_STORAGE_WRITE_FAILED");
799
+ }).finally(() => {
800
+ this.writing = void 0;
801
+ });
802
+ await this.writing;
803
+ }
804
+ markCompactionCancelled(session) {
805
+ const bracket = this.brackets.get(session);
806
+ if (bracket) bracket.cancelled = true;
807
+ }
808
+ get() {
809
+ return {
810
+ enabled: this.enabled,
811
+ state: this.state,
812
+ diagnostic: this.problem,
813
+ ...this.persistedAt === void 0 ? {} : { persistedAt: this.persistedAt },
814
+ dirty: this.dirty,
815
+ snapshot: this.collector.snapshot()
816
+ };
817
+ }
818
+ async setEnabled(enabled) {
819
+ if (typeof enabled !== "boolean") throw new Error("COPILOT_DIAGNOSTICS_INVALID_CONTROL");
820
+ if (this.settingsBusy) throw new Error("COPILOT_DIAGNOSTICS_CONTROL_BUSY");
821
+ if (enabled && !this.domain) throw new Error("COPILOT_DIAGNOSTICS_STORAGE_UNAVAILABLE");
822
+ if (enabled) this.collector.assertCanEnable();
823
+ this.settingsBusy = true;
824
+ try {
825
+ const settings = this.ctx.get("settings");
826
+ const row = settings?.describe({ redactSecrets: true }).find((item) => item.ns === "github-copilot");
827
+ if (!settings || !row) throw new Error("COPILOT_DIAGNOSTICS_SETTINGS_UNAVAILABLE");
828
+ await settings.mutate("github-copilot", [{
829
+ op: "set",
830
+ path: ["diagnosticsEnabled"],
831
+ value: enabled
832
+ }], row.revision);
833
+ const saved = settings.describe({ redactSecrets: true }).find((item) => item.ns === "github-copilot")?.value;
834
+ if (typeof saved !== "object" || saved === null || !("diagnosticsEnabled" in saved) || saved.diagnosticsEnabled !== enabled) throw new Error("COPILOT_DIAGNOSTICS_SETTINGS_COMMIT_UNCERTAIN");
835
+ this.enabled = enabled;
836
+ this.collector.setEnabled(enabled);
837
+ await this.flush();
838
+ return this.get();
839
+ } finally {
840
+ this.settingsBusy = false;
841
+ }
842
+ }
843
+ async clear() {
844
+ if (!this.domain) throw new Error("COPILOT_DIAGNOSTICS_STORAGE_UNAVAILABLE");
845
+ this.collector.clear();
846
+ await this.flush();
847
+ return this.get();
848
+ }
849
+ async recordClient(batch) {
850
+ const parsed = ClientDiagnosticsBatchSchema.safeParse(batch);
851
+ if (!parsed.success) throw new Error("COPILOT_DIAGNOSTICS_INVALID_CLIENT_REPORT");
852
+ if (!this.enabled || !this.domain || parsed.data.epoch !== this.collector.snapshot().epoch) return {
853
+ ...this.get(),
854
+ diagnostic: "client-report-revoked"
855
+ };
856
+ this.collector.mergeClient(parsed.data.rows);
857
+ this.collector.noteClientGaps(parsed.data.dropped ?? 0, parsed.data.unconfirmed ?? 0);
858
+ return this.get();
859
+ }
860
+ };
861
+ })();
862
+ //#endregion
25
863
  //#region lib/types/dual-model-host.js
26
864
  /** Retired planner/executor entry points; retained policies stay enforceable without migration. */
27
865
  var __runInitializers$8 = function(thisArg, initializers, value) {
@@ -72,58 +910,58 @@ const DEFAULT_CONFIG = Object.freeze({
72
910
  plannerModel: "",
73
911
  executorModel: ""
74
912
  });
75
- const configSchema = z.object({
76
- enabled: z.boolean().default(false),
77
- plannerModel: z.string().default(""),
78
- executorModel: z.string().default("")
913
+ const configSchema = z$1.object({
914
+ enabled: z$1.boolean().default(false),
915
+ plannerModel: z$1.string().default(""),
916
+ executorModel: z$1.string().default("")
79
917
  });
80
- const ConfigJson = z$1.object({
81
- enabled: z$1.boolean(),
82
- plannerModel: z$1.string().max(512),
83
- executorModel: z$1.string().max(512)
918
+ const ConfigJson = z.object({
919
+ enabled: z.boolean(),
920
+ plannerModel: z.string().max(512),
921
+ executorModel: z.string().max(512)
84
922
  }).strict();
85
- const RevisionJson = z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
86
- const CreateJson = z$1.object({
87
- requestId: z$1.string().uuid(),
88
- workspaceId: z$1.string().min(1).max(512),
923
+ const RevisionJson = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
924
+ const CreateJson = z.object({
925
+ requestId: z.string().uuid(),
926
+ workspaceId: z.string().min(1).max(512),
89
927
  expectedRevision: RevisionJson
90
928
  }).strict();
91
- const SaveJson = z$1.object({
929
+ const SaveJson = z.object({
92
930
  configuration: ConfigJson,
93
931
  expectedRevision: RevisionJson
94
932
  }).strict();
95
- const ExecuteJson = z$1.object({
96
- description: z$1.string().min(1).max(160),
97
- prompt: z$1.string().min(1).max(1e5)
933
+ const ExecuteJson = z.object({
934
+ description: z.string().min(1).max(160),
935
+ prompt: z.string().min(1).max(1e5)
98
936
  }).strict();
99
- const PolicyJson = z$1.object({
100
- version: z$1.literal(1),
101
- rootSessionId: z$1.string(),
102
- requestId: z$1.string(),
103
- workspaceId: z$1.string(),
104
- settingsRevision: z$1.number().int().nonnegative(),
105
- cwd: z$1.string(),
106
- agentPreset: z$1.string(),
107
- provider: z$1.literal(GITHUB_COPILOT_PREVIEW_PROVIDER_ID),
108
- plannerModel: z$1.string().min(1),
109
- executorModel: z$1.string().min(1),
110
- executorTools: z$1.array(z$1.string()),
111
- plannerTools: z$1.array(z$1.string())
937
+ const PolicyJson = z.object({
938
+ version: z.literal(1),
939
+ rootSessionId: z.string(),
940
+ requestId: z.string(),
941
+ workspaceId: z.string(),
942
+ settingsRevision: z.number().int().nonnegative(),
943
+ cwd: z.string(),
944
+ agentPreset: z.string(),
945
+ provider: z.literal(GITHUB_COPILOT_PREVIEW_PROVIDER_ID),
946
+ plannerModel: z.string().min(1),
947
+ executorModel: z.string().min(1),
948
+ executorTools: z.array(z.string()),
949
+ plannerTools: z.array(z.string())
112
950
  }).strict();
113
- const ChildJson = z$1.object({
114
- version: z$1.literal(3),
115
- mode: z$1.literal("continuable"),
116
- provider: z$1.literal("spawn"),
117
- agentProvider: z$1.string(),
118
- agentModel: z$1.string()
951
+ const ChildJson = z.object({
952
+ version: z.literal(3),
953
+ mode: z.literal("continuable"),
954
+ provider: z.literal("spawn"),
955
+ agentProvider: z.string(),
956
+ agentModel: z.string()
119
957
  }).strict();
120
958
  const ChildWireJson = ChildJson.extend({
121
- label: z$1.string(),
122
- agentReasoningEffort: z$1.string().optional(),
123
- persona: z$1.string().optional(),
124
- toolFilter: z$1.object({
125
- allow: z$1.array(z$1.string()).optional(),
126
- deny: z$1.array(z$1.string()).optional()
959
+ label: z.string(),
960
+ agentReasoningEffort: z.string().optional(),
961
+ persona: z.string().optional(),
962
+ toolFilter: z.object({
963
+ allow: z.array(z.string()).optional(),
964
+ deny: z.array(z.string()).optional()
127
965
  }).strict().refine((value) => value.allow !== void 0 || value.deny !== void 0).optional()
128
966
  }).strict().transform(({ version, mode, provider, agentProvider, agentModel }) => ({
129
967
  version,
@@ -132,14 +970,14 @@ const ChildWireJson = ChildJson.extend({
132
970
  agentProvider,
133
971
  agentModel
134
972
  }));
135
- const ProjectionJson = z$1.object({
136
- id: z$1.string(),
137
- parentId: z$1.string().nullable(),
138
- origin: z$1.string().nullable(),
139
- inherited: z$1.number(),
973
+ const ProjectionJson = z.object({
974
+ id: z.string(),
975
+ parentId: z.string().nullable(),
976
+ origin: z.string().nullable(),
977
+ inherited: z.number(),
140
978
  policy: PolicyJson.nullable(),
141
979
  child: ChildJson.nullable(),
142
- invalid: z$1.boolean()
980
+ invalid: z.boolean()
143
981
  });
144
982
  /** A root policy is authoritative only in its own suffix, never in a fork seed. */
145
983
  const dualModelProjection = {
@@ -737,9 +1575,9 @@ let GitHubCopilotDualModel = (() => {
737
1575
  })();
738
1576
  //#endregion
739
1577
  //#region lib/types/search-routing-remote.js
740
- const SearchProviderCatalogSchema = z$1.object({
741
- supported: z$1.boolean(),
742
- providers: z$1.array(z$1.object({ id: z$1.string().min(1).max(512) }).strict()).max(512)
1578
+ const SearchProviderCatalogSchema = z.object({
1579
+ supported: z.boolean(),
1580
+ providers: z.array(z.object({ id: z.string().min(1).max(512) }).strict()).max(512)
743
1581
  }).strict();
744
1582
  //#endregion
745
1583
  //#region lib/types/search-routing-host.js
@@ -1179,36 +2017,36 @@ function createAccountModelAuth(credentials, renewRejectedCredential) {
1179
2017
  }
1180
2018
  //#endregion
1181
2019
  //#region lib/types/copilot-usage-normalize.js
1182
- const amount = z$1.number().finite().min(0).max(0xe8d4a51000);
1183
- const entitlement = z$1.union([
2020
+ const amount = z.number().finite().min(0).max(0xe8d4a51000);
2021
+ const entitlement = z.union([
1184
2022
  amount,
1185
- z$1.literal(-1),
1186
- z$1.string().max(32).regex(/^(?:-1|(?:0|[1-9]\d*)(?:\.\d+)?)$/u)
2023
+ z.literal(-1),
2024
+ z.string().max(32).regex(/^(?:-1|(?:0|[1-9]\d*)(?:\.\d+)?)$/u)
1187
2025
  ]).transform(Number).refine((value) => Number.isFinite(value) && value <= 0xe8d4a51000);
1188
- const resetSeconds = z$1.unknown().transform((value) => typeof value === "number" && Number.isInteger(value) && value > 0 && value <= Math.floor(0xe677d21fdbff / 1e3) ? value * 1e3 : void 0);
1189
- const resetCalendar = z$1.unknown().transform(resetDate);
1190
- const snapshot = z$1.object({
1191
- unlimited: z$1.boolean(),
2026
+ const resetSeconds = z.unknown().transform((value) => typeof value === "number" && Number.isInteger(value) && value > 0 && value <= Math.floor(0xe677d21fdbff / 1e3) ? value * 1e3 : void 0);
2027
+ const resetCalendar = z.unknown().transform(resetDate);
2028
+ const snapshot = z.object({
2029
+ unlimited: z.boolean(),
1192
2030
  entitlement: entitlement.optional(),
1193
- percent_remaining: z$1.number().finite().min(0).max(100).optional(),
2031
+ percent_remaining: z.number().finite().min(0).max(100).optional(),
1194
2032
  quota_remaining: amount.optional(),
1195
2033
  credits_used: amount.optional(),
1196
- has_quota: z$1.boolean().optional(),
1197
- token_based_billing: z$1.boolean().optional(),
2034
+ has_quota: z.boolean().optional(),
2035
+ token_based_billing: z.boolean().optional(),
1198
2036
  quota_reset_at: resetSeconds.optional()
1199
2037
  });
1200
- const response = z$1.object({
1201
- token_based_billing: z$1.boolean().optional(),
1202
- access_type_sku: z$1.string().max(128).optional(),
2038
+ const response = z.object({
2039
+ token_based_billing: z.boolean().optional(),
2040
+ access_type_sku: z.string().max(128).optional(),
1203
2041
  quota_reset_date: resetCalendar.optional(),
1204
2042
  quota_reset_date_utc: resetCalendar.optional(),
1205
2043
  limited_user_reset_date: resetCalendar.optional(),
1206
- quota_snapshots: z$1.object({
2044
+ quota_snapshots: z.object({
1207
2045
  chat: snapshot.optional(),
1208
2046
  premium_interactions: snapshot.optional()
1209
2047
  }).optional(),
1210
- monthly_quotas: z$1.object({ chat: amount }).optional(),
1211
- limited_user_quotas: z$1.object({ chat: amount }).optional()
2048
+ monthly_quotas: z.object({ chat: amount }).optional(),
2049
+ limited_user_quotas: z.object({ chat: amount }).optional()
1212
2050
  });
1213
2051
  function unavailableCopilotUsage(diagnostic, billing = "unknown", budget = "unknown") {
1214
2052
  return {
@@ -2994,232 +3832,6 @@ function createAccountProvider(descriptors, guard, baseURL) {
2994
3832
  };
2995
3833
  }
2996
3834
  //#endregion
2997
- //#region package.json
2998
- var package_default = {
2999
- name: "dsh-github-copilot",
3000
- description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
3001
- version: "0.4.0-alpha.122",
3002
- publishConfig: {
3003
- "access": "public",
3004
- "registry": "https://registry.npmjs.org/",
3005
- "tag": "alpha"
3006
- },
3007
- packageManager: "pnpm@11.7.0",
3008
- repository: {
3009
- "type": "git",
3010
- "url": "git+https://github.com/cloga/dsh-github-copilot.git"
3011
- },
3012
- type: "module",
3013
- exports: {
3014
- ".": {
3015
- "types": "./lib/types/index.d.ts",
3016
- "default": "./lib/index.js"
3017
- },
3018
- "./client": {
3019
- "types": "./lib/types/client.d.ts",
3020
- "default": "./lib/client.js"
3021
- },
3022
- "./remote": {
3023
- "types": "./lib/types/remote.d.ts",
3024
- "default": "./lib/remote.js"
3025
- },
3026
- "./web-delegate": {
3027
- "types": "./lib/types/web-delegate.d.ts",
3028
- "default": "./lib/web-delegate.js"
3029
- },
3030
- "./routed-web": {
3031
- "types": "./lib/types/routed-web.d.ts",
3032
- "default": "./lib/routed-web.js"
3033
- },
3034
- "./manual-compaction-recovery": {
3035
- "types": "./lib/types/manual-compaction-recovery.d.ts",
3036
- "default": "./lib/manual-compaction-recovery.js"
3037
- },
3038
- "./deployment-baseline.json": "./deployment-baseline.json",
3039
- "./package.json": "./package.json"
3040
- },
3041
- files: [
3042
- "cordis.patch.yml",
3043
- "deployment-baseline.json",
3044
- "lib/*.js",
3045
- "lib/*.js.map",
3046
- "lib/types/**/*.d.ts",
3047
- "README.md",
3048
- "README.zh.md",
3049
- "CHANGELOG.md",
3050
- "CONTRIBUTING.md",
3051
- "SECURITY.md",
3052
- "AGENTS.md",
3053
- "docs/agent-readiness.md",
3054
- "docs/model-compatibility-acceptance.md",
3055
- "docs/single-route-migration.md",
3056
- "docs/session-search-routing.md",
3057
- "docs/npm-distribution.md",
3058
- "docs/dual-model.md",
3059
- "docs/official-first-016-alpha2.md",
3060
- "docs/official-first-020-rc1.md",
3061
- "docs/official-first-020-rc2.md",
3062
- "docs/web-lifecycle-rc2.md",
3063
- "docs/copilot-compaction.md",
3064
- "docs/manual-compaction-recovery.md",
3065
- "docs/copilot-usage.md",
3066
- "docs/copilot-accounts.md",
3067
- "docs/session-continuation.md",
3068
- "docs/account-management-experience.md",
3069
- "docs/mockups/copilot-account-management.html",
3070
- "docs/mockups/copilot-account-dropdown.html",
3071
- "docs/automatic-model-routing.md",
3072
- "docs/auto-task-routing.md",
3073
- "docs/auto-high-cost.md",
3074
- "docs/evidence-driven-iteration.md",
3075
- "docs/auto-iteration-review.json",
3076
- "scripts/iteration-review.mjs",
3077
- "docs/image-input-compatibility.md",
3078
- "output/auto-model-mockup/index.html",
3079
- "docs/images/dual-model-provenance.json",
3080
- "scripts/check-search-composition.mjs",
3081
- "docs/images/"
3082
- ],
3083
- keywords: [
3084
- "dsh",
3085
- "deepseek-harness",
3086
- "plugin",
3087
- "cordis",
3088
- "github-copilot",
3089
- "oauth",
3090
- "model-provider",
3091
- "hosted-search",
3092
- "web-search",
3093
- "openai-responses",
3094
- "typescript"
3095
- ],
3096
- license: "MIT",
3097
- engines: {
3098
- "node": ">=22.19.0",
3099
- "dsh": "0.2.0-rc.2"
3100
- },
3101
- scripts: {
3102
- "build": "pnpm clean && tsc -p tsconfig.json && tsdown",
3103
- "clean": "node -e \"require('node:fs').rmSync('lib', { recursive: true, force: true })\"",
3104
- "prepare": "tsc -p tsconfig.json && tsdown",
3105
- "prepack": "pnpm verify:baseline",
3106
- "test": "vitest run",
3107
- "test:watch": "vitest",
3108
- "typecheck": "tsc -p tsconfig.json --noEmit",
3109
- "typecheck:tests": "tsc -p tsconfig.tests.json",
3110
- "test:scripts": "node --test \"tests/scripts/*.test.mjs\"",
3111
- "agent:describe": "node scripts/agent.mjs describe --json",
3112
- "agent:doctor": "node scripts/agent.mjs doctor --json",
3113
- "agent:plan": "node scripts/agent.mjs plan",
3114
- "preflight:search": "node scripts/check-search-composition.mjs",
3115
- "verify:agent": "node scripts/verify-agent-contract.mjs",
3116
- "verify:tarball": "node scripts/verify-tarball.mjs",
3117
- "verify:baseline": "node scripts/verify-deployment-baseline.mjs",
3118
- "verify:package": "node scripts/verify-package.mjs",
3119
- "verify:controlled-core": "node scripts/verify-controlled-core.mjs",
3120
- "verify:reasoning-ui": "node scripts/verify-reasoning-presentation.mjs",
3121
- "verify:upstream": "node scripts/verify-upstream-baseline.mjs",
3122
- "release:check": "node scripts/release-policy.mjs",
3123
- "verify": "pnpm verify:agent && pnpm typecheck && pnpm typecheck:tests && pnpm verify:baseline && pnpm build && pnpm test && pnpm test:scripts && pnpm verify:package"
3124
- },
3125
- peerDependencies: {
3126
- "@deepseek-ai/cordis": "^4.0.4",
3127
- "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
3128
- "@deepseek-ai/dsh-agent-default-model": "0.2.0-rc.2",
3129
- "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
3130
- "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
3131
- "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
3132
- "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
3133
- "@deepseek-ai/dsh-authorization": "0.2.0-rc.2",
3134
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
3135
- "@deepseek-ai/dsh-client-ui-settings-models": "0.2.0-rc.2",
3136
- "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
3137
- "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
3138
- "@deepseek-ai/dsh-launch-environment": "0.2.0-rc.2",
3139
- "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
3140
- "@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
3141
- "@deepseek-ai/dsh-session": "0.2.0-rc.2",
3142
- "@deepseek-ai/dsh-scope": "0.2.0-rc.2",
3143
- "@deepseek-ai/dsh-settings": "0.2.0-rc.2",
3144
- "@deepseek-ai/dsh-typert-protocol": "0.2.0-rc.2",
3145
- "@deepseek-ai/dsh-web": "0.2.0-rc.2",
3146
- "@deepseek-ai/dsh-web-search-deepseek": "0.2.0-rc.2",
3147
- "@deepseek-ai/schemastery": "^3.18.4"
3148
- },
3149
- peerDependenciesMeta: {
3150
- "@deepseek-ai/dsh-web-search-deepseek": { "optional": true },
3151
- "@deepseek-ai/dsh-launch-environment": { "optional": true },
3152
- "@deepseek-ai/dsh-api-remotes": { "optional": true },
3153
- "@deepseek-ai/dsh-client-ui-renderer": { "optional": true },
3154
- "@deepseek-ai/dsh-client-ui-settings-models": { "optional": true },
3155
- "@deepseek-ai/dsh-client-ui-slots": { "optional": true },
3156
- "@deepseek-ai/dsh-typert-protocol": { "optional": true }
3157
- },
3158
- dependencies: {
3159
- "@earendil-works/pi-ai": "0.87.1",
3160
- "undici": "6.28.1",
3161
- "zod": "^4.4.3"
3162
- },
3163
- devDependencies: {
3164
- "@deepseek-ai/cordis": "~4.0.4",
3165
- "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
3166
- "@deepseek-ai/dsh-agent-default-model": "0.2.0-rc.2",
3167
- "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
3168
- "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
3169
- "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
3170
- "@deepseek-ai/dsh-jobs": "0.2.0-rc.2",
3171
- "@deepseek-ai/dsh-api-gateway": "0.2.0-rc.2",
3172
- "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
3173
- "@deepseek-ai/dsh-app-boot": "0.2.0-rc.2",
3174
- "@deepseek-ai/dsh-config-editor": "0.2.0-rc.2",
3175
- "@deepseek-ai/dsh-attachment": "0.2.0-rc.2",
3176
- "@deepseek-ai/dsh-authorization": "0.2.0-rc.2",
3177
- "@deepseek-ai/dsh-client-connection": "0.2.0-rc.2",
3178
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
3179
- "@deepseek-ai/dsh-client-ui-settings-models": "0.2.0-rc.2",
3180
- "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
3181
- "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
3182
- "@deepseek-ai/dsh-fs": "0.2.0-rc.2",
3183
- "@deepseek-ai/dsh-launch-environment": "0.2.0-rc.2",
3184
- "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
3185
- "@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
3186
- "@deepseek-ai/dsh-scope": "0.2.0-rc.2",
3187
- "@deepseek-ai/dsh-session": "0.2.0-rc.2",
3188
- "@deepseek-ai/dsh-session-format-catalog": "0.2.0-rc.2",
3189
- "@deepseek-ai/dsh-session-projection": "0.2.0-rc.2",
3190
- "@deepseek-ai/dsh-settings": "0.2.0-rc.2",
3191
- "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
3192
- "@deepseek-ai/dsh-tool-web": "0.2.0-rc.2",
3193
- "@deepseek-ai/dsh-tools": "0.2.0-rc.2",
3194
- "@deepseek-ai/dsh-typert-protocol": "0.2.0-rc.2",
3195
- "@deepseek-ai/dsh-typert-registry": "0.2.0-rc.2",
3196
- "@deepseek-ai/dsh-web": "0.2.0-rc.2",
3197
- "@deepseek-ai/dsh-web-search-deepseek": "0.2.0-rc.2",
3198
- "@deepseek-ai/schemastery": "^3.18.4",
3199
- "@types/node": "^22.0.0",
3200
- "@types/react": "~18.3.1",
3201
- "@types/react-dom": "18.3.7",
3202
- "jsdom": "^26.1.0",
3203
- "react": "^18.2.0",
3204
- "react-dom": "18.3.1",
3205
- "tsdown": "^0.22.2",
3206
- "typescript": "^5.9.0",
3207
- "unrun": "^0.3.1",
3208
- "vitest": "^3.2.0"
3209
- },
3210
- main: "lib/index.js",
3211
- types: "lib/types/index.d.ts",
3212
- imports: { "#package.json": "./package.json" },
3213
- dsh: {
3214
- "bundle": { "patch": "./cordis.patch.yml" },
3215
- "client": {
3216
- "external": ["react"],
3217
- "inject": ["@deepseek-ai/dsh-api-remotes", "@deepseek-ai/dsh-client-ui-settings-models"],
3218
- "platform": "web"
3219
- }
3220
- }
3221
- };
3222
- //#endregion
3223
3835
  //#region lib/types/migration-status.js
3224
3836
  const { name: name$1, version } = package_default;
3225
3837
  const LIMIT = 1024;
@@ -3858,15 +4470,34 @@ var CopilotAccountsHost = class {
3858
4470
  return this.viewForAccount(accountId);
3859
4471
  }
3860
4472
  async readIdentity(accountId, force) {
4473
+ const operation = beginDiagnostics(this.ctx, "identity-read");
4474
+ try {
4475
+ const view = await this.readIdentityObserved(accountId, force, operation);
4476
+ const reason = view.state === "error" ? diagnosticsReason(new Error(view.diagnostic)) : "none";
4477
+ operation?.finish(reason === "none" ? "success" : diagnosticsOutcome(reason), reason);
4478
+ return view;
4479
+ } catch (error) {
4480
+ const reason = diagnosticsReason(error);
4481
+ operation?.finish(diagnosticsOutcome(reason), reason);
4482
+ throw error;
4483
+ }
4484
+ }
4485
+ async readIdentityObserved(accountId, force, operation) {
3861
4486
  id(accountId);
3862
4487
  if (this.disposed) fail("COPILOT_ACCOUNTS_DISPOSED");
3863
4488
  let flight = this.identityFlights.get(accountId);
3864
4489
  let problem;
3865
4490
  const failed = this.identityFailures.get(accountId);
3866
4491
  const cached = this.identities.get(accountId);
3867
- if (flight === void 0 && !force && cached && Date.now() - cached.at < IDENTITY_TTL) return this.viewForAccount(accountId);
3868
- if (flight === void 0 && !force && failed && Date.now() - failed.at < IDENTITY_FAILURE_COOLDOWN) problem = failed.diagnostic;
3869
- else {
4492
+ if (flight === void 0 && !force && cached && Date.now() - cached.at < IDENTITY_TTL) {
4493
+ operation?.stage("cache-hit");
4494
+ return this.viewForAccount(accountId);
4495
+ }
4496
+ if (flight === void 0 && !force && failed && Date.now() - failed.at < IDENTITY_FAILURE_COOLDOWN) {
4497
+ problem = failed.diagnostic;
4498
+ operation?.stage("cooldown");
4499
+ } else {
4500
+ if (flight !== void 0) operation?.stage("joined-flight");
3870
4501
  if (flight === void 0) {
3871
4502
  if (this.identityFlights.size >= 32) fail("COPILOT_ACCOUNTS_LIMIT");
3872
4503
  const abort = new AbortController();
@@ -3878,15 +4509,20 @@ var CopilotAccountsHost = class {
3878
4509
  flight = {
3879
4510
  abort,
3880
4511
  promise: Promise.resolve().then(async () => {
4512
+ const observed = beginDiagnostics(this.ctx, "identity-flight");
4513
+ observed?.stage("identity-validation");
3881
4514
  let lease;
3882
4515
  try {
3883
4516
  signal.throwIfAborted();
3884
4517
  lease = this.acquire(void 0, false, accountId);
3885
4518
  await abortable$1(this.identity(lease.binding, signal), signal);
3886
4519
  this.identityFailures.delete(accountId);
4520
+ observed?.finish("success");
3887
4521
  return;
3888
4522
  } catch (error) {
3889
4523
  const problem = signal.aborted ? signal.reason instanceof DOMException && signal.reason.name === "TimeoutError" ? "COPILOT_ACCOUNTS_IDENTITY_TIMEOUT" : "COPILOT_ACCOUNTS_CHANGED" : diagnostic(error, "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE");
4524
+ const reason = diagnosticsReason(new Error(problem));
4525
+ observed?.finish(diagnosticsOutcome(reason), reason);
3890
4526
  if (!abort.signal.aborted && !this.disposed) {
3891
4527
  this.identities.delete(accountId);
3892
4528
  this.unavailableIdentities.add(accountId);
@@ -3937,6 +4573,8 @@ var CopilotAccountsHost = class {
3937
4573
  if (!expectedKey || value === void 0 || copilotAccountKey(normalizeGitHubCopilotOAuthCredential(value)) !== expectedKey) fail("COPILOT_ACCOUNTS_CHANGED");
3938
4574
  }
3939
4575
  async switchAccount(accountId, expectedRevision) {
4576
+ const observed = beginDiagnostics(this.ctx, "account-global-switch");
4577
+ observed?.stage("host-received");
3940
4578
  let committed = false, fenced = false;
3941
4579
  try {
3942
4580
  id(accountId);
@@ -3956,9 +4594,11 @@ var CopilotAccountsHost = class {
3956
4594
  AbortSignal.timeout(6e4)
3957
4595
  ]);
3958
4596
  const identity = (async () => {
4597
+ observed?.stage("identity-validation");
3959
4598
  await this.identity(binding, signal);
3960
4599
  return this.identities.get(accountId)?.key;
3961
4600
  })();
4601
+ observed?.stage("model-validation");
3962
4602
  const models = this.validateModels(binding, signal);
3963
4603
  let identityKey;
3964
4604
  try {
@@ -3975,6 +4615,7 @@ var CopilotAccountsHost = class {
3975
4615
  if (this.leases.size > 0 || this.ctx.get("authorization")?.describe(recordKey("canonical"))?.inFlight === true) fail("COPILOT_ACCOUNTS_BUSY");
3976
4616
  const current = this.selection();
3977
4617
  if (current.revision !== expectedRevision || current.accountId !== before.accountId) fail("COPILOT_ACCOUNTS_CONFLICT");
4618
+ observed?.stage("cas");
3978
4619
  try {
3979
4620
  await this.settings().mutate("github-copilot", [{
3980
4621
  op: "set",
@@ -3991,6 +4632,7 @@ var CopilotAccountsHost = class {
3991
4632
  fail("COPILOT_ACCOUNTS_CONFLICT");
3992
4633
  }
3993
4634
  committed = true;
4635
+ observed?.stage("readback");
3994
4636
  const after = this.selection();
3995
4637
  if (after.accountId !== accountId || after.revision === expectedRevision) fail("COPILOT_ACCOUNTS_COMMIT_UNCERTAIN");
3996
4638
  await this.assertIdentityCurrent(this.capture(accountId), identityKey);
@@ -3998,10 +4640,21 @@ var CopilotAccountsHost = class {
3998
4640
  this.lastFailure = void 0;
3999
4641
  } catch (error) {
4000
4642
  this.lastFailure = committed ? "COPILOT_ACCOUNTS_COMMIT_UNCERTAIN" : diagnostic(error, "COPILOT_ACCOUNTS_CHANGED");
4643
+ const reason = diagnosticsReason(new Error(this.lastFailure));
4644
+ observed?.finish(diagnosticsOutcome(reason), reason);
4001
4645
  } finally {
4002
4646
  if (fenced) this.operation = void 0;
4003
4647
  }
4004
- return this.get();
4648
+ try {
4649
+ const view = await this.get();
4650
+ const reason = view.state === "error" ? diagnosticsReason(new Error(view.diagnostic)) : "none";
4651
+ observed?.finish(view.state === "error" ? diagnosticsOutcome(reason) : "success", reason);
4652
+ return view;
4653
+ } catch (error) {
4654
+ const reason = diagnosticsReason(error);
4655
+ observed?.finish(diagnosticsOutcome(reason), reason);
4656
+ throw error;
4657
+ }
4005
4658
  }
4006
4659
  async add() {
4007
4660
  return this.authorize(randomUUID());
@@ -5062,10 +5715,11 @@ var SessionAccountsHost = class {
5062
5715
  if (!binding) throw new Error("COPILOT_SESSION_ACCOUNTS_UNAVAILABLE");
5063
5716
  return this.bindingForAccount(binding.accountId);
5064
5717
  }
5065
- async set(agent, accountId, revision) {
5718
+ async set(agent, accountId, revision, observed) {
5066
5719
  const accounts = this.ctx.get("githubCopilotAccounts");
5067
5720
  if (!accounts) throw new Error("COPILOT_SESSION_ACCOUNTS_UNAVAILABLE");
5068
5721
  if (accountId !== null) {
5722
+ observed?.stage("identity-validation");
5069
5723
  const binding = this.bindingForAccount(accountId);
5070
5724
  await accounts.host.validateAccount(binding);
5071
5725
  }
@@ -5080,11 +5734,13 @@ var SessionAccountsHost = class {
5080
5734
  accountId
5081
5735
  });
5082
5736
  if (next.length > 2048) throw new Error("COPILOT_SESSION_ACCOUNTS_LIMIT");
5737
+ observed?.stage("cas");
5083
5738
  await settings.mutate("github-copilot", [{
5084
5739
  op: "set",
5085
5740
  path: ["sessionAccounts"],
5086
5741
  value: next
5087
5742
  }], revision);
5743
+ observed?.stage("readback");
5088
5744
  const actual = this.selected(agent);
5089
5745
  if (actual.source !== (accountId === null ? "global" : "session") || accountId !== null && actual.accountId !== accountId) throw new Error("COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN");
5090
5746
  }
@@ -5256,8 +5912,20 @@ let SessionAccountController = (() => {
5256
5912
  };
5257
5913
  }
5258
5914
  async set(agent, accountId, revision) {
5259
- await this.owner.set(agent, accountId, revision);
5260
- return this.get(agent);
5915
+ const operation = beginDiagnostics(this.ctx, accountId === null ? "account-session-inherit" : "account-session-select");
5916
+ operation?.stage("host-received");
5917
+ try {
5918
+ await this.owner.set(agent, accountId, revision, operation);
5919
+ operation?.stage("readback");
5920
+ const result = await this.get(agent);
5921
+ const reason = result.accounts.state === "error" ? diagnosticsReason(new Error(result.accounts.diagnostic)) : "none";
5922
+ operation?.finish(result.accounts.state === "error" ? diagnosticsOutcome(reason) : "success", reason);
5923
+ return result;
5924
+ } catch (error) {
5925
+ const reason = diagnosticsReason(error);
5926
+ operation?.finish(diagnosticsOutcome(reason), reason);
5927
+ throw error;
5928
+ }
5261
5929
  }
5262
5930
  async refreshIdentity(agent) {
5263
5931
  return this.readIdentity(agent, true);
@@ -5311,21 +5979,21 @@ function isZeroContextUsage(usage) {
5311
5979
  //#endregion
5312
5980
  //#region lib/types/context-evidence.js
5313
5981
  const COPILOT_CONTEXT_EVIDENCE = "githubCopilotContextEvidence";
5314
- const count$2 = z$1.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
5315
- const routeSchema = z$1.object({
5316
- provider: z$1.string().min(1),
5317
- model: z$1.string().min(1)
5982
+ const count$2 = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
5983
+ const routeSchema = z.object({
5984
+ provider: z.string().min(1),
5985
+ model: z.string().min(1)
5318
5986
  }).strict();
5319
- const sampleSchema = z$1.object({
5987
+ const sampleSchema = z.object({
5320
5988
  tokens: count$2,
5321
5989
  seq: count$2,
5322
5990
  route: routeSchema
5323
5991
  }).strict();
5324
- const ContextEvidenceSchema = z$1.object({
5992
+ const ContextEvidenceSchema = z.object({
5325
5993
  route: routeSchema.nullable(),
5326
5994
  sample: sampleSchema.nullable(),
5327
- invalid: z$1.boolean(),
5328
- reason: z$1.enum([
5995
+ invalid: z.boolean(),
5996
+ reason: z.enum([
5329
5997
  "none",
5330
5998
  "failed-zero",
5331
5999
  "compaction",
@@ -5333,7 +6001,7 @@ const ContextEvidenceSchema = z$1.object({
5333
6001
  "unknown"
5334
6002
  ])
5335
6003
  }).strict();
5336
- const usageSchema = z$1.object({
6004
+ const usageSchema = z.object({
5337
6005
  inputTokens: count$2,
5338
6006
  outputTokens: count$2,
5339
6007
  cacheReadTokens: count$2.optional(),
@@ -5804,10 +6472,10 @@ const WEB_SEARCH_ROUTING_SETTINGS_NAMESPACE = "github-copilot-search-routing";
5804
6472
  /** Sentinel that disables the default/fixed search backend. */
5805
6473
  const NO_DEFAULT_SEARCH_PROVIDER = "none";
5806
6474
  /** User-facing routing settings; provider-specific credentials and models remain provider-owned. */
5807
- const WebSearchRoutingConfigSchema = z.object({
5808
- searchProvider: z.string(),
5809
- searchMode: z.union(["auto", "fixed"]).default("auto"),
5810
- defaultSearchProvider: z.string().default("deepseek-official")
6475
+ const WebSearchRoutingConfigSchema = z$1.object({
6476
+ searchProvider: z$1.string(),
6477
+ searchMode: z$1.union(["auto", "fixed"]).default("auto"),
6478
+ defaultSearchProvider: z$1.string().default("deepseek-official")
5811
6479
  });
5812
6480
  //#endregion
5813
6481
  //#region lib/types/config.js
@@ -5826,6 +6494,7 @@ function readInlineConfig(config) {
5826
6494
  const defaults = readConfigValue(config.continuationDefaultHistory);
5827
6495
  return {
5828
6496
  ...config,
6497
+ diagnosticsEnabled: readConfigValue(config.diagnosticsEnabled),
5829
6498
  continuationDefaultHistory: defaults === void 0 ? void 0 : Array.from(defaults, (row) => ({
5830
6499
  enabled: row.enabled,
5831
6500
  changedAt: row.changedAt
@@ -5856,51 +6525,52 @@ function readInlineConfig(config) {
5856
6525
  /** Longest timer either bound may take; `setTimeout`/`AbortSignal.timeout` refuse more. */
5857
6526
  const MAX_TIMEOUT_MS = 2147483647;
5858
6527
  /** Schema of the plugin's settings section. */
5859
- const Config = z.object({
5860
- enabled: z.boolean().default(true),
5861
- providers: z.array(z.string()).default([]),
5862
- includeSources: z.boolean().default(true),
5863
- stripServerTools: z.boolean().default(true),
5864
- idleTimeoutMs: z.number().step(1).min(1).max(MAX_TIMEOUT_MS).default(3e5),
5865
- chatStreamIdleTimeoutMs: z.number().step(1).min(1).max(MAX_TIMEOUT_MS).default(3e5),
5866
- chatStreamLiveness: z.boolean().default(true),
5867
- chatMaxRequestImageBytes: z.number().step(1).min(1).max(Number.MAX_SAFE_INTEGER).default(20971520),
5868
- probe: z.boolean().default(true),
5869
- probeTimeoutMs: z.number().step(1).min(1).max(MAX_TIMEOUT_MS).default(3e4),
5870
- accountModelTtlMs: z.number().step(1).min(0).max(MAX_TIMEOUT_MS).default(864e5),
5871
- accountModelFailureCooldownMs: z.number().step(1).min(0).max(MAX_TIMEOUT_MS).default(3e5),
5872
- excludedModelIds: z.array(z.string()).default([]).hidden().volatile(),
5873
- highCostModelIds: z.array(z.string()).default([]).hidden().volatile(),
5874
- activeAccountId: z.string().hidden().volatile(),
5875
- sessionAccounts: z.array(z.object({
5876
- sessionId: z.string().min(1).max(256),
5877
- accountId: z.string().min(1).max(36)
6528
+ const Config = z$1.object({
6529
+ diagnosticsEnabled: z$1.boolean().default(false).hidden().volatile(),
6530
+ enabled: z$1.boolean().default(true),
6531
+ providers: z$1.array(z$1.string()).default([]),
6532
+ includeSources: z$1.boolean().default(true),
6533
+ stripServerTools: z$1.boolean().default(true),
6534
+ idleTimeoutMs: z$1.number().step(1).min(1).max(MAX_TIMEOUT_MS).default(3e5),
6535
+ chatStreamIdleTimeoutMs: z$1.number().step(1).min(1).max(MAX_TIMEOUT_MS).default(3e5),
6536
+ chatStreamLiveness: z$1.boolean().default(true),
6537
+ chatMaxRequestImageBytes: z$1.number().step(1).min(1).max(Number.MAX_SAFE_INTEGER).default(20971520),
6538
+ probe: z$1.boolean().default(true),
6539
+ probeTimeoutMs: z$1.number().step(1).min(1).max(MAX_TIMEOUT_MS).default(3e4),
6540
+ accountModelTtlMs: z$1.number().step(1).min(0).max(MAX_TIMEOUT_MS).default(864e5),
6541
+ accountModelFailureCooldownMs: z$1.number().step(1).min(0).max(MAX_TIMEOUT_MS).default(3e5),
6542
+ excludedModelIds: z$1.array(z$1.string()).default([]).hidden().volatile(),
6543
+ highCostModelIds: z$1.array(z$1.string()).default([]).hidden().volatile(),
6544
+ activeAccountId: z$1.string().hidden().volatile(),
6545
+ sessionAccounts: z$1.array(z$1.object({
6546
+ sessionId: z$1.string().min(1).max(256),
6547
+ accountId: z$1.string().min(1).max(36)
5878
6548
  })).default([]).hidden().volatile(),
5879
- sessionContinuation: z.array(z.object({
5880
- sessionId: z.string().min(1).max(256),
5881
- version: z.const(1),
5882
- consentedAt: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER),
5883
- enabled: z.boolean()
6549
+ sessionContinuation: z$1.array(z$1.object({
6550
+ sessionId: z$1.string().min(1).max(256),
6551
+ version: z$1.const(1),
6552
+ consentedAt: z$1.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER),
6553
+ enabled: z$1.boolean()
5884
6554
  })).default([]).hidden().volatile(),
5885
- continuationDefaultHistory: z.array(z.object({
5886
- enabled: z.boolean(),
5887
- changedAt: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER)
6555
+ continuationDefaultHistory: z$1.array(z$1.object({
6556
+ enabled: z$1.boolean(),
6557
+ changedAt: z$1.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER)
5888
6558
  })).default([]).hidden().volatile(),
5889
- followParentModel: z.boolean().default(false).volatile(),
5890
- autoSemanticAssessment: z.boolean().default(true),
5891
- autoAllocationEvidence: z.boolean().default(true),
5892
- parentModelFollow: z.array(z.object({
5893
- childSessionId: z.string().min(1),
5894
- parentSessionId: z.string().min(1)
6559
+ followParentModel: z$1.boolean().default(false).volatile(),
6560
+ autoSemanticAssessment: z$1.boolean().default(true),
6561
+ autoAllocationEvidence: z$1.boolean().default(true),
6562
+ parentModelFollow: z$1.array(z$1.object({
6563
+ childSessionId: z$1.string().min(1),
6564
+ parentSessionId: z$1.string().min(1)
5895
6565
  })).default([]).hidden().volatile(),
5896
- requestBudgetSafetyTokens: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER).default(DEFAULT_REQUEST_BUDGET_POLICY.safetyTokens),
5897
- requestBudgetPressureRatio: z.number().step(.01).min(.01).max(1).default(DEFAULT_REQUEST_BUDGET_POLICY.pressureRatio),
5898
- compactionReasoning: z.union(["prefer-low", "preserve"]).default(DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning),
5899
- routeWebSearch: z.boolean().default(true),
5900
- searchFallback: z.union(["none", "deepseek"]).default("deepseek"),
5901
- searchModel: z.string().hidden().volatile(),
6566
+ requestBudgetSafetyTokens: z$1.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER).default(DEFAULT_REQUEST_BUDGET_POLICY.safetyTokens),
6567
+ requestBudgetPressureRatio: z$1.number().step(.01).min(.01).max(1).default(DEFAULT_REQUEST_BUDGET_POLICY.pressureRatio),
6568
+ compactionReasoning: z$1.union(["prefer-low", "preserve"]).default(DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning),
6569
+ routeWebSearch: z$1.boolean().default(true),
6570
+ searchFallback: z$1.union(["none", "deepseek"]).default("deepseek"),
6571
+ searchModel: z$1.string().hidden().volatile(),
5902
6572
  searchRouting: WebSearchRoutingConfigSchema.default({}).volatile(),
5903
- temporaryRouteBackup: z.string().hidden().volatile()
6573
+ temporaryRouteBackup: z$1.string().hidden().volatile()
5904
6574
  });
5905
6575
  //#endregion
5906
6576
  //#region lib/types/search-tool-routing.js
@@ -7924,15 +8594,15 @@ function excludedModelSet(value) {
7924
8594
  //#endregion
7925
8595
  //#region lib/types/auto-allocation.js
7926
8596
  const AUTO_ALLOCATION_POLICY = "high-cost-v1";
7927
- const AutoAllocationSchema = z$1.object({
7928
- policyVersion: z$1.literal(AUTO_ALLOCATION_POLICY),
7929
- selectedModelId: z$1.string().min(1).max(512),
7930
- candidates: z$1.array(z$1.object({
7931
- modelId: z$1.string().min(1).max(512),
7932
- highCost: z$1.boolean(),
7933
- previous: z$1.boolean(),
7934
- weight: z$1.number().positive().max(1.5),
7935
- expectedShare: z$1.number().positive().max(1)
8597
+ const AutoAllocationSchema = z.object({
8598
+ policyVersion: z.literal(AUTO_ALLOCATION_POLICY),
8599
+ selectedModelId: z.string().min(1).max(512),
8600
+ candidates: z.array(z.object({
8601
+ modelId: z.string().min(1).max(512),
8602
+ highCost: z.boolean(),
8603
+ previous: z.boolean(),
8604
+ weight: z.number().positive().max(1.5),
8605
+ expectedShare: z.number().positive().max(1)
7936
8606
  }).strict()).min(1).max(512)
7937
8607
  }).strict().refine((value) => {
7938
8608
  const total = value.candidates.reduce((sum, row) => sum + row.weight, 0);
@@ -9304,9 +9974,9 @@ var SessionContinuationTurn = class {
9304
9974
  //#endregion
9305
9975
  //#region lib/types/session-continuation-types.js
9306
9976
  const COMPACTION_CONTINUATION = "githubCopilotCompactionLifecycle";
9307
- const CompactionContinuationStatusSchema = z$1.object({
9308
- id: z$1.string().min(1).max(256),
9309
- state: z$1.enum([
9977
+ const CompactionContinuationStatusSchema = z.object({
9978
+ id: z.string().min(1).max(256),
9979
+ state: z.enum([
9310
9980
  "running",
9311
9981
  "completed",
9312
9982
  "failed",
@@ -9314,31 +9984,31 @@ const CompactionContinuationStatusSchema = z$1.object({
9314
9984
  "blocked"
9315
9985
  ])
9316
9986
  }).strict();
9317
- const CompactionContinuationLifecycleSchema = z$1.object({
9318
- id: z$1.string().nullable(),
9319
- running: z$1.boolean()
9987
+ const CompactionContinuationLifecycleSchema = z.object({
9988
+ id: z.string().nullable(),
9989
+ running: z.boolean()
9320
9990
  }).strict();
9321
- const SessionContinuationPreferenceSchema = z$1.object({
9322
- sessionId: z$1.string().min(1).max(256).refine((value) => !/[\p{Cc}\p{Cf}]/u.test(value)),
9323
- version: z$1.literal(1),
9324
- consentedAt: z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
9325
- enabled: z$1.boolean().optional()
9991
+ const SessionContinuationPreferenceSchema = z.object({
9992
+ sessionId: z.string().min(1).max(256).refine((value) => !/[\p{Cc}\p{Cf}]/u.test(value)),
9993
+ version: z.literal(1),
9994
+ consentedAt: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
9995
+ enabled: z.boolean().optional()
9326
9996
  }).strict();
9327
- const SessionContinuationPreferencesSchema = z$1.array(SessionContinuationPreferenceSchema).max(2048).refine((rows) => new Set(rows.map((row) => row.sessionId)).size === rows.length);
9328
- const ContinuationDefaultHistorySchema = z$1.array(z$1.object({
9329
- enabled: z$1.boolean(),
9330
- changedAt: z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
9997
+ const SessionContinuationPreferencesSchema = z.array(SessionContinuationPreferenceSchema).max(2048).refine((rows) => new Set(rows.map((row) => row.sessionId)).size === rows.length);
9998
+ const ContinuationDefaultHistorySchema = z.array(z.object({
9999
+ enabled: z.boolean(),
10000
+ changedAt: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
9331
10001
  }).strict()).max(2048).refine((rows) => rows.every((row, index) => index === 0 || row.changedAt > rows[index - 1].changedAt));
9332
- z$1.object({
9333
- enabled: z$1.boolean(),
9334
- revision: z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
10002
+ z.object({
10003
+ enabled: z.boolean(),
10004
+ revision: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
9335
10005
  }).strict();
9336
- z$1.object({
9337
- enabled: z$1.boolean(),
9338
- revision: z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
9339
- activeTurnEnabled: z$1.boolean().optional(),
9340
- source: z$1.enum(["default", "session"]).optional(),
9341
- nextTurnAuthorized: z$1.boolean().optional(),
10006
+ z.object({
10007
+ enabled: z.boolean(),
10008
+ revision: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
10009
+ activeTurnEnabled: z.boolean().optional(),
10010
+ source: z.enum(["default", "session"]).optional(),
10011
+ nextTurnAuthorized: z.boolean().optional(),
9342
10012
  compaction: CompactionContinuationStatusSchema.optional()
9343
10013
  }).strict();
9344
10014
  //#endregion
@@ -10050,12 +10720,12 @@ function installCopilotPreStepPressure(ctx, callbacks) {
10050
10720
  }
10051
10721
  //#endregion
10052
10722
  //#region lib/types/auto-assessment-evidence.js
10053
- const milliseconds = z$1.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
10054
- const SemanticAssessmentEvidenceSchema = z$1.object({
10055
- modelId: z$1.string().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u).optional(),
10723
+ const milliseconds = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
10724
+ const SemanticAssessmentEvidenceSchema = z.object({
10725
+ modelId: z.string().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u).optional(),
10056
10726
  budgetMs: milliseconds.refine((value) => value > 0),
10057
10727
  elapsedMs: milliseconds,
10058
- stage: z$1.enum([
10728
+ stage: z.enum([
10059
10729
  "preparing",
10060
10730
  "model-selected",
10061
10731
  "adapter-started",
@@ -10064,9 +10734,9 @@ const SemanticAssessmentEvidenceSchema = z$1.object({
10064
10734
  ]),
10065
10735
  adapterStartedMs: milliseconds.optional(),
10066
10736
  firstTextMs: milliseconds.optional(),
10067
- nativeFinish: z$1.enum(["stop", "non-stop"]).optional(),
10068
- outputCharacters: z$1.number().int().min(0).max(2049),
10069
- validation: z$1.enum([
10737
+ nativeFinish: z.enum(["stop", "non-stop"]).optional(),
10738
+ outputCharacters: z.number().int().min(0).max(2049),
10739
+ validation: z.enum([
10070
10740
  "not-validated",
10071
10741
  "valid",
10072
10742
  "invalid",
@@ -10133,14 +10803,14 @@ function assessmentEvidence(budgetMs) {
10133
10803
  }
10134
10804
  //#endregion
10135
10805
  //#region lib/types/auto-task-assessment.js
10136
- const TaskAssessmentSchema = z$1.object({
10137
- demand: z$1.enum([
10806
+ const TaskAssessmentSchema = z.object({
10807
+ demand: z.enum([
10138
10808
  "simple",
10139
10809
  "routine",
10140
10810
  "complex",
10141
10811
  "unknown"
10142
10812
  ]),
10143
- signals: z$1.array(z$1.enum([
10813
+ signals: z.array(z.enum([
10144
10814
  "isolated-greeting",
10145
10815
  "bounded-transformation",
10146
10816
  "reasoning",
@@ -10576,30 +11246,30 @@ function autoModelInputModalities(models) {
10576
11246
  }
10577
11247
  //#endregion
10578
11248
  //#region lib/types/auto-allocation-evidence.js
10579
- const AutoAllocationSummarySchema = z$1.object({
10580
- policyVersion: z$1.literal(AUTO_ALLOCATION_POLICY),
10581
- scope: z$1.literal("viewed-session-host-lifetime"),
10582
- status: z$1.enum(["observed", "not-collected"]),
10583
- retainedDecisions: z$1.number().int().nonnegative().max(128),
10584
- noFitDecisions: z$1.number().int().nonnegative().max(128),
10585
- rowsTruncated: z$1.boolean(),
10586
- completeHistory: z$1.literal(false),
10587
- observationStart: z$1.number().int().nonnegative().nullable(),
10588
- observationEnd: z$1.number().int().nonnegative().nullable(),
10589
- rows: z$1.array(z$1.object({
10590
- modelId: z$1.string().min(1).max(512),
10591
- category: z$1.enum([
11249
+ const AutoAllocationSummarySchema = z.object({
11250
+ policyVersion: z.literal(AUTO_ALLOCATION_POLICY),
11251
+ scope: z.literal("viewed-session-host-lifetime"),
11252
+ status: z.enum(["observed", "not-collected"]),
11253
+ retainedDecisions: z.number().int().nonnegative().max(128),
11254
+ noFitDecisions: z.number().int().nonnegative().max(128),
11255
+ rowsTruncated: z.boolean(),
11256
+ completeHistory: z.literal(false),
11257
+ observationStart: z.number().int().nonnegative().nullable(),
11258
+ observationEnd: z.number().int().nonnegative().nullable(),
11259
+ rows: z.array(z.object({
11260
+ modelId: z.string().min(1).max(512),
11261
+ category: z.enum([
10592
11262
  "powerful",
10593
11263
  "versatile",
10594
11264
  "lightweight",
10595
11265
  "unknown"
10596
11266
  ]),
10597
- highCost: z$1.boolean(),
10598
- previous: z$1.boolean(),
10599
- weight: z$1.number().positive().max(1.5),
10600
- opportunities: z$1.number().int().positive().max(128),
10601
- expectedSelections: z$1.number().nonnegative().max(128),
10602
- selections: z$1.number().int().nonnegative().max(128)
11267
+ highCost: z.boolean(),
11268
+ previous: z.boolean(),
11269
+ weight: z.number().positive().max(1.5),
11270
+ opportunities: z.number().int().positive().max(128),
11271
+ expectedSelections: z.number().nonnegative().max(128),
11272
+ selections: z.number().int().nonnegative().max(128)
10603
11273
  }).strict()).max(512)
10604
11274
  }).strict();
10605
11275
  /** Recompute only from captured bounded decisions, never today's settings or history content. */
@@ -10662,10 +11332,10 @@ function summarizeAutoAllocations(explanations, window) {
10662
11332
  }
10663
11333
  //#endregion
10664
11334
  //#region lib/types/turn-selection.js
10665
- const ExplanationSchema = z$1.object({
11335
+ const ExplanationSchema = z.object({
10666
11336
  assessment: TaskAssessmentSchema.extend({
10667
- source: z$1.enum(["local", "semantic"]),
10668
- diagnostic: z$1.enum([
11337
+ source: z.enum(["local", "semantic"]),
11338
+ diagnostic: z.enum([
10669
11339
  "disabled",
10670
11340
  "unavailable",
10671
11341
  "invalid-result",
@@ -10675,46 +11345,46 @@ const ExplanationSchema = z$1.object({
10675
11345
  ]).optional(),
10676
11346
  semantic: SemanticAssessmentEvidenceSchema.optional()
10677
11347
  }).strict(),
10678
- targetCategory: z$1.enum([
11348
+ targetCategory: z.enum([
10679
11349
  "powerful",
10680
11350
  "versatile",
10681
11351
  "lightweight"
10682
11352
  ]),
10683
- selectedCategory: z$1.enum([
11353
+ selectedCategory: z.enum([
10684
11354
  "powerful",
10685
11355
  "versatile",
10686
11356
  "lightweight",
10687
11357
  "unknown"
10688
11358
  ]),
10689
- categoryCandidateCount: z$1.number().int().min(0).max(512),
10690
- method: z$1.enum([
11359
+ categoryCandidateCount: z.number().int().min(0).max(512),
11360
+ method: z.enum([
10691
11361
  "continuity",
10692
11362
  "equal-distribution",
10693
11363
  "weighted-distribution",
10694
11364
  "only-candidate",
10695
11365
  "no-fit"
10696
11366
  ]),
10697
- fallback: z$1.boolean(),
11367
+ fallback: z.boolean(),
10698
11368
  allocation: AutoAllocationSchema.optional()
10699
11369
  }).strict();
10700
- z$1.discriminatedUnion("mode", [
10701
- z$1.object({ mode: z$1.literal("unknown") }).strict(),
10702
- z$1.object({ mode: z$1.literal("manual") }).strict(),
10703
- z$1.object({
10704
- mode: z$1.literal("auto"),
10705
- preference: z$1.enum([
11370
+ z.discriminatedUnion("mode", [
11371
+ z.object({ mode: z.literal("unknown") }).strict(),
11372
+ z.object({ mode: z.literal("manual") }).strict(),
11373
+ z.object({
11374
+ mode: z.literal("auto"),
11375
+ preference: z.enum([
10706
11376
  "efficiency",
10707
11377
  "balance",
10708
11378
  "intelligence"
10709
11379
  ]),
10710
- reason: z$1.enum([
11380
+ reason: z.enum([
10711
11381
  "short-text-turn",
10712
11382
  "standard-turn",
10713
11383
  "large-structured-turn",
10714
11384
  "image-capability"
10715
11385
  ]),
10716
- candidateCount: z$1.number().int().positive(),
10717
- fittingCandidateCount: z$1.number().int().nonnegative().optional(),
11386
+ candidateCount: z.number().int().positive(),
11387
+ fittingCandidateCount: z.number().int().nonnegative().optional(),
10718
11388
  explanation: ExplanationSchema.optional()
10719
11389
  }).strict()
10720
11390
  ]);
@@ -10787,21 +11457,21 @@ var TurnSelectionStore = class {
10787
11457
  //#endregion
10788
11458
  //#region lib/types/turn-request-models.js
10789
11459
  const TURN_REQUEST_MODELS = "githubCopilotTurnRequestModels";
10790
- const count$1 = z$1.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
10791
- const route = z$1.object({
10792
- provider: z$1.string().trim().min(1).max(1024),
10793
- model: z$1.string().trim().min(1).max(1024)
11460
+ const count$1 = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
11461
+ const route = z.object({
11462
+ provider: z.string().trim().min(1).max(1024),
11463
+ model: z.string().trim().min(1).max(1024)
10794
11464
  }).strict();
10795
- const row = z$1.object({
10796
- routes: z$1.array(route).max(32),
10797
- incomplete: z$1.boolean()
11465
+ const row = z.object({
11466
+ routes: z.array(route).max(32),
11467
+ incomplete: z.boolean()
10798
11468
  }).strict().extend({ turn: count$1 }).strict();
10799
- const TurnRequestModelsStateSchema = z$1.object({
10800
- active: z$1.object({
11469
+ const TurnRequestModelsStateSchema = z.object({
11470
+ active: z.object({
10801
11471
  turn: count$1,
10802
11472
  step: count$1.nullable()
10803
11473
  }).strict().nullable(),
10804
- turns: z$1.array(row).max(128)
11474
+ turns: z.array(row).max(128)
10805
11475
  }).strict();
10806
11476
  function record$3(value) {
10807
11477
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -11161,15 +11831,15 @@ function resolveParentModel(child, bindings, lookup, followAll = false) {
11161
11831
  //#endregion
11162
11832
  //#region lib/types/auto-model-intent.js
11163
11833
  const AUTO_MODEL_INTENT_PROJECTION = "githubCopilotAutoModelIntent";
11164
- const count = z$1.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
11165
- const selectionSchema = z$1.object({
11166
- provider: z$1.string().min(1),
11167
- model: z$1.string().min(1)
11834
+ const count = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
11835
+ const selectionSchema = z.object({
11836
+ provider: z.string().min(1),
11837
+ model: z.string().min(1)
11168
11838
  }).strict();
11169
- const AutoModelIntentSchema = z$1.object({
11839
+ const AutoModelIntentSchema = z.object({
11170
11840
  inherited: count,
11171
11841
  selection: selectionSchema.nullable(),
11172
- blocked: z$1.boolean()
11842
+ blocked: z.boolean()
11173
11843
  }).strict();
11174
11844
  function record$1(value) {
11175
11845
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -11368,17 +12038,17 @@ function installAutoModelRouting(ctx, dependencies) {
11368
12038
  const agentDisposers = /* @__PURE__ */ new WeakMap();
11369
12039
  const activeDisposers = /* @__PURE__ */ new Set();
11370
12040
  const followed = /* @__PURE__ */ new WeakMap();
11371
- const selectionSchema = z$1.object({
11372
- provider: z$1.string().min(1),
11373
- model: z$1.string().min(1)
12041
+ const selectionSchema = z.object({
12042
+ provider: z.string().min(1),
12043
+ model: z.string().min(1)
11374
12044
  }).strict();
11375
- const followSchema = z$1.object({
11376
- inherited: z$1.number().int().nonnegative(),
11377
- turn: z$1.number().int().nonnegative().nullable(),
11378
- started: z$1.boolean(),
12045
+ const followSchema = z.object({
12046
+ inherited: z.number().int().nonnegative(),
12047
+ turn: z.number().int().nonnegative().nullable(),
12048
+ started: z.boolean(),
11379
12049
  explicit: selectionSchema.nullable(),
11380
- descriptor: z$1.boolean(),
11381
- blocked: z$1.boolean()
12050
+ descriptor: z.boolean(),
12051
+ blocked: z.boolean()
11382
12052
  }).strict();
11383
12053
  let removeFollowProjection;
11384
12054
  const followIntent = (agent) => {
@@ -12905,6 +13575,9 @@ function observeSettingsNamespace(ctx, namespace, config, hooks) {
12905
13575
  * @param config - the composition entry config, used as the settings base layer.
12906
13576
  */
12907
13577
  function apply(ctx, config) {
13578
+ ctx.plugin({ apply(scope) {
13579
+ new DiagnosticsController(scope);
13580
+ } });
12908
13581
  installCopilotToolSchemaCompatibility(ctx);
12909
13582
  installContextEvidence(ctx);
12910
13583
  let promptText = () => "";