@theia/ai-copilot 1.75.0 → 1.76.0-next.10

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,133 @@
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 copilot_sdk_mappers_1 = require("./copilot-sdk-mappers");
20
+ // Minimal ModelInfo factory: selectSdkModelIds only reads `id` and `policy.state`.
21
+ function model(id, state) {
22
+ return { id, policy: state ? { state } : undefined };
23
+ }
24
+ describe('copilot-sdk-mappers - selectSdkModelIds', () => {
25
+ it('keeps enabled and unconfigured models and drops disabled ones', () => {
26
+ const result = (0, copilot_sdk_mappers_1.selectSdkModelIds)([
27
+ model('gpt-4o', 'enabled'),
28
+ model('o1', 'disabled'),
29
+ model('claude', 'unconfigured'),
30
+ model('gpt-5')
31
+ ]);
32
+ (0, chai_1.expect)(result).to.deep.equal(['gpt-4o', 'claude', 'gpt-5']);
33
+ });
34
+ it('preserves order and removes duplicates', () => {
35
+ const result = (0, copilot_sdk_mappers_1.selectSdkModelIds)([
36
+ model('a', 'enabled'),
37
+ model('b', 'enabled'),
38
+ model('a', 'enabled')
39
+ ]);
40
+ (0, chai_1.expect)(result).to.deep.equal(['a', 'b']);
41
+ });
42
+ it('drops a dated release when its family is offered as well', () => {
43
+ const result = (0, copilot_sdk_mappers_1.selectSdkModelIds)([
44
+ model('gpt-5'),
45
+ model('gpt-5-2026-04-17'),
46
+ model('claude-sonnet-5'),
47
+ model('claude-sonnet-5-20260514')
48
+ ]);
49
+ (0, chai_1.expect)(result).to.deep.equal(['gpt-5', 'claude-sonnet-5']);
50
+ });
51
+ it('keeps a dated release that is the only way to select that model', () => {
52
+ const result = (0, copilot_sdk_mappers_1.selectSdkModelIds)([model('gpt-5'), model('o5-preview-2026-03-01')]);
53
+ (0, chai_1.expect)(result).to.deep.equal(['gpt-5', 'o5-preview-2026-03-01']);
54
+ });
55
+ it('keeps a dated release whose family is disabled by policy', () => {
56
+ const result = (0, copilot_sdk_mappers_1.selectSdkModelIds)([model('gpt-5', 'disabled'), model('gpt-5-2026-04-17')]);
57
+ (0, chai_1.expect)(result).to.deep.equal(['gpt-5-2026-04-17']);
58
+ });
59
+ it('returns an empty list when given no models', () => {
60
+ (0, chai_1.expect)((0, copilot_sdk_mappers_1.selectSdkModelIds)([])).to.deep.equal([]);
61
+ });
62
+ });
63
+ describe('copilot-sdk-mappers - buildSdkPrompt', () => {
64
+ it('forwards a lone user turn verbatim with no system text', () => {
65
+ const messages = [
66
+ { actor: 'user', type: 'text', text: 'hello world' }
67
+ ];
68
+ const result = (0, copilot_sdk_mappers_1.buildSdkPrompt)(messages);
69
+ (0, chai_1.expect)(result.systemText).to.equal('');
70
+ (0, chai_1.expect)(result.prompt).to.equal('hello world');
71
+ });
72
+ it('extracts and concatenates system messages', () => {
73
+ const messages = [
74
+ { actor: 'system', type: 'text', text: 'You are helpful.' },
75
+ { actor: 'system', type: 'text', text: 'Be concise.' },
76
+ { actor: 'user', type: 'text', text: 'hi' }
77
+ ];
78
+ const result = (0, copilot_sdk_mappers_1.buildSdkPrompt)(messages);
79
+ (0, chai_1.expect)(result.systemText).to.equal('You are helpful.\n\nBe concise.');
80
+ (0, chai_1.expect)(result.prompt).to.equal('hi');
81
+ });
82
+ it('renders a multi-message history as a role-labelled transcript', () => {
83
+ const messages = [
84
+ { actor: 'user', type: 'text', text: 'first' },
85
+ { actor: 'ai', type: 'text', text: 'reply' },
86
+ { actor: 'user', type: 'text', text: 'second' }
87
+ ];
88
+ const result = (0, copilot_sdk_mappers_1.buildSdkPrompt)(messages);
89
+ (0, chai_1.expect)(result.prompt).to.equal('User: first\n\nAssistant: reply\n\nUser: second');
90
+ });
91
+ it('drops thinking messages from the conversation body', () => {
92
+ const messages = [
93
+ { actor: 'ai', type: 'thinking', thinking: 'internal', signature: 's' },
94
+ { actor: 'user', type: 'text', text: 'only user' }
95
+ ];
96
+ const result = (0, copilot_sdk_mappers_1.buildSdkPrompt)(messages);
97
+ (0, chai_1.expect)(result.prompt).to.equal('only user');
98
+ });
99
+ it('summarises tool use and tool result messages in the transcript', () => {
100
+ const messages = [
101
+ { actor: 'user', type: 'text', text: 'run it' },
102
+ { actor: 'ai', type: 'tool_use', id: 'call_1', name: 'foo', input: { x: 1 } },
103
+ { actor: 'user', type: 'tool_result', tool_use_id: 'call_1', name: 'foo', content: 'done' }
104
+ ];
105
+ const result = (0, copilot_sdk_mappers_1.buildSdkPrompt)(messages);
106
+ (0, chai_1.expect)(result.prompt).to.equal('User: run it\n\nAssistant: [tool call: foo {"x":1}]\n\nUser: [tool result: done]');
107
+ });
108
+ });
109
+ describe('copilot-sdk-mappers - buildSdkSystemMessage', () => {
110
+ it('carries the system text as the content of the system message', () => {
111
+ const systemMessage = (0, copilot_sdk_mappers_1.buildSdkSystemMessage)('be helpful');
112
+ (0, chai_1.expect)(systemMessage?.mode).to.equal('customize');
113
+ (0, chai_1.expect)(systemMessage?.content).to.equal('be helpful');
114
+ });
115
+ it('removes the agent instructions of the CLI that the Theia prompt replaces', () => {
116
+ const systemMessage = (0, copilot_sdk_mappers_1.buildSdkSystemMessage)('be helpful');
117
+ const sections = systemMessage?.mode === 'customize' ? systemMessage.sections : undefined;
118
+ (0, chai_1.expect)(Object.keys(sections ?? {})).to.have.members(['identity', 'tone', 'guidelines', 'code_change_rules']);
119
+ for (const section of Object.values(sections ?? {})) {
120
+ (0, chai_1.expect)(section?.action).to.equal('remove');
121
+ }
122
+ });
123
+ it('keeps the tool instructions of the CLI, which tool calling relies on', () => {
124
+ const systemMessage = (0, copilot_sdk_mappers_1.buildSdkSystemMessage)('be helpful');
125
+ const sections = systemMessage?.mode === 'customize' ? systemMessage.sections : undefined;
126
+ (0, chai_1.expect)(sections).to.not.have.property('tool_instructions');
127
+ (0, chai_1.expect)(sections).to.not.have.property('safety');
128
+ });
129
+ it('configures nothing when the request has no system text', () => {
130
+ (0, chai_1.expect)((0, copilot_sdk_mappers_1.buildSdkSystemMessage)('')).to.be.undefined;
131
+ });
132
+ });
133
+ //# sourceMappingURL=copilot-sdk-mappers.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot-sdk-mappers.spec.js","sourceRoot":"","sources":["../../src/node/copilot-sdk-mappers.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EA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AAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;QAC5E,MAAM,aAAa,GAAG,IAAA,2CAAqB,EAAC,YAAY,CAAC,CAAC;QAC1D,MAAM,QAAQ,GAAG,aAAa,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1F,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC3D,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAC9D,IAAA,aAAM,EAAC,IAAA,2CAAqB,EAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;IACtD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,198 @@
1
+ /**
2
+ * The part of the Copilot SDK API this integration uses, mirrored by hand.
3
+ *
4
+ * Mirrored from `@github/copilot-sdk` 1.0.9 (protocol version 3), which the Copilot CLI 1.0.79 ships.
5
+ * The package is deliberately not a dependency: it depends on the CLI, a large proprietary binary that
6
+ * would end up in the tree and the lockfile of every application. The CLI is a prerequisite on the
7
+ * backend host instead, see `CopilotCliLocator`, and the SDK is loaded from it at runtime, see
8
+ * `CopilotSdkLoader`.
9
+ *
10
+ * Only what this integration passes to the SDK or reads from it is declared, so a drift shows up as a
11
+ * compile error here rather than at runtime. `scripts/copilot-sdk-mirror` checks the mirror against a
12
+ * released SDK and runs in CI on a schedule; update the version above along with the declarations.
13
+ */
14
+ export interface ModelPolicy {
15
+ state: 'enabled' | 'disabled' | 'unconfigured';
16
+ }
17
+ /** A model as reported by {@link CopilotClient.listModels}. */
18
+ export interface ModelInfo {
19
+ /** Model identifier, for example `claude-sonnet-4.5`. */
20
+ id: string;
21
+ policy?: ModelPolicy;
22
+ }
23
+ /** The sections the runtime assembles its system prompt from. Unknown ids are a silent no-op there. */
24
+ export type SystemMessageSection = 'preamble' | 'identity' | 'tone' | 'tool_efficiency' | 'environment_context' | 'code_change_rules' | 'guidelines' | 'safety' | 'tool_instructions' | 'custom_instructions' | 'runtime_instructions' | 'last_instructions';
25
+ export type SectionTransformFn = (currentContent: string) => string | Promise<string>;
26
+ export type SectionOverrideAction = 'replace' | 'remove' | 'append' | 'prepend' | 'preserve' | SectionTransformFn;
27
+ export interface SectionOverride {
28
+ action: SectionOverrideAction;
29
+ content?: string;
30
+ }
31
+ /** The SDK foundation plus the given content. */
32
+ export interface SystemMessageAppendConfig {
33
+ mode?: 'append';
34
+ content?: string;
35
+ }
36
+ /** The given content as the entire system message. */
37
+ export interface SystemMessageReplaceConfig {
38
+ mode: 'replace';
39
+ content: string;
40
+ }
41
+ /** The SDK structure with section-level overrides, which is what this integration uses. */
42
+ export interface SystemMessageCustomizeConfig {
43
+ mode: 'customize';
44
+ sections?: Partial<Record<SystemMessageSection, SectionOverride>>;
45
+ content?: string;
46
+ }
47
+ export type SystemMessageConfig = SystemMessageAppendConfig | SystemMessageReplaceConfig | SystemMessageCustomizeConfig;
48
+ /** What the runtime tells a tool handler about its invocation. */
49
+ export interface ToolInvocation {
50
+ sessionId: string;
51
+ toolCallId: string;
52
+ toolName: string;
53
+ arguments: unknown;
54
+ }
55
+ export type ToolHandler = (args: unknown, invocation: ToolInvocation) => Promise<unknown> | unknown;
56
+ /** A tool declared to the runtime. `parameters` also accepts a Zod schema upstream. */
57
+ export interface Tool {
58
+ name: string;
59
+ description?: string;
60
+ parameters?: Record<string, unknown>;
61
+ handler?: ToolHandler;
62
+ /** When true, the tool runs without a permission prompt of the runtime. */
63
+ skipPermission?: boolean;
64
+ }
65
+ /**
66
+ * A permission request of the runtime, upstream a union over the kind of operation with its own fields.
67
+ * Only `managedApprovalRequired` is read, which managed policy sets for a request it reserves for the
68
+ * user.
69
+ */
70
+ export interface PermissionRequest {
71
+ readonly kind: string;
72
+ readonly managedApprovalRequired?: boolean;
73
+ }
74
+ /** The decisions this integration can return. Upstream also has scopes that outlive a request. */
75
+ export type PermissionRequestResult = {
76
+ kind: 'approve-once';
77
+ } | {
78
+ kind: 'reject';
79
+ feedback?: string;
80
+ }
81
+ /** No user is available to confirm the request. */
82
+ | {
83
+ kind: 'user-not-available';
84
+ }
85
+ /** Leaves the request pending, so that another connected client can answer it. */
86
+ | {
87
+ kind: 'no-result';
88
+ };
89
+ export type PermissionHandler = (request: PermissionRequest, invocation: {
90
+ sessionId: string;
91
+ managedSettingsEnabled?: boolean;
92
+ }) => Promise<PermissionRequestResult> | PermissionRequestResult;
93
+ /** The envelope every session event comes in. */
94
+ export interface SessionEvent<T extends string, D> {
95
+ readonly type: T;
96
+ readonly data: D;
97
+ }
98
+ /** The session events this integration listens to, keyed by their type discriminator. */
99
+ export interface CopilotSessionEvents {
100
+ 'assistant.message_delta': SessionEvent<'assistant.message_delta', {
101
+ readonly deltaContent: string;
102
+ }>;
103
+ 'assistant.reasoning_delta': SessionEvent<'assistant.reasoning_delta', {
104
+ readonly deltaContent: string;
105
+ }>;
106
+ 'assistant.message': SessionEvent<'assistant.message', {
107
+ readonly content: string;
108
+ readonly outputTokens?: number;
109
+ }>;
110
+ 'assistant.usage': SessionEvent<'assistant.usage', {
111
+ readonly inputTokens?: number;
112
+ readonly outputTokens?: number;
113
+ }>;
114
+ /** Nothing of its payload is read, the event itself is the signal that the turn is over. */
115
+ 'session.idle': SessionEvent<'session.idle', unknown>;
116
+ 'session.error': SessionEvent<'session.error', {
117
+ readonly errorType: string;
118
+ readonly message: string;
119
+ readonly statusCode?: number;
120
+ readonly stack?: string;
121
+ }>;
122
+ }
123
+ export type CopilotSessionEventType = keyof CopilotSessionEvents;
124
+ /** A conversation with the runtime, upstream a class with resume, fork and sharing on top. */
125
+ export interface CopilotSession {
126
+ readonly sessionId: string;
127
+ /**
128
+ * Registers a handler for one type of event and returns the function that removes it again.
129
+ */
130
+ on<K extends CopilotSessionEventType>(eventType: K, handler: (event: CopilotSessionEvents[K]) => void): () => void;
131
+ /** Sends a turn and resolves with the id of the message it created. */
132
+ send(options: {
133
+ prompt: string;
134
+ }): Promise<string>;
135
+ /** Stops the turn in flight. */
136
+ abort(): Promise<void>;
137
+ /** Releases the session in memory, leaving what it persisted in place. */
138
+ disconnect(): Promise<void>;
139
+ }
140
+ /** How the SDK reaches the runtime. This integration always spawns the CLI it located. */
141
+ export interface StdioRuntimeConnection {
142
+ readonly kind: 'stdio';
143
+ readonly path?: string;
144
+ readonly args?: readonly string[];
145
+ readonly env?: Record<string, string>;
146
+ }
147
+ export type RuntimeConnection = StdioRuntimeConnection;
148
+ /** The `RuntimeConnection` value of the SDK, of which only the stdio factory is used. */
149
+ export interface RuntimeConnectionFactory {
150
+ readonly forStdio: (options?: {
151
+ path?: string;
152
+ args?: readonly string[];
153
+ env?: Record<string, string>;
154
+ }) => StdioRuntimeConnection;
155
+ }
156
+ /**
157
+ * Selects the defaults of the runtime: `copilot-cli` brings the ambient behaviour of the CLI along,
158
+ * `empty` requires the application to opt into what it needs.
159
+ */
160
+ export type CopilotClientMode = 'empty' | 'copilot-cli';
161
+ /** The client options this integration sets. */
162
+ export interface CopilotClientOptions {
163
+ connection?: RuntimeConnection;
164
+ mode?: CopilotClientMode;
165
+ /** Copilot home of the runtime, which becomes its `COPILOT_HOME`. Required in `empty` mode. */
166
+ baseDirectory?: string;
167
+ logLevel?: 'none' | 'error' | 'warning' | 'info' | 'debug' | 'all';
168
+ env?: Record<string, string | undefined>;
169
+ gitHubToken?: string;
170
+ /** When false, only an explicit token is used and no sign-in found on the host. */
171
+ useLoggedInUser?: boolean;
172
+ }
173
+ /** The session configuration this integration passes. */
174
+ export interface SessionConfig {
175
+ model?: string;
176
+ streaming?: boolean;
177
+ tools?: Tool[];
178
+ systemMessage?: SystemMessageConfig;
179
+ /**
180
+ * The tools to enable, as source-qualified patterns such as `custom:*` or `builtin:<name>`.
181
+ * Required in `empty` mode.
182
+ */
183
+ availableTools?: string[];
184
+ onPermissionRequest?: PermissionHandler;
185
+ }
186
+ /** The runtime as seen by this integration, upstream a class with the full session and status API. */
187
+ export interface CopilotClient {
188
+ /** Starts the runtime and connects to it. */
189
+ start(): Promise<void>;
190
+ /** Stops the runtime and resolves with the errors its cleanup ran into, if any. */
191
+ stop(): Promise<Error[]>;
192
+ listModels(): Promise<ModelInfo[]>;
193
+ createSession(config: SessionConfig): Promise<CopilotSession>;
194
+ /** Removes a session and what it persisted in the Copilot home. */
195
+ deleteSession(sessionId: string): Promise<void>;
196
+ }
197
+ export type CopilotClientConstructor = new (options?: CopilotClientOptions) => CopilotClient;
198
+ //# sourceMappingURL=copilot-sdk-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot-sdk-types.d.ts","sourceRoot":"","sources":["../../src/node/copilot-sdk-types.ts"],"names":[],"mappings":"AAwBA;;;;;;;;;;;;GAYG;AAMH,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,cAAc,CAAC;CAClD;AAED,+DAA+D;AAC/D,MAAM,WAAW,SAAS;IACtB,yDAAyD;IACzD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,WAAW,CAAC;CACxB;AAMD,uGAAuG;AACvG,MAAM,MAAM,oBAAoB,GAC1B,UAAU,GACV,UAAU,GACV,MAAM,GACN,iBAAiB,GACjB,qBAAqB,GACrB,mBAAmB,GACnB,YAAY,GACZ,QAAQ,GACR,mBAAmB,GACnB,qBAAqB,GACrB,sBAAsB,GACtB,mBAAmB,CAAC;AAE1B,MAAM,MAAM,kBAAkB,GAAG,CAAC,c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OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,mBAAmB,CAAC,EAAE,iBAAiB,CAAC;CAC3C;AAED,sGAAsG;AACtG,MAAM,WAAW,aAAa;IAC1B,6CAA6C;IAC7C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,mFAAmF;IACnF,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IACzB,UAAU,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IACnC,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC9D,mEAAmE;IACnE,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AAED,MAAM,MAAM,wBAAwB,GAAG,KAAK,OAAO,CAAC,EAAE,oBAAoB,KAAK,aAAa,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  // *****************************************************************************
3
- // Copyright (C) 2026 Lonti.com Pty Ltd.
3
+ // Copyright (C) 2026 EclipseSource GmbH and others.
4
4
  //
5
5
  // This program and the accompanying materials are made available under the
6
6
  // terms of the Eclipse Public License v. 2.0 which is available at
@@ -15,15 +15,4 @@
15
15
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
16
  // *****************************************************************************
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.DEFAULT_COPILOT_OAUTH_CONFIG = exports.CopilotOAuthConfig = void 0;
19
- exports.CopilotOAuthConfig = Symbol('CopilotOAuthConfig');
20
- /**
21
- * Default OAuth configuration for the built-in Theia Copilot integration.
22
- */
23
- exports.DEFAULT_COPILOT_OAUTH_CONFIG = {
24
- clientId: 'Ov23liS2vINy9VOAweyv',
25
- userAgent: 'Theia-Copilot/1.0.0',
26
- keystoreService: 'theia-copilot-auth',
27
- keystoreAccount: 'github-copilot'
28
- };
29
- //# sourceMappingURL=copilot-oauth-config.js.map
18
+ //# sourceMappingURL=copilot-sdk-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot-sdk-types.js","sourceRoot":"","sources":["../../src/node/copilot-sdk-types.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,EAAE;AACF,gFAAgF;AAChF,gFAAgF"}
@@ -1,4 +1,12 @@
1
1
  export * from './copilot-auth-service-impl';
2
- export * from './copilot-language-model';
3
2
  export * from './copilot-language-models-manager-impl';
3
+ export * from './copilot-cli-auth-provider';
4
+ export * from './copilot-cli-locator';
5
+ export * from './copilot-credential-store';
6
+ export * from './copilot-runtime-env';
7
+ export * from './copilot-sdk-client-provider';
8
+ export * from './copilot-sdk-loader';
9
+ export * from './copilot-sdk-mappers';
10
+ export * from './copilot-sdk-language-model';
11
+ export * from './copilot-sdk-types';
4
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAgBA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wCAAwC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAgBA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC"}
package/lib/node/index.js CHANGED
@@ -17,6 +17,14 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const tslib_1 = require("tslib");
19
19
  tslib_1.__exportStar(require("./copilot-auth-service-impl"), exports);
20
- tslib_1.__exportStar(require("./copilot-language-model"), exports);
21
20
  tslib_1.__exportStar(require("./copilot-language-models-manager-impl"), exports);
21
+ tslib_1.__exportStar(require("./copilot-cli-auth-provider"), exports);
22
+ tslib_1.__exportStar(require("./copilot-cli-locator"), exports);
23
+ tslib_1.__exportStar(require("./copilot-credential-store"), exports);
24
+ tslib_1.__exportStar(require("./copilot-runtime-env"), exports);
25
+ tslib_1.__exportStar(require("./copilot-sdk-client-provider"), exports);
26
+ tslib_1.__exportStar(require("./copilot-sdk-loader"), exports);
27
+ tslib_1.__exportStar(require("./copilot-sdk-mappers"), exports);
28
+ tslib_1.__exportStar(require("./copilot-sdk-language-model"), exports);
29
+ tslib_1.__exportStar(require("./copilot-sdk-types"), exports);
22
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,sEAA4C;AAC5C,mEAAyC;AACzC,iFAAuD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,sEAA4C;AAC5C,iFAAuD;AACvD,sEAA4C;AAC5C,gEAAsC;AACtC,qEAA2C;AAC3C,gEAAsC;AACtC,wEAA8C;AAC9C,+DAAqC;AACrC,gEAAsC;AACtC,uEAA6C;AAC7C,8DAAoC"}
package/package.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "name": "@theia/ai-copilot",
3
- "version": "1.75.0",
3
+ "version": "1.76.0-next.10+c8926e4df",
4
4
  "description": "Theia - GitHub Copilot Integration",
5
5
  "dependencies": {
6
- "@theia/ai-core": "1.75.0",
7
- "@theia/ai-openai": "1.75.0",
8
- "@theia/core": "1.75.0",
9
- "openai": "^6.49.0",
6
+ "@theia/ai-core": "1.76.0-next.10+c8926e4df",
7
+ "@theia/core": "1.76.0-next.10+c8926e4df",
10
8
  "tslib": "^2.8.1"
11
9
  },
12
10
  "publishConfig": {
@@ -48,5 +46,5 @@
48
46
  "nyc": {
49
47
  "extends": "../../configs/nyc.json"
50
48
  },
51
- "gitHead": "6d8e911f05f0fd9a13d76797e79b21ee3f038bc2"
49
+ "gitHead": "c8926e4df55986ad77d1f24c297873f1656fc9cb"
52
50
  }
@@ -89,7 +89,12 @@ export class CopilotAuthDialog extends ReactDialog<boolean> {
89
89
 
90
90
  override async open(): Promise<boolean | undefined> {
91
91
  this.initiateFlow();
92
- return super.open();
92
+ const result = await super.open();
93
+ if (this.state !== 'success') {
94
+ // Leave no Copilot CLI process behind when the dialog is dismissed or retried.
95
+ await this.authService.cancelSignIn();
96
+ }
97
+ return result;
93
98
  }
94
99
 
95
100
  override update(): void {
@@ -102,7 +107,7 @@ export class CopilotAuthDialog extends ReactDialog<boolean> {
102
107
  this.state = 'loading';
103
108
  this.update();
104
109
 
105
- this.deviceCodeResponse = await this.authService.initiateDeviceFlow(this.props.enterpriseUrl);
110
+ this.deviceCodeResponse = await this.authService.startSignIn(this.props.enterpriseUrl);
106
111
  this.state = 'waiting';
107
112
  this.update();
108
113
  } catch (error) {
@@ -121,11 +126,7 @@ export class CopilotAuthDialog extends ReactDialog<boolean> {
121
126
  this.update();
122
127
 
123
128
  try {
124
- const success = await this.authService.pollForToken(
125
- this.deviceCodeResponse.device_code,
126
- this.deviceCodeResponse.interval,
127
- this.props.enterpriseUrl
128
- );
129
+ const success = await this.authService.waitForSignIn();
129
130
 
130
131
  if (success) {
131
132
  this.state = 'success';
@@ -149,7 +150,10 @@ export class CopilotAuthDialog extends ReactDialog<boolean> {
149
150
 
150
151
  protected override isValid(_value: boolean, _mode: DialogError): DialogError {
151
152
  if (this.state === 'error') {
152
- return this.errorMessage ?? 'An error occurred';
153
+ // The error is shown in the dialog body by renderError, where it can wrap. Returning only a
154
+ // failed result keeps the accept button disabled without repeating the (often long) message
155
+ // next to it, where it does not fit.
156
+ return { result: false, message: '' };
153
157
  }
154
158
  return '';
155
159
  }
@@ -19,7 +19,7 @@ import { CommandService, nls, PreferenceService } from '@theia/core';
19
19
  import { FrontendApplicationContribution } from '@theia/core/lib/browser';
20
20
  import { MessageService } from '@theia/core/lib/common/message-service';
21
21
  import { CopilotAuthService, CopilotLanguageModelsManager, CopilotModelDescription, COPILOT_PROVIDER_ID } from '../common';
22
- import { COPILOT_ENABLED_PREF, COPILOT_MODEL_OVERRIDES_PREF, COPILOT_ENTERPRISE_URL_PREF } from '../common/copilot-preferences';
22
+ import { COPILOT_ENABLED_PREF, COPILOT_ENTERPRISE_URL_PREF, COPILOT_EXECUTABLE_PATH_PREF, COPILOT_MODEL_OVERRIDES_PREF } from '../common/copilot-preferences';
23
23
  import { AICorePreferences, PREFERENCE_NAME_MAX_RETRIES } from '@theia/ai-core/lib/common/ai-core-preferences';
24
24
  import { CopilotCommands } from './copilot-command-contribution';
25
25
 
@@ -49,24 +49,34 @@ export class CopilotFrontendApplicationContribution implements FrontendApplicati
49
49
 
50
50
  onStart(): void {
51
51
  this.preferenceService.ready.then(async () => {
52
- const enterpriseUrl = this.preferenceService.get<string>(COPILOT_ENTERPRISE_URL_PREF);
53
- this.manager.setEnterpriseUrl(enterpriseUrl || undefined);
54
-
52
+ // Before anything reaches for the CLI: the backend cannot read the preferences itself.
53
+ await this.updateExecutablePath();
55
54
  if (this.isCopilotEnabled()) {
56
55
  const authState = await this.authService.getAuthState();
57
56
  if (authState.migrationRequired) {
58
- this.notifyTokenMigration();
57
+ this.notifySignInRequired();
59
58
  }
60
59
  await this.initializeModels();
61
60
  }
62
61
 
63
62
  this.preferenceService.onPreferenceChanged(event => {
64
- if (event.preferenceName === COPILOT_ENABLED_PREF) {
63
+ if (event.preferenceName === COPILOT_EXECUTABLE_PATH_PREF) {
64
+ this.updateExecutablePath().then(() => {
65
+ if (this.isCopilotEnabled() && this.useAutoDiscovery) {
66
+ // A CLI that could not be found before may be reachable now.
67
+ this.discoverAndRegisterModels();
68
+ }
69
+ });
70
+ } else if (event.preferenceName === COPILOT_ENABLED_PREF) {
65
71
  if (this.isCopilotEnabled()) {
66
72
  this.initializeModels();
67
73
  } else {
68
74
  this.removeAllCopilotModels();
69
75
  }
76
+ } else if (event.preferenceName === COPILOT_ENTERPRISE_URL_PREF) {
77
+ // The domain is only read at sign-in time, so a change while signed in has no effect
78
+ // until the next sign-in. Let the user know instead of silently ignoring it.
79
+ this.notifyEnterpriseUrlChanged();
70
80
  } else if (event.preferenceName === COPILOT_MODEL_OVERRIDES_PREF && this.isCopilotEnabled()) {
71
81
  const newModels = this.preferenceService.get<string[]>(COPILOT_MODEL_OVERRIDES_PREF, []);
72
82
  if (newModels.length > 0) {
@@ -77,15 +87,6 @@ export class CopilotFrontendApplicationContribution implements FrontendApplicati
77
87
  this.removeAllCopilotModels();
78
88
  this.discoverAndRegisterModels();
79
89
  }
80
- } else if (event.preferenceName === COPILOT_ENTERPRISE_URL_PREF && this.isCopilotEnabled()) {
81
- const url = this.preferenceService.get<string>(COPILOT_ENTERPRISE_URL_PREF);
82
- this.manager.setEnterpriseUrl(url || undefined);
83
- if (this.useAutoDiscovery) {
84
- this.removeAllCopilotModels();
85
- this.discoverAndRegisterModels();
86
- } else {
87
- this.manager.refreshModelsStatus();
88
- }
89
90
  }
90
91
  });
91
92
 
@@ -111,6 +112,52 @@ export class CopilotFrontendApplicationContribution implements FrontendApplicati
111
112
  return this.preferenceService.get<boolean>(COPILOT_ENABLED_PREF, true);
112
113
  }
113
114
 
115
+ /**
116
+ * Hands the configured location of the Copilot CLI to the backend, which searches for it when
117
+ * none is configured.
118
+ */
119
+ protected async updateExecutablePath(): Promise<void> {
120
+ const executablePath = this.preferenceService.get<string>(COPILOT_EXECUTABLE_PATH_PREF, '').trim();
121
+ await this.authService.setExecutablePath(executablePath || undefined);
122
+ }
123
+
124
+ /**
125
+ * Tells the user why they are signed out after an update, since the sign-in of the previous
126
+ * version cannot be carried over: it belonged to an OAuth application that is no longer used.
127
+ */
128
+ protected async notifySignInRequired(): Promise<void> {
129
+ const signIn = nls.localize('theia/ai/copilot/commands/signIn', 'Sign in to GitHub Copilot');
130
+ const action = await this.messageService.info(
131
+ nls.localize('theia/ai/copilot/signInAgain',
132
+ 'GitHub Copilot now signs in through the GitHub Copilot CLI. Your previous sign-in could not be carried over and has been '
133
+ + 'removed, please sign in again to use Copilot models.'),
134
+ signIn
135
+ );
136
+ if (action === signIn) {
137
+ this.commandService.executeCommand(CopilotCommands.SIGN_IN.id);
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Tells the user that a changed GitHub Copilot domain only takes effect on the next sign-in, since
143
+ * the domain is read when signing in and not while a session is already established.
144
+ */
145
+ protected async notifyEnterpriseUrlChanged(): Promise<void> {
146
+ const authState = await this.authService.getAuthState();
147
+ if (!authState.isAuthenticated) {
148
+ return;
149
+ }
150
+ const signIn = nls.localize('theia/ai/copilot/commands/signIn', 'Sign in to GitHub Copilot');
151
+ const action = await this.messageService.info(
152
+ nls.localize('theia/ai/copilot/enterpriseUrlChanged',
153
+ 'The GitHub Copilot domain changed. Sign in again for it to take effect.'),
154
+ signIn
155
+ );
156
+ if (action === signIn) {
157
+ this.commandService.executeCommand(CopilotCommands.SIGN_IN.id);
158
+ }
159
+ }
160
+
114
161
  protected async initializeModels(): Promise<void> {
115
162
  const configuredModels = this.preferenceService.get<string[]>(COPILOT_MODEL_OVERRIDES_PREF, []);
116
163
  if (configuredModels.length > 0) {
@@ -171,18 +218,6 @@ export class CopilotFrontendApplicationContribution implements FrontendApplicati
171
218
  this.manager.createOrUpdateLanguageModels(...models.map((modelId: string) => this.createCopilotModelDescription(modelId)));
172
219
  }
173
220
 
174
- protected async notifyTokenMigration(): Promise<void> {
175
- const signIn = nls.localize('theia/ai/copilot/commands/signIn', 'Sign in to GitHub Copilot');
176
- const action = await this.messageService.info(
177
- nls.localize('theia/ai/copilot/tokenMigration',
178
- 'Your GitHub Copilot session used an outdated authentication method and has been cleared. Please sign in again to access all available models.'),
179
- signIn
180
- );
181
- if (action === signIn) {
182
- this.commandService.executeCommand(CopilotCommands.SIGN_IN.id);
183
- }
184
- }
185
-
186
221
  protected createCopilotModelDescription(modelId: string): CopilotModelDescription {
187
222
  const id = `${COPILOT_PROVIDER_ID}/${modelId}`;
188
223
  const maxRetries = this.aiCorePreferences.get(PREFERENCE_NAME_MAX_RETRIES) ?? 3;
@@ -190,8 +225,6 @@ export class CopilotFrontendApplicationContribution implements FrontendApplicati
190
225
  return {
191
226
  id,
192
227
  model: modelId,
193
- enableStreaming: true,
194
- supportsStructuredOutput: true,
195
228
  maxRetries
196
229
  };
197
230
  }