@theia/ai-anthropic 1.57.0-next.112

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 (47) hide show
  1. package/README.md +31 -0
  2. package/lib/browser/anthropic-frontend-application-contribution.d.ts +15 -0
  3. package/lib/browser/anthropic-frontend-application-contribution.d.ts.map +1 -0
  4. package/lib/browser/anthropic-frontend-application-contribution.js +99 -0
  5. package/lib/browser/anthropic-frontend-application-contribution.js.map +1 -0
  6. package/lib/browser/anthropic-frontend-module.d.ts +4 -0
  7. package/lib/browser/anthropic-frontend-module.d.ts.map +1 -0
  8. package/lib/browser/anthropic-frontend-module.js +32 -0
  9. package/lib/browser/anthropic-frontend-module.js.map +1 -0
  10. package/lib/browser/anthropic-preferences.d.ts +5 -0
  11. package/lib/browser/anthropic-preferences.d.ts.map +1 -0
  12. package/lib/browser/anthropic-preferences.js +42 -0
  13. package/lib/browser/anthropic-preferences.js.map +1 -0
  14. package/lib/common/anthropic-language-models-manager.d.ts +33 -0
  15. package/lib/common/anthropic-language-models-manager.d.ts.map +1 -0
  16. package/lib/common/anthropic-language-models-manager.js +21 -0
  17. package/lib/common/anthropic-language-models-manager.js.map +1 -0
  18. package/lib/common/index.d.ts +2 -0
  19. package/lib/common/index.d.ts.map +1 -0
  20. package/lib/common/index.js +20 -0
  21. package/lib/common/index.js.map +1 -0
  22. package/lib/node/anthropic-backend-module.d.ts +4 -0
  23. package/lib/node/anthropic-backend-module.d.ts.map +1 -0
  24. package/lib/node/anthropic-backend-module.js +32 -0
  25. package/lib/node/anthropic-backend-module.js.map +1 -0
  26. package/lib/node/anthropic-language-model.d.ts +26 -0
  27. package/lib/node/anthropic-language-model.d.ts.map +1 -0
  28. package/lib/node/anthropic-language-model.js +247 -0
  29. package/lib/node/anthropic-language-model.js.map +1 -0
  30. package/lib/node/anthropic-language-models-manager-impl.d.ts +11 -0
  31. package/lib/node/anthropic-language-models-manager-impl.d.ts.map +1 -0
  32. package/lib/node/anthropic-language-models-manager-impl.js +77 -0
  33. package/lib/node/anthropic-language-models-manager-impl.js.map +1 -0
  34. package/lib/package.spec.d.ts +1 -0
  35. package/lib/package.spec.d.ts.map +1 -0
  36. package/lib/package.spec.js +26 -0
  37. package/lib/package.spec.js.map +1 -0
  38. package/package.json +50 -0
  39. package/src/browser/anthropic-frontend-application-contribution.ts +107 -0
  40. package/src/browser/anthropic-frontend-module.ts +31 -0
  41. package/src/browser/anthropic-preferences.ts +42 -0
  42. package/src/common/anthropic-language-models-manager.ts +45 -0
  43. package/src/common/index.ts +16 -0
  44. package/src/node/anthropic-backend-module.ts +34 -0
  45. package/src/node/anthropic-language-model.ts +299 -0
  46. package/src/node/anthropic-language-models-manager-impl.ts +81 -0
  47. package/src/package.spec.ts +28 -0
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ <div align='center'>
2
+
3
+ <br />
4
+
5
+ <img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
6
+
7
+ <h2>ECLIPSE THEIA - Anthropic EXTENSION</h2>
8
+
9
+ <hr />
10
+
11
+ </div>
12
+
13
+ ## Description
14
+
15
+ The `@theia/anthropic` integrates Anthropic's models with Theia AI.
16
+ The Anthropic API key and the models to use can be configured via preferences.
17
+ Alternatively the API key can also be handed in via the `ANTHROPIC_API_KEY` environment variable.
18
+
19
+ ## Additional Information
20
+
21
+ - [Theia - GitHub](https://github.com/eclipse-theia/theia)
22
+ - [Theia - Website](https://theia-ide.org/)
23
+
24
+ ## License
25
+
26
+ - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
27
+ - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
28
+
29
+ ## Trademark
30
+ "Theia" is a trademark of the Eclipse Foundation
31
+ https://www.eclipse.org/theia
@@ -0,0 +1,15 @@
1
+ import { FrontendApplicationContribution, PreferenceService } from '@theia/core/lib/browser';
2
+ import { AnthropicLanguageModelsManager, AnthropicModelDescription } from '../common';
3
+ import { RequestSetting } from '@theia/ai-core/lib/browser/ai-core-preferences';
4
+ export declare class AnthropicFrontendApplicationContribution implements FrontendApplicationContribution {
5
+ protected preferenceService: PreferenceService;
6
+ protected manager: AnthropicLanguageModelsManager;
7
+ protected prevModels: string[];
8
+ onStart(): void;
9
+ protected handleModelChanges(newModels: string[]): void;
10
+ private getRequestSettingsPref;
11
+ protected handleRequestSettingsChanges(newSettings: RequestSetting[]): void;
12
+ protected createAnthropicModelDescription(modelId: string, requestSettings: RequestSetting[]): AnthropicModelDescription;
13
+ protected getMatchingRequestSetting(modelId: string, providerId: string, requestSettings: RequestSetting[]): RequestSetting | undefined;
14
+ }
15
+ //# sourceMappingURL=anthropic-frontend-application-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/anthropic-frontend-application-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE7F,OAAO,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAEtF,OAAO,EAAoC,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAIlH,qBACa,wCAAyC,YAAW,+BAA+B;IAG5F,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAG/C,SAAS,CAAC,OAAO,EAAE,8BAA8B,CAAC;IAElD,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,CAAM;IAEpC,OAAO,IAAI,IAAI;IAsBf,SAAS,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAavD,OAAO,CAAC,sBAAsB;IAI9B,SAAS,CAAC,4BAA4B,CAAC,WAAW,EAAE,cAAc,EAAE,GAAG,IAAI;IAK3E,SAAS,CAAC,+BAA+B,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,yBAAyB;IAYxH,SAAS,CAAC,yBAAyB,CAC/B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,cAAc,EAAE,GAClC,cAAc,GAAG,SAAS;CAWhC"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2024 EclipseSource GmbH.
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
+ exports.AnthropicFrontendApplicationContribution = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const browser_1 = require("@theia/core/lib/browser");
21
+ const inversify_1 = require("@theia/core/shared/inversify");
22
+ const common_1 = require("../common");
23
+ const anthropic_preferences_1 = require("./anthropic-preferences");
24
+ const ai_core_preferences_1 = require("@theia/ai-core/lib/browser/ai-core-preferences");
25
+ const ANTHROPIC_PROVIDER_ID = 'anthropic';
26
+ let AnthropicFrontendApplicationContribution = class AnthropicFrontendApplicationContribution {
27
+ constructor() {
28
+ this.prevModels = [];
29
+ }
30
+ onStart() {
31
+ this.preferenceService.ready.then(() => {
32
+ const apiKey = this.preferenceService.get(anthropic_preferences_1.API_KEY_PREF, undefined);
33
+ this.manager.setApiKey(apiKey);
34
+ const models = this.preferenceService.get(anthropic_preferences_1.MODELS_PREF, []);
35
+ const requestSettings = this.getRequestSettingsPref();
36
+ this.manager.createOrUpdateLanguageModels(...models.map(modelId => this.createAnthropicModelDescription(modelId, requestSettings)));
37
+ this.prevModels = [...models];
38
+ this.preferenceService.onPreferenceChanged(event => {
39
+ if (event.preferenceName === anthropic_preferences_1.API_KEY_PREF) {
40
+ this.manager.setApiKey(event.newValue);
41
+ }
42
+ else if (event.preferenceName === anthropic_preferences_1.MODELS_PREF) {
43
+ this.handleModelChanges(event.newValue);
44
+ }
45
+ else if (event.preferenceName === ai_core_preferences_1.PREFERENCE_NAME_REQUEST_SETTINGS) {
46
+ this.handleRequestSettingsChanges(event.newValue);
47
+ }
48
+ });
49
+ });
50
+ }
51
+ handleModelChanges(newModels) {
52
+ const oldModels = new Set(this.prevModels);
53
+ const updatedModels = new Set(newModels);
54
+ const modelsToRemove = [...oldModels].filter(model => !updatedModels.has(model));
55
+ const modelsToAdd = [...updatedModels].filter(model => !oldModels.has(model));
56
+ this.manager.removeLanguageModels(...modelsToRemove.map(model => `${ANTHROPIC_PROVIDER_ID}/${model}`));
57
+ const requestSettings = this.getRequestSettingsPref();
58
+ this.manager.createOrUpdateLanguageModels(...modelsToAdd.map(modelId => this.createAnthropicModelDescription(modelId, requestSettings)));
59
+ this.prevModels = newModels;
60
+ }
61
+ getRequestSettingsPref() {
62
+ return this.preferenceService.get(ai_core_preferences_1.PREFERENCE_NAME_REQUEST_SETTINGS, []);
63
+ }
64
+ handleRequestSettingsChanges(newSettings) {
65
+ const models = this.preferenceService.get(anthropic_preferences_1.MODELS_PREF, []);
66
+ this.manager.createOrUpdateLanguageModels(...models.map(modelId => this.createAnthropicModelDescription(modelId, newSettings)));
67
+ }
68
+ createAnthropicModelDescription(modelId, requestSettings) {
69
+ const id = `${ANTHROPIC_PROVIDER_ID}/${modelId}`;
70
+ const modelRequestSetting = this.getMatchingRequestSetting(modelId, ANTHROPIC_PROVIDER_ID, requestSettings);
71
+ return {
72
+ id: id,
73
+ model: modelId,
74
+ apiKey: true,
75
+ enableStreaming: true,
76
+ defaultRequestSettings: modelRequestSetting === null || modelRequestSetting === void 0 ? void 0 : modelRequestSetting.requestSettings
77
+ };
78
+ }
79
+ getMatchingRequestSetting(modelId, providerId, requestSettings) {
80
+ const matchingSettings = requestSettings.filter(setting => (!setting.providerId || setting.providerId === providerId) && setting.modelId === modelId);
81
+ if (matchingSettings.length > 1) {
82
+ console.warn(`Multiple entries found for provider "${providerId}" and model "${modelId}". Using the first match.`);
83
+ }
84
+ return matchingSettings[0];
85
+ }
86
+ };
87
+ exports.AnthropicFrontendApplicationContribution = AnthropicFrontendApplicationContribution;
88
+ tslib_1.__decorate([
89
+ (0, inversify_1.inject)(browser_1.PreferenceService),
90
+ tslib_1.__metadata("design:type", Object)
91
+ ], AnthropicFrontendApplicationContribution.prototype, "preferenceService", void 0);
92
+ tslib_1.__decorate([
93
+ (0, inversify_1.inject)(common_1.AnthropicLanguageModelsManager),
94
+ tslib_1.__metadata("design:type", Object)
95
+ ], AnthropicFrontendApplicationContribution.prototype, "manager", void 0);
96
+ exports.AnthropicFrontendApplicationContribution = AnthropicFrontendApplicationContribution = tslib_1.__decorate([
97
+ (0, inversify_1.injectable)()
98
+ ], AnthropicFrontendApplicationContribution);
99
+ //# sourceMappingURL=anthropic-frontend-application-contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/anthropic-frontend-application-contribution.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,qDAA6F;AAC7F,4DAAkE;AAClE,sCAAsF;AACtF,mEAAoE;AACpE,wFAAkH;AAElH,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAGnC,IAAM,wCAAwC,GAA9C,MAAM,w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,WAAW,CAAC,CAAC,CAAC,CAAC;IACpI,CAAC;IAES,+BAA+B,CAAC,OAAe,EAAE,eAAiC;QACxF,MAAM,EAAE,GAAG,GAAG,qBAAqB,IAAI,OAAO,EAAE,CAAC;QACjD,MAAM,mBAAmB,GAAG,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,qBAAqB,EAAE,eAAe,CAAC,CAAC;QAC5G,OAAO;YACH,EAAE,EAAE,EAAE;YACN,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,IAAI;YACZ,eAAe,EAAE,IAAI;YACrB,sBAAsB,EAAE,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,eAAe;SAC/D,CAAC;IACN,CAAC;IAES,yBAAyB,CAC/B,OAAe,EACf,UAAkB,EAClB,eAAiC;QAEjC,MAAM,gBAAgB,GAAG,eAAe,CAAC,MAAM,CAC3C,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,KAAK,UAAU,CAAC,IAAI,OAAO,CAAC,OAAO,KAAK,OAAO,CACvG,CAAC;QACF,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,IAAI,CACR,wCAAwC,UAAU,gBAAgB,OAAO,2BAA2B,CACvG,CAAC;QACN,CAAC;QACD,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;CACJ,CAAA;AAjFY,4FAAwC;AAGvC;IADT,IAAA,kBAAM,EAAC,2BAAiB,CAAC;;mFACqB;AAGrC;IADT,IAAA,kBAAM,EAAC,uCAA8B,CAAC;;yEACW;mDANzC,wCAAwC;IADpD,IAAA,sBAAU,GAAE;GACA,wCAAwC,CAiFpD"}
@@ -0,0 +1,4 @@
1
+ import { ContainerModule } from '@theia/core/shared/inversify';
2
+ declare const _default: ContainerModule;
3
+ export default _default;
4
+ //# sourceMappingURL=anthropic-frontend-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/anthropic-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAM/D,wBAQG"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2024 EclipseSource GmbH.
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 inversify_1 = require("@theia/core/shared/inversify");
19
+ const anthropic_preferences_1 = require("./anthropic-preferences");
20
+ const browser_1 = require("@theia/core/lib/browser");
21
+ const anthropic_frontend_application_contribution_1 = require("./anthropic-frontend-application-contribution");
22
+ const common_1 = require("../common");
23
+ exports.default = new inversify_1.ContainerModule(bind => {
24
+ bind(browser_1.PreferenceContribution).toConstantValue({ schema: anthropic_preferences_1.AnthropicPreferencesSchema });
25
+ bind(anthropic_frontend_application_contribution_1.AnthropicFrontendApplicationContribution).toSelf().inSingletonScope();
26
+ bind(browser_1.FrontendApplicationContribution).toService(anthropic_frontend_application_contribution_1.AnthropicFrontendApplicationContribution);
27
+ bind(common_1.AnthropicLanguageModelsManager).toDynamicValue(ctx => {
28
+ const provider = ctx.container.get(browser_1.RemoteConnectionProvider);
29
+ return provider.createProxy(common_1.ANTHROPIC_LANGUAGE_MODELS_MANAGER_PATH);
30
+ }).inSingletonScope();
31
+ });
32
+ //# sourceMappingURL=anthropic-frontend-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-frontend-module.js","sourceRoot":"","sources":["../../src/browser/anthropic-frontend-module.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,4DAA+D;AAC/D,mEAAqE;AACrE,qDAAuJ;AACvJ,+GAAyG;AACzG,sCAAmG;AAEnG,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,gCAAsB,CAAC,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,kDAA0B,EAAE,CAAC,CAAC;IACrF,IAAI,CAAC,sFAAwC,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC3E,IAAI,CAAC,yCAA+B,CAAC,CAAC,SAAS,CAAC,sFAAwC,CAAC,CAAC;IAC1F,IAAI,CAAC,uCAA8B,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;QACtD,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAA4B,kCAAwB,CAAC,CAAC;QACxF,OAAO,QAAQ,CAAC,WAAW,CAAiC,+CAAsC,CAAC,CAAC;IACxG,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAC1B,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';
2
+ export declare const API_KEY_PREF = "ai-features.anthropic.AnthropicApiKey";
3
+ export declare const MODELS_PREF = "ai-features.anthropic.AnthropicModels";
4
+ export declare const AnthropicPreferencesSchema: PreferenceSchema;
5
+ //# sourceMappingURL=anthropic-preferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-preferences.d.ts","sourceRoot":"","sources":["../../src/browser/anthropic-preferences.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6DAA6D,CAAC;AAG/F,eAAO,MAAM,YAAY,0CAA0C,CAAC;AACpE,eAAO,MAAM,WAAW,0CAA0C,CAAC;AAEnE,eAAO,MAAM,0BAA0B,EAAE,gBAmBxC,CAAC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2024 EclipseSource GmbH.
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
+ exports.AnthropicPreferencesSchema = exports.MODELS_PREF = exports.API_KEY_PREF = void 0;
19
+ const ai_core_preferences_1 = require("@theia/ai-core/lib/browser/ai-core-preferences");
20
+ exports.API_KEY_PREF = 'ai-features.anthropic.AnthropicApiKey';
21
+ exports.MODELS_PREF = 'ai-features.anthropic.AnthropicModels';
22
+ exports.AnthropicPreferencesSchema = {
23
+ type: 'object',
24
+ properties: {
25
+ [exports.API_KEY_PREF]: {
26
+ type: 'string',
27
+ markdownDescription: 'Enter an API Key of your official Anthropic Account. **Please note:** By using this preference the Anthropic API key will be stored in clear text\
28
+ on the machine running Theia. Use the environment variable `ANTHROPIC_API_KEY` to set the key securely.',
29
+ title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
30
+ },
31
+ [exports.MODELS_PREF]: {
32
+ type: 'array',
33
+ description: 'Official Anthropic models to use',
34
+ title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
35
+ default: ['claude-3-5-sonnet-latest', 'claude-3-5-haiku-latest', 'claude-3-opus-latest'],
36
+ items: {
37
+ type: 'string'
38
+ }
39
+ },
40
+ }
41
+ };
42
+ //# sourceMappingURL=anthropic-preferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-preferences.js","sourceRoot":"","sources":["../../src/browser/anthropic-preferences.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;;;AAGhF,wFAA2F;AAE9E,QAAA,YAAY,GAAG,uCAAuC,CAAC;AACvD,QAAA,WAAW,GAAG,uCAAuC,CAAC;AAEtD,QAAA,0BAA0B,GAAqB;IACxD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,CAAC,oBAAY,CAAC,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,mBAAmB,EAAE;oHACmF;YACxG,KAAK,EAAE,+CAAyB;SACnC;QACD,CAAC,mBAAW,CAAC,EAAE;YACX,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,kCAAkC;YAC/C,KAAK,EAAE,+CAAyB;YAChC,OAAO,EAAE,CAAC,0BAA0B,EAAE,yBAAyB,EAAE,sBAAsB,CAAC;YACxF,KAAK,EAAE;gBACH,IAAI,EAAE,QAAQ;aACjB;SACJ;KACJ;CACJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ export declare const ANTHROPIC_LANGUAGE_MODELS_MANAGER_PATH = "/services/anthropic/language-model-manager";
2
+ export declare const AnthropicLanguageModelsManager: unique symbol;
3
+ export interface AnthropicModelDescription {
4
+ /**
5
+ * The identifier of the model which will be shown in the UI.
6
+ */
7
+ id: string;
8
+ /**
9
+ * The model ID as used by the Anthropic API.
10
+ */
11
+ model: string;
12
+ /**
13
+ * The key for the model. If 'true' is provided the global Anthropic API key will be used.
14
+ */
15
+ apiKey: string | true | undefined;
16
+ /**
17
+ * Indicate whether the streaming API shall be used.
18
+ */
19
+ enableStreaming: boolean;
20
+ /**
21
+ * Default request settings for the Anthropic model.
22
+ */
23
+ defaultRequestSettings?: {
24
+ [key: string]: unknown;
25
+ };
26
+ }
27
+ export interface AnthropicLanguageModelsManager {
28
+ apiKey: string | undefined;
29
+ setApiKey(key: string | undefined): void;
30
+ createOrUpdateLanguageModels(...models: AnthropicModelDescription[]): Promise<void>;
31
+ removeLanguageModels(...modelIds: string[]): void;
32
+ }
33
+ //# sourceMappingURL=anthropic-language-models-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-language-models-manager.d.ts","sourceRoot":"","sources":["../../src/common/anthropic-language-models-manager.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,sCAAsC,+CAA+C,CAAC;AACnG,eAAO,MAAM,8BAA8B,eAA2C,CAAC;AACvF,MAAM,WAAW,yBAAyB;IACtC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,sBAAsB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACvD;AACD,MAAM,WAAW,8BAA8B;IAC3C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACzC,4BAA4B,CAAC,GAAG,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpF,oBAAoB,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;CACpD"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnthropicLanguageModelsManager = exports.ANTHROPIC_LANGUAGE_MODELS_MANAGER_PATH = void 0;
4
+ // *****************************************************************************
5
+ // Copyright (C) 2024 EclipseSource GmbH.
6
+ //
7
+ // This program and the accompanying materials are made available under the
8
+ // terms of the Eclipse Public License v. 2.0 which is available at
9
+ // http://www.eclipse.org/legal/epl-2.0.
10
+ //
11
+ // This Source Code may also be made available under the following Secondary
12
+ // Licenses when the conditions for such availability set forth in the Eclipse
13
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
14
+ // with the GNU Classpath Exception which is available at
15
+ // https://www.gnu.org/software/classpath/license.html.
16
+ //
17
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
18
+ // *****************************************************************************
19
+ exports.ANTHROPIC_LANGUAGE_MODELS_MANAGER_PATH = '/services/anthropic/language-model-manager';
20
+ exports.AnthropicLanguageModelsManager = Symbol('AnthropicLanguageModelsManager');
21
+ //# sourceMappingURL=anthropic-language-models-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-language-models-manager.js","sourceRoot":"","sources":["../../src/common/anthropic-language-models-manager.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;AACnE,QAAA,sCAAsC,GAAG,4CAA4C,CAAC;AACtF,QAAA,8BAA8B,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './anthropic-language-models-manager';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAeA,cAAc,qCAAqC,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ // *****************************************************************************
5
+ // Copyright (C) 2024 EclipseSource GmbH.
6
+ //
7
+ // This program and the accompanying materials are made available under the
8
+ // terms of the Eclipse Public License v. 2.0 which is available at
9
+ // http://www.eclipse.org/legal/epl-2.0.
10
+ //
11
+ // This Source Code may also be made available under the following Secondary
12
+ // Licenses when the conditions for such availability set forth in the Eclipse
13
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
14
+ // with the GNU Classpath Exception which is available at
15
+ // https://www.gnu.org/software/classpath/license.html.
16
+ //
17
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
18
+ // *****************************************************************************
19
+ tslib_1.__exportStar(require("./anthropic-language-models-manager"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/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;AAChF,8EAAoD"}
@@ -0,0 +1,4 @@
1
+ import { ContainerModule } from '@theia/core/shared/inversify';
2
+ declare const _default: ContainerModule;
3
+ export default _default;
4
+ //# sourceMappingURL=anthropic-backend-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/anthropic-backend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAe/D,wBAEG"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2024 EclipseSource GmbH.
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 inversify_1 = require("@theia/core/shared/inversify");
19
+ const anthropic_language_models_manager_1 = require("../common/anthropic-language-models-manager");
20
+ const core_1 = require("@theia/core");
21
+ const anthropic_language_models_manager_impl_1 = require("./anthropic-language-models-manager-impl");
22
+ const connection_container_module_1 = require("@theia/core/lib/node/messaging/connection-container-module");
23
+ // We use a connection module to handle AI services separately for each frontend.
24
+ const anthropicConnectionModule = connection_container_module_1.ConnectionContainerModule.create(({ bind, bindBackendService, bindFrontendService }) => {
25
+ bind(anthropic_language_models_manager_impl_1.AnthropicLanguageModelsManagerImpl).toSelf().inSingletonScope();
26
+ bind(anthropic_language_models_manager_1.AnthropicLanguageModelsManager).toService(anthropic_language_models_manager_impl_1.AnthropicLanguageModelsManagerImpl);
27
+ bind(core_1.ConnectionHandler).toDynamicValue(ctx => new core_1.RpcConnectionHandler(anthropic_language_models_manager_1.ANTHROPIC_LANGUAGE_MODELS_MANAGER_PATH, () => ctx.container.get(anthropic_language_models_manager_1.AnthropicLanguageModelsManager))).inSingletonScope();
28
+ });
29
+ exports.default = new inversify_1.ContainerModule(bind => {
30
+ bind(connection_container_module_1.ConnectionContainerModule).toConstantValue(anthropicConnectionModule);
31
+ });
32
+ //# sourceMappingURL=anthropic-backend-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-backend-module.js","sourceRoot":"","sources":["../../src/node/anthropic-backend-module.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,4DAA+D;AAC/D,mGAAqI;AACrI,sCAAsE;AACtE,qGAA8F;AAC9F,4GAAuG;AAEvG,iFAAiF;AACjF,MAAM,yBAAyB,GAAG,uDAAyB,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,EAAE,EAAE;IACrH,IAAI,CAAC,2EAAkC,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACrE,IAAI,CAAC,kEAA8B,CAAC,CAAC,SAAS,CAAC,2EAAkC,CAAC,CAAC;IACnF,IAAI,CAAC,wBAAiB,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CACzC,IAAI,2BAAoB,CAAC,0EAAsC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,kEAA8B,CAAC,CAAC,CAC5H,CAAC,gBAAgB,EAAE,CAAC;AACzB,CAAC,CAAC,CAAC;AAEH,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,uDAAyB,CAAC,CAAC,eAAe,CAAC,yBAAyB,CAAC,CAAC;AAC/E,CAAC,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { LanguageModel, LanguageModelRequest, LanguageModelResponse, LanguageModelStreamResponse, LanguageModelTextResponse } from '@theia/ai-core';
2
+ import { CancellationToken } from '@theia/core';
3
+ import { Anthropic } from '@anthropic-ai/sdk';
4
+ export declare const AnthropicModelIdentifier: unique symbol;
5
+ /**
6
+ * Implements the Anthropic language model integration for Theia
7
+ */
8
+ export declare class AnthropicModel implements LanguageModel {
9
+ readonly id: string;
10
+ model: string;
11
+ enableStreaming: boolean;
12
+ apiKey: () => string | undefined;
13
+ defaultRequestSettings?: Readonly<Record<string, unknown>> | undefined;
14
+ constructor(id: string, model: string, enableStreaming: boolean, apiKey: () => string | undefined, defaultRequestSettings?: Readonly<Record<string, unknown>> | undefined);
15
+ protected getSettings(request: LanguageModelRequest): Readonly<Record<string, unknown>>;
16
+ request(request: LanguageModelRequest, cancellationToken?: CancellationToken): Promise<LanguageModelResponse>;
17
+ protected formatToolCallResult(result: unknown): string | Array<{
18
+ type: 'text';
19
+ text: string;
20
+ }>;
21
+ protected handleStreamingRequest(anthropic: Anthropic, request: LanguageModelRequest, cancellationToken?: CancellationToken, toolMessages?: readonly Anthropic.Messages.MessageParam[]): Promise<LanguageModelStreamResponse>;
22
+ private createTools;
23
+ protected handleNonStreamingRequest(anthropic: Anthropic, request: LanguageModelRequest): Promise<LanguageModelTextResponse>;
24
+ protected initializeAnthropic(): Anthropic;
25
+ }
26
+ //# sourceMappingURL=anthropic-language-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-language-model.d.ts","sourceRoot":"","sources":["../../src/node/anthropic-language-model.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,aAAa,EACb,oBAAoB,EAEpB,qBAAqB,EACrB,2BAA2B,EAE3B,yBAAyB,EAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAW,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAA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