dsh-github-copilot 0.4.0-alpha.100

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 (156) hide show
  1. package/AGENTS.md +312 -0
  2. package/CHANGELOG.md +479 -0
  3. package/CONTRIBUTING.md +46 -0
  4. package/LICENSE +21 -0
  5. package/README.md +203 -0
  6. package/README.zh.md +202 -0
  7. package/SECURITY.md +29 -0
  8. package/cordis.patch.yml +16 -0
  9. package/deployment-baseline.json +1299 -0
  10. package/docs/agent-readiness.md +110 -0
  11. package/docs/auto-task-routing.md +234 -0
  12. package/docs/automatic-model-routing.md +205 -0
  13. package/docs/copilot-accounts.md +236 -0
  14. package/docs/copilot-compaction.md +120 -0
  15. package/docs/copilot-usage.md +125 -0
  16. package/docs/dual-model.md +66 -0
  17. package/docs/image-input-compatibility.md +64 -0
  18. package/docs/images/copilot-accounts-credits.png +0 -0
  19. package/docs/images/copilot-accounts.png +0 -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/dual-model-desktop.png +0 -0
  23. package/docs/images/dual-model-mobile.png +0 -0
  24. package/docs/images/dual-model-provenance.json +35 -0
  25. package/docs/images/parent-model-follow.png +0 -0
  26. package/docs/manual-compaction-recovery.md +64 -0
  27. package/docs/model-compatibility-acceptance.md +164 -0
  28. package/docs/npm-distribution.md +149 -0
  29. package/docs/official-first-016-alpha2.md +66 -0
  30. package/docs/official-first-020-rc1.md +32 -0
  31. package/docs/official-first-020-rc2.md +16 -0
  32. package/docs/session-search-routing.md +133 -0
  33. package/docs/single-route-migration.md +130 -0
  34. package/docs/web-lifecycle-rc2.md +55 -0
  35. package/lib/client.js +10822 -0
  36. package/lib/client.js.map +1 -0
  37. package/lib/copilot-identity-DRZY_d2X.js +15 -0
  38. package/lib/index.js +11689 -0
  39. package/lib/manual-compaction-recovery.js +315 -0
  40. package/lib/remote.js +734 -0
  41. package/lib/request-budget-DLY_aRq0.js +87 -0
  42. package/lib/routed-web.js +120 -0
  43. package/lib/search-routing-CqysPLve.js +792 -0
  44. package/lib/types/account-model-auth.d.ts +15 -0
  45. package/lib/types/account-model-catalog.d.ts +70 -0
  46. package/lib/types/account-model-source.d.ts +85 -0
  47. package/lib/types/agent-compaction.d.ts +4 -0
  48. package/lib/types/authorization-controller.d.ts +119 -0
  49. package/lib/types/auto-assessment-evidence.d.ts +46 -0
  50. package/lib/types/auto-model-host.d.ts +27 -0
  51. package/lib/types/auto-model-intent.d.ts +36 -0
  52. package/lib/types/auto-model-presentation.d.ts +57 -0
  53. package/lib/types/auto-model-routing.d.ts +59 -0
  54. package/lib/types/auto-selection-explanation.d.ts +9 -0
  55. package/lib/types/auto-task-assessment.d.ts +47 -0
  56. package/lib/types/auto-task-classifier.d.ts +9 -0
  57. package/lib/types/background-compaction.d.ts +30 -0
  58. package/lib/types/client.d.ts +115 -0
  59. package/lib/types/compact-account.d.ts +42 -0
  60. package/lib/types/compaction-pressure.d.ts +23 -0
  61. package/lib/types/compatibility.d.ts +17 -0
  62. package/lib/types/config.d.ts +89 -0
  63. package/lib/types/content-file.d.ts +10 -0
  64. package/lib/types/context-evidence-ui.d.ts +11 -0
  65. package/lib/types/context-evidence.d.ts +108 -0
  66. package/lib/types/context-usage.d.ts +4 -0
  67. package/lib/types/copilot-account-presentation.d.ts +7 -0
  68. package/lib/types/copilot-accounts-card.d.ts +30 -0
  69. package/lib/types/copilot-accounts-host.d.ts +75 -0
  70. package/lib/types/copilot-accounts-remote.d.ts +77 -0
  71. package/lib/types/copilot-accounts-types.d.ts +42 -0
  72. package/lib/types/copilot-auth.d.ts +25 -0
  73. package/lib/types/copilot-grant.d.ts +11 -0
  74. package/lib/types/copilot-identity.d.ts +11 -0
  75. package/lib/types/copilot-request.d.ts +11 -0
  76. package/lib/types/copilot-stream-liveness.d.ts +23 -0
  77. package/lib/types/copilot-usage-card.d.ts +30 -0
  78. package/lib/types/copilot-usage-host.d.ts +58 -0
  79. package/lib/types/copilot-usage-normalize.d.ts +9 -0
  80. package/lib/types/copilot-usage-remote.d.ts +63 -0
  81. package/lib/types/copilot-usage-types.d.ts +20 -0
  82. package/lib/types/copilot-usage-ui.d.ts +4 -0
  83. package/lib/types/current-provider.d.ts +59 -0
  84. package/lib/types/deepseek-search-fallback.d.ts +11 -0
  85. package/lib/types/dual-model-host.d.ts +119 -0
  86. package/lib/types/dual-model-remote.d.ts +63 -0
  87. package/lib/types/dual-model-types.d.ts +34 -0
  88. package/lib/types/external-link.d.ts +3 -0
  89. package/lib/types/failure.d.ts +38 -0
  90. package/lib/types/http.d.ts +48 -0
  91. package/lib/types/image-input-admission.d.ts +5 -0
  92. package/lib/types/index.d.ts +39 -0
  93. package/lib/types/manual-compaction-recovery.d.ts +52 -0
  94. package/lib/types/migration-status.d.ts +50 -0
  95. package/lib/types/model-exclusions.d.ts +15 -0
  96. package/lib/types/model-preferences-card.d.ts +9 -0
  97. package/lib/types/model-protocol.d.ts +31 -0
  98. package/lib/types/native-select-style.d.ts +4 -0
  99. package/lib/types/parent-model-follow-card.d.ts +41 -0
  100. package/lib/types/parent-model-follow.d.ts +44 -0
  101. package/lib/types/pi-provider-bridge.d.ts +22 -0
  102. package/lib/types/plan.d.ts +148 -0
  103. package/lib/types/pre-step-pressure.d.ts +8 -0
  104. package/lib/types/preview-provider.d.ts +66 -0
  105. package/lib/types/preview-route.d.ts +74 -0
  106. package/lib/types/probe.d.ts +39 -0
  107. package/lib/types/reasoning-presentation.d.ts +55 -0
  108. package/lib/types/remote-codec.d.ts +10 -0
  109. package/lib/types/remote.d.ts +199 -0
  110. package/lib/types/replay-recovery-host.d.ts +28 -0
  111. package/lib/types/replay-recovery-remote.d.ts +14 -0
  112. package/lib/types/replay-recovery-types.d.ts +24 -0
  113. package/lib/types/replay-recovery-ui.d.ts +26 -0
  114. package/lib/types/replay-recovery.d.ts +17 -0
  115. package/lib/types/request-body-evidence.d.ts +34 -0
  116. package/lib/types/request-body-timeout-marker.d.ts +2 -0
  117. package/lib/types/request-body-timeout.d.ts +4 -0
  118. package/lib/types/request-budget.d.ts +58 -0
  119. package/lib/types/request-upload-evidence.d.ts +23 -0
  120. package/lib/types/response-error-body.d.ts +3 -0
  121. package/lib/types/responses-reasoning-text.d.ts +24 -0
  122. package/lib/types/responses-reasoning.d.ts +7 -0
  123. package/lib/types/responses-replay-compat.d.ts +30 -0
  124. package/lib/types/route-ownership.d.ts +70 -0
  125. package/lib/types/routed-web.d.ts +50 -0
  126. package/lib/types/search-backend.d.ts +16 -0
  127. package/lib/types/search-routing-host.d.ts +19 -0
  128. package/lib/types/search-routing-policy.d.ts +18 -0
  129. package/lib/types/search-routing-remote.d.ts +20 -0
  130. package/lib/types/search-routing.d.ts +43 -0
  131. package/lib/types/search-tool-routing.d.ts +22 -0
  132. package/lib/types/serialize.d.ts +106 -0
  133. package/lib/types/settings-reader.d.ts +16 -0
  134. package/lib/types/sse.d.ts +28 -0
  135. package/lib/types/temporary-models.d.ts +25 -0
  136. package/lib/types/tool-schema-compat.d.ts +17 -0
  137. package/lib/types/traditional-search.d.ts +17 -0
  138. package/lib/types/turn-model-provenance.d.ts +45 -0
  139. package/lib/types/turn-selection-card.d.ts +10 -0
  140. package/lib/types/turn-selection-host.d.ts +11 -0
  141. package/lib/types/turn-selection-remote.d.ts +13 -0
  142. package/lib/types/turn-selection.d.ts +119 -0
  143. package/lib/types/turn-usage-evidence.d.ts +66 -0
  144. package/lib/types/turn-usage-notice.d.ts +7 -0
  145. package/lib/types/types.d.ts +69 -0
  146. package/lib/types/usage.d.ts +26 -0
  147. package/lib/types/watchdog.d.ts +22 -0
  148. package/lib/types/web-delegate.d.ts +12 -0
  149. package/lib/types/web-search-routing-card.d.ts +16 -0
  150. package/lib/types/web-search-routing-config.d.ts +12 -0
  151. package/lib/types/wire-anthropic.d.ts +37 -0
  152. package/lib/types/wire.d.ts +56 -0
  153. package/lib/web-delegate.js +9 -0
  154. package/output/auto-model-mockup/index.html +207 -0
  155. package/package.json +236 -0
  156. package/scripts/check-search-composition.mjs +191 -0
@@ -0,0 +1,87 @@
1
+ //#region lib/types/request-budget.js
2
+ /** The safety allowance matches the pinned native SDK; pressure is a separate opt-in check. */
3
+ const DEFAULT_REQUEST_BUDGET_POLICY = Object.freeze({
4
+ safetyTokens: 4096,
5
+ pressureRatio: .9,
6
+ compactionReasoning: "prefer-low"
7
+ });
8
+ /** Validate deployment policy before applying defaults; unknown keys fail rather than silently drift. */
9
+ function resolveRequestBudgetPolicy(config = {}) {
10
+ const keys = /* @__PURE__ */ new Set([
11
+ "safetyTokens",
12
+ "pressureRatio",
13
+ "compactionReasoning"
14
+ ]);
15
+ for (const key of Object.keys(config)) if (!keys.has(key)) throw new Error(`COPILOT_REQUEST_BUDGET_POLICY_INVALID: unknown setting ${key}`);
16
+ const safetyTokens = config.safetyTokens === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.safetyTokens : config.safetyTokens;
17
+ const pressureRatio = config.pressureRatio === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.pressureRatio : config.pressureRatio;
18
+ const compactionReasoning = config.compactionReasoning === void 0 ? DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning : config.compactionReasoning;
19
+ if (!Number.isSafeInteger(safetyTokens) || safetyTokens < 0) throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: safetyTokens must be a non-negative safe integer");
20
+ if (!Number.isFinite(pressureRatio) || pressureRatio <= 0 || pressureRatio > 1) throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: pressureRatio must be greater than zero and at most one");
21
+ if (compactionReasoning !== "prefer-low" && compactionReasoning !== "preserve") throw new Error("COPILOT_REQUEST_BUDGET_POLICY_INVALID: unsupported compactionReasoning");
22
+ return Object.freeze({
23
+ safetyTokens,
24
+ pressureRatio,
25
+ compactionReasoning
26
+ });
27
+ }
28
+ function failure(code, message) {
29
+ return Object.freeze({
30
+ ok: false,
31
+ code,
32
+ message: `${code}: ${message}`
33
+ });
34
+ }
35
+ function positiveInteger(value) {
36
+ return Number.isSafeInteger(value) && value > 0;
37
+ }
38
+ /**
39
+ * Reserve output under the combined context and independently enforce the prompt ceiling.
40
+ * `policy` must come from resolveRequestBudgetPolicy; no caller cap or catalog object is changed.
41
+ */
42
+ function calculateRequestBudget(limits, requestedMaxTokens, policy = DEFAULT_REQUEST_BUDGET_POLICY) {
43
+ const { contextWindow, maxInputTokens, maxTokens } = limits;
44
+ if (!positiveInteger(contextWindow) || !positiveInteger(maxTokens) || maxInputTokens !== void 0 && !positiveInteger(maxInputTokens)) return failure("COPILOT_REQUEST_INVALID_LIMITS", "model token capacities must be positive safe integers");
45
+ if (requestedMaxTokens !== void 0 && !positiveInteger(requestedMaxTokens)) return failure("COPILOT_REQUEST_INVALID_OUTPUT_LIMIT", "request output cap must be a positive safe integer");
46
+ const outputReservation = requestedMaxTokens ?? maxTokens;
47
+ if (outputReservation > maxTokens) return failure("COPILOT_REQUEST_OUTPUT_LIMIT_EXCEEDED", `request output cap ${outputReservation} exceeds model output capacity ${maxTokens}`);
48
+ const contextInputLimit = contextWindow - outputReservation;
49
+ const limitingFactor = maxInputTokens !== void 0 && maxInputTokens <= contextInputLimit ? "prompt" : "context";
50
+ const hardInputLimit = Math.min(maxInputTokens ?? contextInputLimit, contextInputLimit) - policy.safetyTokens;
51
+ if (hardInputLimit <= 0) return failure("COPILOT_REQUEST_NO_INPUT_HEADROOM", "output reservation and safety allowance leave no positive input budget");
52
+ return Object.freeze({
53
+ ok: true,
54
+ budget: Object.freeze({
55
+ contextWindow,
56
+ ...maxInputTokens === void 0 ? {} : { maxInputTokens },
57
+ maxOutputTokens: maxTokens,
58
+ outputReservation,
59
+ hardInputLimit,
60
+ pressureInputLimit: Math.floor(hardInputLimit * policy.pressureRatio),
61
+ limitingFactor
62
+ })
63
+ });
64
+ }
65
+ /**
66
+ * Check an estimated full prompt; estimates are not provider-exact token counts.
67
+ * Enable pressure only for an owned ordinary loop call with a compaction recovery path.
68
+ * Auxiliary and agentless calls use hard admission, including compaction itself.
69
+ */
70
+ function assessRequestBudget(estimatedInput, budget, pressure = false) {
71
+ if (!Number.isFinite(estimatedInput) || estimatedInput < 0 || estimatedInput > Number.MAX_SAFE_INTEGER) return failure("COPILOT_REQUEST_INVALID_ESTIMATE", "estimated input must be finite, non-negative, and safely representable");
72
+ const input = Math.ceil(estimatedInput);
73
+ if (input > budget.hardInputLimit) return failure(budget.limitingFactor === "prompt" ? "COPILOT_REQUEST_INPUT_LIMIT_EXCEEDED" : "COPILOT_REQUEST_CONTEXT_LIMIT_EXCEEDED", `estimated input ${input} exceeds input budget ${budget.hardInputLimit} with output reservation ${budget.outputReservation}`);
74
+ if (pressure && input > budget.pressureInputLimit) return failure("COPILOT_REQUEST_PRESSURE_EXCEEDED", `estimated input ${input} exceeds proactive compaction budget ${budget.pressureInputLimit}`);
75
+ return Object.freeze({ ok: true });
76
+ }
77
+ /**
78
+ * Select a low-cost supported effort only for a caller-confirmed compaction request.
79
+ * A supplied effort, including a materialized provider default, wins unchanged; native validation
80
+ * remains authoritative. Unsupported low-cost controls preserve the provider default, never off/none.
81
+ */
82
+ function selectCompactionReasoning(supportedEfforts, requestedEffort, mode = DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning) {
83
+ if (requestedEffort !== void 0 || mode === "preserve") return requestedEffort;
84
+ return supportedEfforts.find((effort) => effort === "minimal") ?? supportedEfforts.find((effort) => effort === "low");
85
+ }
86
+ //#endregion
87
+ export { selectCompactionReasoning as a, resolveRequestBudgetPolicy as i, assessRequestBudget as n, calculateRequestBudget as r, DEFAULT_REQUEST_BUDGET_POLICY as t };
@@ -0,0 +1,120 @@
1
+ import "./copilot-identity-DRZY_d2X.js";
2
+ import { D as isPluginPreviewProvider, t as isCopilotSearchSelection, v as currentSearchInitiator, y as currentSearchSelection } from "./search-routing-CqysPLve.js";
3
+ import { WebError, WebRuntime } from "@deepseek-ai/dsh-web";
4
+ //#region lib/types/routed-web.js
5
+ /**
6
+ * Plugin-owned WebRuntime facade. The bundle isolates, but does not reconfigure,
7
+ * the original official service. Normal search, fetch and registrations delegate
8
+ * through its public APIs. A second private official WebRuntime supplies the same
9
+ * validation/source cap for the Copilot branch. No Core prototypes or private
10
+ * registries are read or changed.
11
+ */
12
+ var CopilotRoutedWeb = class extends WebRuntime {
13
+ static inject = ["githubCopilotOriginalWeb"];
14
+ bounded;
15
+ lifetime = new AbortController();
16
+ pending = /* @__PURE__ */ new Set();
17
+ mirroredSearchProviders = /* @__PURE__ */ new Map();
18
+ constructor(ctx, config = {}) {
19
+ super(ctx, config);
20
+ ctx.provide("githubCopilotSearchCatalog", { list: () => [...this.mirroredSearchProviders.keys()] });
21
+ this.bounded = new WebRuntime(ctx.isolate("web"), { searchProvider: "copilot-session-search" });
22
+ this.bounded.registerSearchProvider({
23
+ id: "copilot-session-search",
24
+ available: () => !this.lifetime.signal.aborted,
25
+ search: (request, signal) => {
26
+ const router = ctx.get("githubCopilotSearchRouter");
27
+ if (router === void 0) throw new WebError("Copilot session search routing is not ready", "WEB_PROVIDER_UNAVAILABLE");
28
+ return router.search(request, signal, (query, querySignal) => ctx.githubCopilotOriginalWeb.search(query, querySignal), (providerId, query, querySignal) => this.searchWithProvider(providerId, query, querySignal), (providerId) => this.captureSearchProvider(providerId));
29
+ }
30
+ });
31
+ ctx.effect(() => async () => {
32
+ this.lifetime.abort();
33
+ await Promise.allSettled(this.pending);
34
+ this.mirroredSearchProviders.clear();
35
+ });
36
+ }
37
+ disposedError() {
38
+ return new WebError("Copilot search service was disposed", "WEB_PROVIDER_UNAVAILABLE");
39
+ }
40
+ searchWithProvider(providerId, request, signal) {
41
+ const provider = this.captureSearchProvider(providerId);
42
+ if (provider === void 0) return Promise.reject(new WebError(`configured web provider "${providerId}" is not registered`, "WEB_PROVIDER_CONFIGURED_MISSING"));
43
+ return provider.search(request, signal);
44
+ }
45
+ captureSearchProvider(providerId) {
46
+ const entry = this.mirroredSearchProviders.get(providerId);
47
+ if (entry === void 0) return void 0;
48
+ const signal = AbortSignal.any([this.lifetime.signal, entry.cancellation.signal]);
49
+ const current = () => !signal.aborted && this.mirroredSearchProviders.get(providerId) === entry;
50
+ const available = entry.provider.available.bind(entry.provider);
51
+ const search = entry.provider.search.bind(entry.provider);
52
+ return {
53
+ id: providerId,
54
+ signal,
55
+ current,
56
+ owns: (provider) => current() && entry.provider === provider,
57
+ search: async (request, callerSignal) => {
58
+ const boundSignal = AbortSignal.any([signal, ...callerSignal === void 0 ? [] : [callerSignal]]);
59
+ const assertCurrent = () => {
60
+ if (boundSignal.aborted) throw new WebError("web search aborted", "WEB_ABORTED");
61
+ if (!current()) throw new WebError("web search provider registration invalidated", "WEB_PROVIDER_UNAVAILABLE");
62
+ };
63
+ assertCurrent();
64
+ try {
65
+ const usable = available();
66
+ assertCurrent();
67
+ if (!usable) throw new WebError(`configured web provider "${providerId}" is registered but unavailable`, "WEB_PROVIDER_CONFIGURED_UNAVAILABLE");
68
+ const result = await search(request, boundSignal);
69
+ assertCurrent();
70
+ return result;
71
+ } catch (error) {
72
+ assertCurrent();
73
+ throw error;
74
+ }
75
+ }
76
+ };
77
+ }
78
+ registerSearchProvider(provider) {
79
+ if (this.lifetime.signal.aborted) throw this.disposedError();
80
+ const disposeOriginal = this.ctx.githubCopilotOriginalWeb.registerSearchProvider(provider);
81
+ const providers = this.mirroredSearchProviders;
82
+ const providerId = provider.id;
83
+ const entry = {
84
+ provider,
85
+ cancellation: new AbortController()
86
+ };
87
+ const disposeMirror = this.ctx.effect(function* () {
88
+ providers.set(providerId, entry);
89
+ yield () => {
90
+ entry.cancellation.abort();
91
+ if (providers.get(providerId) === entry) providers.delete(providerId);
92
+ };
93
+ }, "github-copilot.search-provider-mirror");
94
+ return () => {
95
+ disposeMirror();
96
+ disposeOriginal();
97
+ };
98
+ }
99
+ registerFetchProvider(provider) {
100
+ if (this.lifetime.signal.aborted) throw this.disposedError();
101
+ return this.ctx.githubCopilotOriginalWeb.registerFetchProvider(provider);
102
+ }
103
+ fetch(request, signal) {
104
+ if (this.lifetime.signal.aborted) return Promise.reject(this.disposedError());
105
+ return this.ctx.githubCopilotOriginalWeb.fetch(request, signal);
106
+ }
107
+ search(request, signal) {
108
+ if (this.lifetime.signal.aborted) return Promise.reject(this.disposedError());
109
+ const selection = currentSearchSelection(currentSearchInitiator(this.ctx));
110
+ const owned = selection?.provider === "github-copilot-preview" && isPluginPreviewProvider(this.ctx, selection.provider);
111
+ if (!isCopilotSearchSelection(selection, owned) && this.ctx.get("githubCopilotSearchRouter") === void 0) return this.ctx.githubCopilotOriginalWeb.search(request, signal);
112
+ const boundSignal = AbortSignal.any([...signal === void 0 ? [] : [signal], this.lifetime.signal]);
113
+ const operation = this.bounded.search(request, boundSignal);
114
+ this.pending.add(operation);
115
+ operation.then(() => this.pending.delete(operation), () => this.pending.delete(operation));
116
+ return operation;
117
+ }
118
+ };
119
+ //#endregion
120
+ export { CopilotRoutedWeb as default };