@theia/ai-copilot 1.76.0-next.4 → 1.76.0-next.7

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 (150) hide show
  1. package/README.md +86 -14
  2. package/lib/browser/copilot-auth-dialog.d.ts.map +1 -1
  3. package/lib/browser/copilot-auth-dialog.js +12 -4
  4. package/lib/browser/copilot-auth-dialog.js.map +1 -1
  5. package/lib/browser/copilot-frontend-application-contribution.d.ts +15 -1
  6. package/lib/browser/copilot-frontend-application-contribution.d.ts.map +1 -1
  7. package/lib/browser/copilot-frontend-application-contribution.js +52 -24
  8. package/lib/browser/copilot-frontend-application-contribution.js.map +1 -1
  9. package/lib/common/copilot-auth-service.d.ts +27 -24
  10. package/lib/common/copilot-auth-service.d.ts.map +1 -1
  11. package/lib/common/copilot-language-models-manager.d.ts +3 -21
  12. package/lib/common/copilot-language-models-manager.d.ts.map +1 -1
  13. package/lib/common/copilot-language-models-manager.js +1 -13
  14. package/lib/common/copilot-language-models-manager.js.map +1 -1
  15. package/lib/common/copilot-preferences.d.ts +1 -0
  16. package/lib/common/copilot-preferences.d.ts.map +1 -1
  17. package/lib/common/copilot-preferences.js +24 -6
  18. package/lib/common/copilot-preferences.js.map +1 -1
  19. package/lib/common/index.d.ts +0 -1
  20. package/lib/common/index.d.ts.map +1 -1
  21. package/lib/common/index.js +0 -1
  22. package/lib/common/index.js.map +1 -1
  23. package/lib/node/copilot-auth-service-impl.d.ts +25 -16
  24. package/lib/node/copilot-auth-service-impl.d.ts.map +1 -1
  25. package/lib/node/copilot-auth-service-impl.js +67 -183
  26. package/lib/node/copilot-auth-service-impl.js.map +1 -1
  27. package/lib/node/copilot-auth-service-impl.spec.js +104 -168
  28. package/lib/node/copilot-auth-service-impl.spec.js.map +1 -1
  29. package/lib/node/copilot-backend-module.d.ts.map +1 -1
  30. package/lib/node/copilot-backend-module.js +10 -2
  31. package/lib/node/copilot-backend-module.js.map +1 -1
  32. package/lib/node/copilot-cli-auth-provider.d.ts +146 -0
  33. package/lib/node/copilot-cli-auth-provider.d.ts.map +1 -0
  34. package/lib/node/copilot-cli-auth-provider.js +430 -0
  35. package/lib/node/copilot-cli-auth-provider.js.map +1 -0
  36. package/lib/node/copilot-cli-auth-provider.spec.d.ts +2 -0
  37. package/lib/node/copilot-cli-auth-provider.spec.d.ts.map +1 -0
  38. package/lib/node/copilot-cli-auth-provider.spec.js +249 -0
  39. package/lib/node/copilot-cli-auth-provider.spec.js.map +1 -0
  40. package/lib/node/copilot-cli-locator.d.ts +120 -0
  41. package/lib/node/copilot-cli-locator.d.ts.map +1 -0
  42. package/lib/node/copilot-cli-locator.js +348 -0
  43. package/lib/node/copilot-cli-locator.js.map +1 -0
  44. package/lib/node/copilot-cli-locator.spec.d.ts +2 -0
  45. package/lib/node/copilot-cli-locator.spec.d.ts.map +1 -0
  46. package/lib/node/copilot-cli-locator.spec.js +327 -0
  47. package/lib/node/copilot-cli-locator.spec.js.map +1 -0
  48. package/lib/node/copilot-credential-store.d.ts +45 -0
  49. package/lib/node/copilot-credential-store.d.ts.map +1 -0
  50. package/lib/node/copilot-credential-store.js +96 -0
  51. package/lib/node/copilot-credential-store.js.map +1 -0
  52. package/lib/node/copilot-credential-store.spec.d.ts +2 -0
  53. package/lib/node/copilot-credential-store.spec.d.ts.map +1 -0
  54. package/lib/node/copilot-credential-store.spec.js +93 -0
  55. package/lib/node/copilot-credential-store.spec.js.map +1 -0
  56. package/lib/node/copilot-language-models-manager-impl.d.ts +20 -18
  57. package/lib/node/copilot-language-models-manager-impl.d.ts.map +1 -1
  58. package/lib/node/copilot-language-models-manager-impl.js +39 -67
  59. package/lib/node/copilot-language-models-manager-impl.js.map +1 -1
  60. package/lib/node/copilot-language-models-manager-impl.spec.d.ts +2 -0
  61. package/lib/node/copilot-language-models-manager-impl.spec.d.ts.map +1 -0
  62. package/lib/node/copilot-language-models-manager-impl.spec.js +119 -0
  63. package/lib/node/copilot-language-models-manager-impl.spec.js.map +1 -0
  64. package/lib/node/copilot-runtime-env.d.ts +20 -0
  65. package/lib/node/copilot-runtime-env.d.ts.map +1 -0
  66. package/lib/node/copilot-runtime-env.js +49 -0
  67. package/lib/node/copilot-runtime-env.js.map +1 -0
  68. package/lib/node/copilot-sdk-client-provider.d.ts +103 -0
  69. package/lib/node/copilot-sdk-client-provider.d.ts.map +1 -0
  70. package/lib/node/copilot-sdk-client-provider.js +247 -0
  71. package/lib/node/copilot-sdk-client-provider.js.map +1 -0
  72. package/lib/node/copilot-sdk-client-provider.spec.d.ts +2 -0
  73. package/lib/node/copilot-sdk-client-provider.spec.d.ts.map +1 -0
  74. package/lib/node/copilot-sdk-client-provider.spec.js +215 -0
  75. package/lib/node/copilot-sdk-client-provider.spec.js.map +1 -0
  76. package/lib/node/copilot-sdk-language-model.d.ts +85 -0
  77. package/lib/node/copilot-sdk-language-model.d.ts.map +1 -0
  78. package/lib/node/copilot-sdk-language-model.js +301 -0
  79. package/lib/node/copilot-sdk-language-model.js.map +1 -0
  80. package/lib/node/copilot-sdk-language-model.spec.d.ts +2 -0
  81. package/lib/node/copilot-sdk-language-model.spec.d.ts.map +1 -0
  82. package/lib/node/copilot-sdk-language-model.spec.js +302 -0
  83. package/lib/node/copilot-sdk-language-model.spec.js.map +1 -0
  84. package/lib/node/copilot-sdk-loader.d.ts +57 -0
  85. package/lib/node/copilot-sdk-loader.d.ts.map +1 -0
  86. package/lib/node/copilot-sdk-loader.js +133 -0
  87. package/lib/node/copilot-sdk-loader.js.map +1 -0
  88. package/lib/node/copilot-sdk-loader.spec.d.ts +2 -0
  89. package/lib/node/copilot-sdk-loader.spec.d.ts.map +1 -0
  90. package/lib/node/copilot-sdk-loader.spec.js +113 -0
  91. package/lib/node/copilot-sdk-loader.spec.js.map +1 -0
  92. package/lib/node/copilot-sdk-mappers.d.ts +49 -0
  93. package/lib/node/copilot-sdk-mappers.d.ts.map +1 -0
  94. package/lib/node/copilot-sdk-mappers.js +147 -0
  95. package/lib/node/copilot-sdk-mappers.js.map +1 -0
  96. package/lib/node/copilot-sdk-mappers.spec.d.ts +2 -0
  97. package/lib/node/copilot-sdk-mappers.spec.d.ts.map +1 -0
  98. package/lib/node/copilot-sdk-mappers.spec.js +133 -0
  99. package/lib/node/copilot-sdk-mappers.spec.js.map +1 -0
  100. package/lib/node/copilot-sdk-types.d.ts +198 -0
  101. package/lib/node/copilot-sdk-types.d.ts.map +1 -0
  102. package/lib/{common/copilot-oauth-config.js → node/copilot-sdk-types.js} +2 -13
  103. package/lib/node/copilot-sdk-types.js.map +1 -0
  104. package/lib/node/index.d.ts +9 -1
  105. package/lib/node/index.d.ts.map +1 -1
  106. package/lib/node/index.js +9 -1
  107. package/lib/node/index.js.map +1 -1
  108. package/package.json +4 -6
  109. package/src/browser/copilot-auth-dialog.tsx +12 -8
  110. package/src/browser/copilot-frontend-application-contribution.ts +62 -29
  111. package/src/common/copilot-auth-service.ts +28 -24
  112. package/src/common/copilot-language-models-manager.ts +3 -28
  113. package/src/common/copilot-preferences.ts +24 -5
  114. package/src/common/index.ts +0 -1
  115. package/src/node/copilot-auth-service-impl.spec.ts +122 -207
  116. package/src/node/copilot-auth-service-impl.ts +63 -218
  117. package/src/node/copilot-backend-module.ts +11 -2
  118. package/src/node/copilot-cli-auth-provider.spec.ts +315 -0
  119. package/src/node/copilot-cli-auth-provider.ts +444 -0
  120. package/src/node/copilot-cli-locator.spec.ts +386 -0
  121. package/src/node/copilot-cli-locator.ts +363 -0
  122. package/src/node/copilot-credential-store.spec.ts +106 -0
  123. package/src/node/copilot-credential-store.ts +99 -0
  124. package/src/node/copilot-language-models-manager-impl.spec.ts +137 -0
  125. package/src/node/copilot-language-models-manager-impl.ts +51 -85
  126. package/src/node/copilot-runtime-env.ts +46 -0
  127. package/src/node/copilot-sdk-client-provider.spec.ts +253 -0
  128. package/src/node/copilot-sdk-client-provider.ts +241 -0
  129. package/src/node/copilot-sdk-language-model.spec.ts +363 -0
  130. package/src/node/copilot-sdk-language-model.ts +329 -0
  131. package/src/node/copilot-sdk-loader.spec.ts +126 -0
  132. package/src/node/copilot-sdk-loader.ts +142 -0
  133. package/src/node/copilot-sdk-mappers.spec.ts +151 -0
  134. package/src/node/copilot-sdk-mappers.ts +161 -0
  135. package/src/node/copilot-sdk-types.ts +276 -0
  136. package/src/node/index.ts +9 -1
  137. package/lib/common/copilot-oauth-config.d.ts +0 -33
  138. package/lib/common/copilot-oauth-config.d.ts.map +0 -1
  139. package/lib/common/copilot-oauth-config.js.map +0 -1
  140. package/lib/node/copilot-language-model.d.ts +0 -34
  141. package/lib/node/copilot-language-model.d.ts.map +0 -1
  142. package/lib/node/copilot-language-model.js +0 -236
  143. package/lib/node/copilot-language-model.js.map +0 -1
  144. package/lib/node/copilot-language-model.spec.d.ts +0 -2
  145. package/lib/node/copilot-language-model.spec.d.ts.map +0 -1
  146. package/lib/node/copilot-language-model.spec.js +0 -89
  147. package/lib/node/copilot-language-model.spec.js.map +0 -1
  148. package/src/common/copilot-oauth-config.ts +0 -55
  149. package/src/node/copilot-language-model.spec.ts +0 -106
  150. package/src/node/copilot-language-model.ts +0 -273
@@ -0,0 +1,249 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 EclipseSource GmbH and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const chai_1 = require("chai");
19
+ const fs_1 = require("fs");
20
+ const os = require("os");
21
+ const path_1 = require("path");
22
+ const promise_util_1 = require("@theia/core/lib/common/promise-util");
23
+ const mock_logger_1 = require("@theia/core/lib/common/test/mock-logger");
24
+ const copilot_cli_auth_provider_1 = require("./copilot-cli-auth-provider");
25
+ class TestableCopilotCliAuthProvider extends copilot_cli_auth_provider_1.CopilotCliAuthProvider {
26
+ constructor() {
27
+ super();
28
+ // The logger is injected in production, and read-only for everyone else.
29
+ Object.assign(this, { logger: new mock_logger_1.MockLogger() });
30
+ }
31
+ callParseDeviceCode(output) {
32
+ return this.parseDeviceCode(output);
33
+ }
34
+ callFindStoredToken(home) {
35
+ return this.findStoredToken(home);
36
+ }
37
+ callFindTokenInText(text) {
38
+ return this.findTokenInText(text);
39
+ }
40
+ callParseAccountLabel(output) {
41
+ return this.parseAccountLabel(output);
42
+ }
43
+ callCreateLoginEnv(home, noopBrowser) {
44
+ return this.createLoginEnv(home, noopBrowser);
45
+ }
46
+ callExtractFailure(output) {
47
+ return this.extractFailure(output);
48
+ }
49
+ callToHostUrl(enterpriseUrl) {
50
+ return this.toHostUrl(enterpriseUrl);
51
+ }
52
+ setLoginResult(result) {
53
+ Object.assign(this, { loginResult: result });
54
+ }
55
+ }
56
+ describe('CopilotCliAuthProvider - parseDeviceCode', () => {
57
+ const provider = new TestableCopilotCliAuthProvider();
58
+ it('should extract from the output format of the current CLI', () => {
59
+ const parsed = provider.callParseDeviceCode('To authenticate, visit https://github.com/login/device and enter code B54F-40A3\nWaiting for authorization...\n');
60
+ (0, chai_1.expect)(parsed?.verification_uri).to.equal('https://github.com/login/device');
61
+ (0, chai_1.expect)(parsed?.user_code).to.equal('B54F-40A3');
62
+ });
63
+ it('should extract the verification URL and the user code', () => {
64
+ const parsed = provider.callParseDeviceCode('Please enter the code AAEB-CD8C at https://github.com/login/device to authenticate.\n');
65
+ (0, chai_1.expect)(parsed?.verification_uri).to.equal('https://github.com/login/device');
66
+ (0, chai_1.expect)(parsed?.user_code).to.equal('AAEB-CD8C');
67
+ });
68
+ it('should extract from output spread across several lines', () => {
69
+ const parsed = provider.callParseDeviceCode([
70
+ 'Opening your browser to authenticate...',
71
+ 'First copy your one-time code: 1A2B-3C4D',
72
+ 'Then open https://github.com/login/device in your browser.'
73
+ ].join('\n'));
74
+ (0, chai_1.expect)(parsed?.user_code).to.equal('1A2B-3C4D');
75
+ (0, chai_1.expect)(parsed?.verification_uri).to.equal('https://github.com/login/device');
76
+ });
77
+ it('should extract an enterprise verification URL', () => {
78
+ const parsed = provider.callParseDeviceCode('Enter WXYZ-7890 at https://company.ghe.com/login/device\n');
79
+ (0, chai_1.expect)(parsed?.verification_uri).to.equal('https://company.ghe.com/login/device');
80
+ (0, chai_1.expect)(parsed?.user_code).to.equal('WXYZ-7890');
81
+ });
82
+ it('should return undefined while only the URL has been reported', () => {
83
+ (0, chai_1.expect)(provider.callParseDeviceCode('Visit https://github.com/login/device\n')).to.be.undefined;
84
+ });
85
+ it('should return undefined while only the code has been reported', () => {
86
+ (0, chai_1.expect)(provider.callParseDeviceCode('Your code is AAEB-CD8C\n')).to.be.undefined;
87
+ });
88
+ it('should return undefined for unrelated output', () => {
89
+ (0, chai_1.expect)(provider.callParseDeviceCode('Opening your browser to authenticate...\n')).to.be.undefined;
90
+ });
91
+ it('should not mistake a lowercase word pair for a code', () => {
92
+ (0, chai_1.expect)(provider.callParseDeviceCode('see also-here at https://github.com/login/device\n')).to.be.undefined;
93
+ });
94
+ });
95
+ describe('CopilotCliAuthProvider - extractFailure', () => {
96
+ const provider = new TestableCopilotCliAuthProvider();
97
+ it('should pick the line reporting the failure', () => {
98
+ const failure = provider.callExtractFailure([
99
+ 'Waiting for authorization...',
100
+ 'Error: Access denied by policy settings (Request ID: DEA8:572C1)'
101
+ ].join('\n'));
102
+ (0, chai_1.expect)(failure).to.equal('Error: Access denied by policy settings (Request ID: DEA8:572C1)');
103
+ });
104
+ it('should pick the last failure line when several are reported', () => {
105
+ const failure = provider.callExtractFailure([
106
+ 'Error: first problem',
107
+ 'unauthorized: not authorized to use this Copilot feature'
108
+ ].join('\n'));
109
+ (0, chai_1.expect)(failure).to.equal('unauthorized: not authorized to use this Copilot feature');
110
+ });
111
+ it('should ignore the clipboard failure the CLI reports on a healthy login', () => {
112
+ const failure = provider.callExtractFailure([
113
+ 'To authenticate, visit https://github.com/login/device and enter code B54F-40A3',
114
+ 'Failed to copy to clipboard. Please visit https://github.com/login/device and enter the code manually.',
115
+ 'Error: Access denied by policy settings'
116
+ ].join('\n'));
117
+ (0, chai_1.expect)(failure).to.equal('Error: Access denied by policy settings');
118
+ });
119
+ it('should not report the clipboard failure as the cause when it is the only match', () => {
120
+ const failure = provider.callExtractFailure([
121
+ 'Waiting for authorization...',
122
+ 'Failed to copy to clipboard. Please visit https://github.com/login/device manually.'
123
+ ].join('\n'));
124
+ (0, chai_1.expect)(failure).to.contain('Waiting for authorization');
125
+ (0, chai_1.expect)(failure).to.not.contain('clipboard');
126
+ });
127
+ it('should fall back to the tail of the output when no line names the problem', () => {
128
+ (0, chai_1.expect)(provider.callExtractFailure('Waiting for authorization...\n')).to.contain('Waiting for authorization');
129
+ });
130
+ });
131
+ describe('CopilotCliAuthProvider - toHostUrl', () => {
132
+ const provider = new TestableCopilotCliAuthProvider();
133
+ it('should prefix a bare domain with https', () => {
134
+ (0, chai_1.expect)(provider.callToHostUrl('company.ghe.com')).to.equal('https://company.ghe.com');
135
+ });
136
+ it('should keep a URL that already has a scheme', () => {
137
+ (0, chai_1.expect)(provider.callToHostUrl('https://company.ghe.com')).to.equal('https://company.ghe.com');
138
+ });
139
+ it('should upgrade a plain HTTP URL, since the sign-in carries credentials', () => {
140
+ (0, chai_1.expect)(provider.callToHostUrl('http://company.ghe.com')).to.equal('https://company.ghe.com');
141
+ });
142
+ it('should not mistake a host that merely starts with "http" for a URL with a scheme', () => {
143
+ (0, chai_1.expect)(provider.callToHostUrl('httpbin.example.com')).to.equal('https://httpbin.example.com');
144
+ });
145
+ });
146
+ describe('CopilotCliAuthProvider - cancelLogin', () => {
147
+ it('should settle a login that is being awaited, so that closing the dialog does not hang it', async () => {
148
+ const provider = new TestableCopilotCliAuthProvider();
149
+ const result = new promise_util_1.Deferred();
150
+ provider.setLoginResult(result);
151
+ await provider.cancelLogin();
152
+ (0, chai_1.expect)(await result.promise).to.equal(false);
153
+ });
154
+ });
155
+ describe('CopilotCliAuthProvider - findTokenInText', () => {
156
+ const provider = new TestableCopilotCliAuthProvider();
157
+ it('should find the token in the commented JSON the CLI writes', () => {
158
+ const config = [
159
+ '// User settings written by the Copilot CLI',
160
+ '{',
161
+ ' "github": { "token": "gho_abcdefghijklmnopqrstuvwxyz0123" },',
162
+ ' "host": "https://github.com"',
163
+ '}'
164
+ ].join('\n');
165
+ (0, chai_1.expect)(provider.callFindTokenInText(config)).to.equal('gho_abcdefghijklmnopqrstuvwxyz0123');
166
+ });
167
+ it('should find a token regardless of the surrounding format', () => {
168
+ (0, chai_1.expect)(provider.callFindTokenInText('token = ghu_abcdefghijklmnopqrstuvwxyz0123\n')).to.equal('ghu_abcdefghijklmnopqrstuvwxyz0123');
169
+ });
170
+ it('should not match values that only look similar', () => {
171
+ (0, chai_1.expect)(provider.callFindTokenInText('{ "user": "ndoschek", "short": "gho_tooshort", "url": "https://github.com" }')).to.be.undefined;
172
+ });
173
+ it('should return undefined for content without a token', () => {
174
+ (0, chai_1.expect)(provider.callFindTokenInText('// nothing to see here\n{}\n')).to.be.undefined;
175
+ });
176
+ });
177
+ describe('CopilotCliAuthProvider - findStoredToken', () => {
178
+ const provider = new TestableCopilotCliAuthProvider();
179
+ const token = 'gho_abcdefghijklmnopqrstuvwxyz0123';
180
+ let home;
181
+ beforeEach(async () => {
182
+ home = await fs_1.promises.mkdtemp((0, path_1.join)(os.tmpdir(), 'theia-copilot-token-'));
183
+ });
184
+ afterEach(async () => {
185
+ await fs_1.promises.rm(home, { recursive: true, force: true });
186
+ });
187
+ it('should find the token the CLI persisted', async () => {
188
+ await fs_1.promises.writeFile((0, path_1.join)(home, 'config.json'), `{ "github": { "token": "${token}" } }`);
189
+ (0, chai_1.expect)(await provider.callFindStoredToken(home)).to.equal(token);
190
+ });
191
+ it('should not inspect the files this provider wrote itself', async () => {
192
+ await fs_1.promises.writeFile((0, path_1.join)(home, 'settings.json'), `{ "token": "${token}" }`);
193
+ await fs_1.promises.writeFile((0, path_1.join)(home, 'no-browser.sh'), `#!/bin/sh\n# ${token}\n`);
194
+ (0, chai_1.expect)(await provider.callFindStoredToken(home)).to.be.undefined;
195
+ });
196
+ it('should skip a file that is implausibly large instead of reading it', async () => {
197
+ // Written with a leading newline so that the token would be found if the file were read.
198
+ await fs_1.promises.writeFile((0, path_1.join)(home, 'huge.json'), 'x'.repeat(1024 * 1024 + 1) + `\n${token}\n`);
199
+ (0, chai_1.expect)(await provider.callFindStoredToken(home)).to.be.undefined;
200
+ });
201
+ it('should return undefined for a home without a token', async () => {
202
+ await fs_1.promises.writeFile((0, path_1.join)(home, 'config.json'), '{ "host": "https://github.com" }');
203
+ (0, chai_1.expect)(await provider.callFindStoredToken(home)).to.be.undefined;
204
+ });
205
+ });
206
+ describe('CopilotCliAuthProvider - parseAccountLabel', () => {
207
+ const provider = new TestableCopilotCliAuthProvider();
208
+ it('should extract the login the CLI reported', () => {
209
+ (0, chai_1.expect)(provider.callParseAccountLabel('Signed in successfully as ndoschek.')).to.equal('ndoschek');
210
+ });
211
+ it('should extract the login without a trailing period', () => {
212
+ (0, chai_1.expect)(provider.callParseAccountLabel('Signed in successfully as some-user\n')).to.equal('some-user');
213
+ });
214
+ it('should return undefined when no login was reported', () => {
215
+ (0, chai_1.expect)(provider.callParseAccountLabel('Waiting for authorization...')).to.be.undefined;
216
+ });
217
+ });
218
+ describe('CopilotCliAuthProvider - createLoginEnv', () => {
219
+ const provider = new TestableCopilotCliAuthProvider();
220
+ it('should isolate the login in the given home with the keychain disabled', () => {
221
+ const env = provider.callCreateLoginEnv('/tmp/theia-copilot-login-test', '/tmp/theia-copilot-login-test/no-browser.sh');
222
+ (0, chai_1.expect)(env.COPILOT_HOME).to.equal('/tmp/theia-copilot-login-test');
223
+ (0, chai_1.expect)(env.COPILOT_DISABLE_KEYTAR).to.equal('1');
224
+ });
225
+ it('should remove a token variable whatever its case, since Windows ignores it', () => {
226
+ const previous = { ...process.env };
227
+ try {
228
+ process.env.Github_Token = 'gho_environment';
229
+ const env = provider.callCreateLoginEnv('/tmp/home', '/tmp/home/no-browser.sh');
230
+ (0, chai_1.expect)(Object.keys(env).some(name => name.toLowerCase() === 'github_token')).to.be.false;
231
+ }
232
+ finally {
233
+ process.env = previous;
234
+ }
235
+ });
236
+ it('should remove tokens from the environment so they cannot satisfy the sign-in', () => {
237
+ const env = provider.callCreateLoginEnv('/tmp/theia-copilot-login-test', '/tmp/theia-copilot-login-test/no-browser.sh');
238
+ (0, chai_1.expect)(env.COPILOT_GITHUB_TOKEN).to.be.undefined;
239
+ (0, chai_1.expect)(env.GH_TOKEN).to.be.undefined;
240
+ (0, chai_1.expect)(env.GITHUB_TOKEN).to.be.undefined;
241
+ });
242
+ it('should point the CLI at the no-op opener and drop the display variables', () => {
243
+ const env = provider.callCreateLoginEnv('/tmp/theia-copilot-login-test', '/tmp/theia-copilot-login-test/no-browser.sh');
244
+ (0, chai_1.expect)(env.BROWSER).to.equal('/tmp/theia-copilot-login-test/no-browser.sh');
245
+ (0, chai_1.expect)(env.DISPLAY).to.be.undefined;
246
+ (0, chai_1.expect)(env.WAYLAND_DISPLAY).to.be.undefined;
247
+ });
248
+ });
249
+ //# sourceMappingURL=copilot-cli-auth-provider.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot-cli-auth-provider.spec.js","sourceRoot":"","sources":["../../src/node/copilot-cli-auth-provider.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,E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AA6C,CAAC,CAAC;QACxH,IAAA,aAAM,EAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;QACjD,IAAA,aAAM,EAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;QACrC,IAAA,aAAM,EAAC,GAAG,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yEAAyE,EAAE,GAAG,EAAE;QAC/E,MAAM,GAAG,GAAG,QAAQ,CAAC,kBAAkB,CAAC,+BAA+B,EAAE,6CAA6C,CAAC,CAAC;QACxH,IAAA,aAAM,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAC5E,IAAA,aAAM,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;QACpC,IAAA,aAAM,EAAC,GAAG,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;IAChD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,120 @@
1
+ import { ILogger } from '@theia/core';
2
+ /**
3
+ * Environment variable that points at the Copilot CLI, honored by the Copilot SDK as well.
4
+ */
5
+ export declare const COPILOT_CLI_PATH_ENV = "COPILOT_CLI_PATH";
6
+ /**
7
+ * Locates the executable of the GitHub Copilot CLI on the machine running the backend.
8
+ *
9
+ * The CLI is a native executable that GitHub ships in a platform-specific package. It is looked up
10
+ * rather than bundled, because it is a large proprietary binary that an application does not
11
+ * necessarily carry: a packaged application (for example an AppImage) cannot execute a binary from
12
+ * inside its archive, and an installation may deliberately not ship it at all. Users install the CLI
13
+ * themselves, the same way as for the Claude Code integration.
14
+ *
15
+ * The native executable is resolved rather than the `index.js` entry point of the same package, so
16
+ * that it can be spawned directly. Spawning the JavaScript entry point would require a Node.js
17
+ * executable, which the backend does not have at hand: `process.execPath` is the Electron binary in
18
+ * an Electron application, and starting that would start a second application instead of the CLI.
19
+ */
20
+ export declare class CopilotCliLocator {
21
+ protected readonly logger: ILogger;
22
+ protected configuredPath: string | undefined;
23
+ protected resolution: Promise<string> | undefined;
24
+ /**
25
+ * Sets the location the user configured, which takes precedence over every other source.
26
+ * A changed value discards what was resolved before.
27
+ */
28
+ setConfiguredPath(path: string | undefined): void;
29
+ /**
30
+ * Resolves the executable of the Copilot CLI, and remembers it for later calls.
31
+ * Rejects with an explanation of where it was searched when there is none.
32
+ */
33
+ resolve(): Promise<string>;
34
+ protected doResolve(): Promise<string>;
35
+ /**
36
+ * Accepts the configured location either as the executable itself or as the directory holding it,
37
+ * so that both what a user has on their `PATH` and what a package manager installed can be given.
38
+ *
39
+ * A configured launcher is followed to the executable it would start, because that is what `which`
40
+ * or `whereis` report for a global installation. Starting the launcher would work as well, but only
41
+ * for as long as a Node.js is on the `PATH` of the backend, which is nothing to rely on.
42
+ */
43
+ protected resolveConfiguredPath(configured: string): Promise<string | undefined>;
44
+ /**
45
+ * The location given in the environment, resolved the same way as a configured one.
46
+ *
47
+ * The variable is documented as doing what the preference does, so a directory or a launcher is
48
+ * accepted here as well. A value that leads nowhere is reported and then left behind rather than
49
+ * turned into an error, so that the remaining sources still get their chance.
50
+ */
51
+ protected environmentCandidates(): Promise<string[]>;
52
+ /**
53
+ * The executable of a platform package that was installed alongside this application, if any.
54
+ *
55
+ * Both the module paths of this file and those of the Copilot SDK are searched, so that the
56
+ * package is found whether the installation hoisted it or nested it below the SDK.
57
+ */
58
+ protected bundledCandidates(): Promise<string[]>;
59
+ /**
60
+ * The executable of a platform package as Node.js resolves it from the given file.
61
+ *
62
+ * This is how the launcher of the CLI finds its own executable, and it is the only lookup that
63
+ * covers every layout: an installation hoists the platform package next to the launcher, while a
64
+ * global installation nests it below the launcher instead. The package points its main entry at
65
+ * the executable, so the directory of what was resolved is the directory holding it.
66
+ */
67
+ protected resolvedCandidates(anchor: string): string[];
68
+ /**
69
+ * The executable of a CLI that is on the `PATH` of the backend process.
70
+ *
71
+ * A global npm installation does not put the executable itself there but a launcher: a link to
72
+ * the JavaScript entry point on Linux and macOS, and a `.cmd` shim on Windows. Such a hit is
73
+ * therefore mapped to the platform package it belongs to, see {@link toCandidatesOnPath}.
74
+ */
75
+ protected pathCandidates(): Promise<string[]>;
76
+ /**
77
+ * Interprets what a `copilot` on the `PATH` points at: a launcher of a global npm installation is
78
+ * mapped to the executable of the platform package it would start, anything else is taken to be
79
+ * the executable itself.
80
+ */
81
+ protected toCandidatesOnPath(target: string): string[];
82
+ /**
83
+ * The executable of a globally installed CLI, for the case that the global binary directory is
84
+ * not on the `PATH` of the backend process. That is common when the application was started from
85
+ * a desktop launcher rather than from a shell.
86
+ */
87
+ protected globalInstallCandidates(): Promise<string[]>;
88
+ /**
89
+ * The executables a module directory can hold the CLI in.
90
+ *
91
+ * A global installation nests the platform package below the launcher rather than hoisting it, so
92
+ * the launcher is used to resolve from, and the hoisted layout is tried as well.
93
+ */
94
+ protected moduleDirectoryCandidates(modules: string): string[];
95
+ /**
96
+ * The executables the platform packages of this host would have below the given module directory.
97
+ */
98
+ protected toPlatformPackageCandidates(base: string): string[];
99
+ /**
100
+ * The platform-specific packages that can carry the CLI for this host.
101
+ * On Linux both the glibc and the musl build are candidates.
102
+ */
103
+ protected getCliPlatformPackageNames(): string[];
104
+ protected getBinaryName(): string;
105
+ /**
106
+ * The names a CLI can go by in a directory that is on the `PATH` or that a user configured: the
107
+ * executable itself, and on Windows in addition the shim a global npm installation writes, since
108
+ * that is the only entry it puts there.
109
+ */
110
+ protected getCliFileNames(): string[];
111
+ /**
112
+ * Whether the given path is something that starts the CLI rather than the CLI itself, which is
113
+ * either its JavaScript entry point or a shim of a global installation.
114
+ */
115
+ protected isLauncher(path: string): boolean;
116
+ protected isJsEntryPoint(path: string): boolean;
117
+ protected isShim(path: string): boolean;
118
+ protected isExecutable(path: string): Promise<boolean>;
119
+ }
120
+ //# sourceMappingURL=copilot-cli-locator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot-cli-locator.d.ts","sourceRoot":"","sources":["../../src/node/copilot-cli-locator.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,OAAO,EAAO,MAAM,aAAa,CAAC;AAI3C;;GAEG;AACH,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAOvD;;;;;;;;;;;;;GAaG;AACH,qBACa,iBAAiB;IAG1B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEnC,SAAS,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAElD;;;OAGG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAQjD;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;cAehB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAwC5C;;;;;;;OAOG;cACa,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAqBtF;;;;;;OAMG;cACa,qBAAqB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAe1D;;;;;OAKG;cACa,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IActD;;;;;;;OAOG;IACH,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAYtD;;;;;;OAMG;cACa,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAkBnD;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IActD;;;;OAIG;cACa,uBAAuB,IAAI,OAAO,CAAC,MAAM,EA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