dsh-github-copilot 0.4.0-alpha.18

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 (75) hide show
  1. package/AGENTS.md +233 -0
  2. package/CONTRIBUTING.md +46 -0
  3. package/LICENSE +21 -0
  4. package/README.md +365 -0
  5. package/README.zh.md +376 -0
  6. package/SECURITY.md +29 -0
  7. package/cordis.patch.yml +16 -0
  8. package/deployment-baseline.json +752 -0
  9. package/docs/agent-readiness.md +95 -0
  10. package/docs/images/copilot-auth-card-signed-in.png +0 -0
  11. package/docs/images/copilot-device-code-copy.png +0 -0
  12. package/docs/images/copilot-model-freshness.png +0 -0
  13. package/docs/images/copilot-model-refreshing.png +0 -0
  14. package/docs/images/copilot-provider-authorization.png +0 -0
  15. package/docs/images/copilot-provider-entry.png +0 -0
  16. package/docs/images/github-copilot-auth-flow.gif +0 -0
  17. package/docs/model-compatibility-acceptance.md +46 -0
  18. package/docs/npm-distribution.md +134 -0
  19. package/docs/session-search-routing.md +53 -0
  20. package/docs/single-route-migration.md +115 -0
  21. package/lib/client.js +7153 -0
  22. package/lib/client.js.map +1 -0
  23. package/lib/index.js +5384 -0
  24. package/lib/remote.js +162 -0
  25. package/lib/routed-web.js +80 -0
  26. package/lib/search-routing-pFLux0W7.js +763 -0
  27. package/lib/types/account-model-auth.d.ts +15 -0
  28. package/lib/types/account-model-catalog.d.ts +67 -0
  29. package/lib/types/account-model-source.d.ts +85 -0
  30. package/lib/types/authorization-controller.d.ts +100 -0
  31. package/lib/types/client.d.ts +106 -0
  32. package/lib/types/compact-account.d.ts +42 -0
  33. package/lib/types/compatibility.d.ts +17 -0
  34. package/lib/types/config.d.ts +42 -0
  35. package/lib/types/content-file.d.ts +10 -0
  36. package/lib/types/copilot-auth.d.ts +23 -0
  37. package/lib/types/copilot-grant.d.ts +11 -0
  38. package/lib/types/copilot-identity.d.ts +6 -0
  39. package/lib/types/copilot-request.d.ts +11 -0
  40. package/lib/types/current-provider.d.ts +59 -0
  41. package/lib/types/deepseek-search-fallback.d.ts +11 -0
  42. package/lib/types/failure.d.ts +38 -0
  43. package/lib/types/http.d.ts +48 -0
  44. package/lib/types/index.d.ts +39 -0
  45. package/lib/types/migration-status.d.ts +50 -0
  46. package/lib/types/model-protocol.d.ts +31 -0
  47. package/lib/types/pi-provider-bridge.d.ts +22 -0
  48. package/lib/types/plan.d.ts +148 -0
  49. package/lib/types/preview-provider.d.ts +35 -0
  50. package/lib/types/preview-route.d.ts +63 -0
  51. package/lib/types/probe.d.ts +39 -0
  52. package/lib/types/reasoning-presentation.d.ts +55 -0
  53. package/lib/types/remote.d.ts +151 -0
  54. package/lib/types/responses-reasoning-text.d.ts +24 -0
  55. package/lib/types/responses-reasoning.d.ts +7 -0
  56. package/lib/types/route-ownership.d.ts +70 -0
  57. package/lib/types/routed-web.d.ts +38 -0
  58. package/lib/types/search-backend.d.ts +16 -0
  59. package/lib/types/search-routing.d.ts +43 -0
  60. package/lib/types/serialize.d.ts +109 -0
  61. package/lib/types/sse.d.ts +28 -0
  62. package/lib/types/temporary-models.d.ts +25 -0
  63. package/lib/types/tool-schema-compat.d.ts +17 -0
  64. package/lib/types/traditional-search.d.ts +17 -0
  65. package/lib/types/types.d.ts +69 -0
  66. package/lib/types/usage.d.ts +26 -0
  67. package/lib/types/watchdog.d.ts +22 -0
  68. package/lib/types/web-delegate.d.ts +12 -0
  69. package/lib/types/web-search-routing-card.d.ts +10 -0
  70. package/lib/types/web-search-routing-config.d.ts +16 -0
  71. package/lib/types/wire-anthropic.d.ts +37 -0
  72. package/lib/types/wire.d.ts +56 -0
  73. package/lib/web-delegate.js +9 -0
  74. package/package.json +200 -0
  75. package/scripts/check-search-composition.mjs +191 -0
package/lib/remote.js ADDED
@@ -0,0 +1,162 @@
1
+ import { z } from "zod";
2
+ //#region lib/types/remote.js
3
+ /**
4
+ * Client-safe Remote contribution for the plugin-owned authorization bridge.
5
+ */
6
+ const direct = { kind: "direct" };
7
+ const GITHUB_COPILOT_AUTHORIZATION_VIEW_TYPE_SYMBOL = "dsh-github-copilot#GitHubCopilotAuthorizationView";
8
+ const GitHubCopilotAuthorizationViewSchema = z.object({
9
+ phase: z.enum([
10
+ "signed-out",
11
+ "authorizing",
12
+ "signed-in",
13
+ "error"
14
+ ]),
15
+ configured: z.boolean(),
16
+ writable: z.boolean(),
17
+ inFlight: z.boolean(),
18
+ notices: z.array(z.object({
19
+ message: z.string(),
20
+ url: z.string().optional(),
21
+ code: z.string().optional()
22
+ }).strict()),
23
+ catalog: z.object({
24
+ state: z.enum([
25
+ "current",
26
+ "partially-outdated",
27
+ "outdated"
28
+ ]),
29
+ accountModelCount: z.number().int().nonnegative(),
30
+ supportedModelCount: z.number().int().nonnegative(),
31
+ unknownModelIds: z.array(z.string()),
32
+ temporarilyUnavailableModelIds: z.array(z.string()).optional(),
33
+ previewModelIds: z.array(z.string()).optional()
34
+ }).strict().optional(),
35
+ accountModels: z.object({
36
+ state: z.enum([
37
+ "idle",
38
+ "loading",
39
+ "ready",
40
+ "stale",
41
+ "error",
42
+ "disposed",
43
+ "unconfigured",
44
+ "unavailable"
45
+ ]),
46
+ models: z.array(z.object({
47
+ id: z.string(),
48
+ name: z.string(),
49
+ api: z.string()
50
+ }).strict()).max(512),
51
+ rejected: z.array(z.object({
52
+ id: z.string().optional(),
53
+ code: z.string()
54
+ }).strict()).max(1024),
55
+ warnings: z.array(z.object({
56
+ id: z.string(),
57
+ code: z.string()
58
+ }).strict()).max(1024).optional(),
59
+ discoveredAt: z.number().int().nonnegative().optional(),
60
+ error: z.string().optional()
61
+ }).strict().optional(),
62
+ route: z.object({
63
+ state: z.enum([
64
+ "ready",
65
+ "needs-repair",
66
+ "not-configured",
67
+ "conflict",
68
+ "error"
69
+ ]),
70
+ diagnosticCode: z.enum([
71
+ "ROUTE_READ_FAILED",
72
+ "RECONCILIATION_FAILED",
73
+ "ROUTE_CONFLICT"
74
+ ]).optional()
75
+ }).strict().optional(),
76
+ error: z.string().optional()
77
+ }).strict();
78
+ const result = {
79
+ mode: "strict",
80
+ typeSymbol: GITHUB_COPILOT_AUTHORIZATION_VIEW_TYPE_SYMBOL,
81
+ schema: GitHubCopilotAuthorizationViewSchema
82
+ };
83
+ const GITHUB_COPILOT_MIGRATION_STATUS_TYPE_SYMBOL = "dsh-github-copilot#GitHubCopilotMigrationStatus";
84
+ const selectionSchema = z.object({
85
+ provider: z.string().min(1).max(512),
86
+ model: z.string().min(1).max(512),
87
+ reasoningEffort: z.string().min(1).max(512).optional()
88
+ }).strict();
89
+ /** Independent Ops result: strict at every object level; no account or private Session data. */
90
+ const GitHubCopilotMigrationStatusSchema = z.object({
91
+ plugin: z.object({
92
+ name: z.literal("dsh-github-copilot"),
93
+ version: z.string().min(1).max(512)
94
+ }).strict(),
95
+ protocolVersion: z.literal(1),
96
+ historyScope: z.literal("live-agents-only"),
97
+ observedAt: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
98
+ capabilities: z.object({
99
+ agentsList: z.boolean(),
100
+ sessionProjections: z.boolean(),
101
+ settingsCas: z.boolean(),
102
+ providerRegistry: z.boolean(),
103
+ defaultSelection: z.boolean()
104
+ }).strict(),
105
+ complete: z.object({
106
+ sessions: z.boolean(),
107
+ defaultSelection: z.boolean(),
108
+ routes: z.boolean()
109
+ }).strict(),
110
+ defaultSelection: selectionSchema.nullable(),
111
+ sessions: z.array(z.object({
112
+ id: z.string().min(1).max(512),
113
+ status: z.enum(["idle", "running"]),
114
+ effectiveSelection: selectionSchema.nullable(),
115
+ selectionSource: z.enum([
116
+ "pending",
117
+ "request-header",
118
+ "default",
119
+ "unknown"
120
+ ]),
121
+ activeRequestSelection: selectionSchema.nullable()
122
+ }).strict()).max(1024),
123
+ routes: z.object({
124
+ nativeConfigured: z.boolean().nullable(),
125
+ nativeRegistered: z.boolean().nullable(),
126
+ managedRegistered: z.boolean().nullable()
127
+ }).strict()
128
+ }).strict();
129
+ const contribution = {
130
+ package: "dsh-github-copilot",
131
+ descriptors: [...[
132
+ "status",
133
+ "reconcile",
134
+ "discoverModels",
135
+ "ensureModels",
136
+ "start",
137
+ "cancel",
138
+ "signOut"
139
+ ].map((method) => ({
140
+ id: `dsh-github-copilot:githubCopilot.${method}`,
141
+ service: "githubCopilotAuthorization",
142
+ namespace: "githubCopilot",
143
+ method,
144
+ invocation: direct,
145
+ parameters: [],
146
+ result
147
+ })), {
148
+ id: "dsh-github-copilot:githubCopilot.migrationStatus",
149
+ service: "githubCopilotAuthorization",
150
+ namespace: "githubCopilot",
151
+ method: "migrationStatus",
152
+ invocation: direct,
153
+ parameters: [],
154
+ result: {
155
+ mode: "strict",
156
+ typeSymbol: GITHUB_COPILOT_MIGRATION_STATUS_TYPE_SYMBOL,
157
+ schema: GitHubCopilotMigrationStatusSchema
158
+ }
159
+ }]
160
+ };
161
+ //#endregion
162
+ export { GITHUB_COPILOT_AUTHORIZATION_VIEW_TYPE_SYMBOL, GITHUB_COPILOT_MIGRATION_STATUS_TYPE_SYMBOL, GitHubCopilotAuthorizationViewSchema, GitHubCopilotMigrationStatusSchema, contribution as default };
@@ -0,0 +1,80 @@
1
+ import { C as currentSearchInitiator, T as isPluginPreviewProvider, t as isCopilotSearchSelection, w as currentSearchSelection } from "./search-routing-pFLux0W7.js";
2
+ import { WebError, WebRuntime } from "@deepseek-ai/dsh-web";
3
+ //#region lib/types/routed-web.js
4
+ /**
5
+ * Plugin-owned WebRuntime facade. The bundle isolates, but does not reconfigure,
6
+ * the original official service. Normal search, fetch and registrations delegate
7
+ * through its public APIs. A second private official WebRuntime supplies the same
8
+ * validation/source cap for the Copilot branch. No Core prototypes or private
9
+ * registries are read or changed.
10
+ */
11
+ var CopilotRoutedWeb = class extends WebRuntime {
12
+ static inject = ["githubCopilotOriginalWeb"];
13
+ bounded;
14
+ lifetime = new AbortController();
15
+ pending = /* @__PURE__ */ new Set();
16
+ mirroredSearchProviders = /* @__PURE__ */ new Map();
17
+ constructor(ctx, config = {}) {
18
+ super(ctx, config);
19
+ this.bounded = new WebRuntime(ctx.isolate("web"), { searchProvider: "copilot-session-search" });
20
+ this.bounded.registerSearchProvider({
21
+ id: "copilot-session-search",
22
+ available: () => !this.lifetime.signal.aborted,
23
+ search: (request, signal) => {
24
+ const router = ctx.get("githubCopilotSearchRouter");
25
+ if (router === void 0) throw new WebError("Copilot session search routing is not ready", "WEB_PROVIDER_UNAVAILABLE");
26
+ return router.search(request, signal, (query, querySignal) => ctx.githubCopilotOriginalWeb.search(query, querySignal), (providerId, query, querySignal) => this.searchWithProvider(providerId, query, querySignal));
27
+ }
28
+ });
29
+ ctx.effect(() => async () => {
30
+ this.lifetime.abort();
31
+ await Promise.allSettled(this.pending);
32
+ this.mirroredSearchProviders.clear();
33
+ });
34
+ }
35
+ disposedError() {
36
+ return new WebError("Copilot search service was disposed", "WEB_PROVIDER_UNAVAILABLE");
37
+ }
38
+ searchWithProvider(providerId, request, signal) {
39
+ const provider = this.mirroredSearchProviders.get(providerId);
40
+ if (provider === void 0) return Promise.reject(new WebError(`configured web provider "${providerId}" is not registered`, "WEB_PROVIDER_CONFIGURED_MISSING"));
41
+ if (!provider.available()) return Promise.reject(new WebError(`configured web provider "${providerId}" is registered but unavailable`, "WEB_PROVIDER_CONFIGURED_UNAVAILABLE"));
42
+ return provider.search(request, signal);
43
+ }
44
+ registerSearchProvider(provider) {
45
+ if (this.lifetime.signal.aborted) throw this.disposedError();
46
+ const disposeOriginal = this.ctx.githubCopilotOriginalWeb.registerSearchProvider(provider);
47
+ const providers = this.mirroredSearchProviders;
48
+ const disposeMirror = this.ctx.effect(function* () {
49
+ providers.set(provider.id, provider);
50
+ yield () => {
51
+ if (providers.get(provider.id) === provider) providers.delete(provider.id);
52
+ };
53
+ }, "github-copilot.search-provider-mirror");
54
+ return () => {
55
+ disposeMirror();
56
+ disposeOriginal();
57
+ };
58
+ }
59
+ registerFetchProvider(provider) {
60
+ if (this.lifetime.signal.aborted) throw this.disposedError();
61
+ return this.ctx.githubCopilotOriginalWeb.registerFetchProvider(provider);
62
+ }
63
+ fetch(request, signal) {
64
+ if (this.lifetime.signal.aborted) return Promise.reject(this.disposedError());
65
+ return this.ctx.githubCopilotOriginalWeb.fetch(request, signal);
66
+ }
67
+ search(request, signal) {
68
+ if (this.lifetime.signal.aborted) return Promise.reject(this.disposedError());
69
+ const selection = currentSearchSelection(currentSearchInitiator(this.ctx));
70
+ const owned = selection?.provider === "github-copilot-preview" && isPluginPreviewProvider(this.ctx, selection.provider);
71
+ if (!isCopilotSearchSelection(selection, owned) && this.ctx.get("githubCopilotSearchRouter") === void 0) return this.ctx.githubCopilotOriginalWeb.search(request, signal);
72
+ const boundSignal = AbortSignal.any([...signal === void 0 ? [] : [signal], this.lifetime.signal]);
73
+ const operation = this.bounded.search(request, boundSignal);
74
+ this.pending.add(operation);
75
+ operation.then(() => this.pending.delete(operation), () => this.pending.delete(operation));
76
+ return operation;
77
+ }
78
+ };
79
+ //#endregion
80
+ export { CopilotRoutedWeb as default };