@theia/ai-anthropic 1.76.0-next.28 → 1.76.0-next.34
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.
- package/lib/browser/anthropic-frontend-application-contribution.d.ts +16 -10
- package/lib/browser/anthropic-frontend-application-contribution.d.ts.map +1 -1
- package/lib/browser/anthropic-frontend-application-contribution.js +62 -63
- package/lib/browser/anthropic-frontend-application-contribution.js.map +1 -1
- package/lib/common/anthropic-language-models-manager.d.ts +20 -0
- package/lib/common/anthropic-language-models-manager.d.ts.map +1 -1
- package/lib/common/anthropic-language-models-manager.js.map +1 -1
- package/lib/common/anthropic-preferences.d.ts +2 -1
- package/lib/common/anthropic-preferences.d.ts.map +1 -1
- package/lib/common/anthropic-preferences.js +16 -16
- package/lib/common/anthropic-preferences.js.map +1 -1
- package/lib/node/anthropic-language-model.d.ts +18 -1
- package/lib/node/anthropic-language-model.d.ts.map +1 -1
- package/lib/node/anthropic-language-model.js +16 -6
- package/lib/node/anthropic-language-model.js.map +1 -1
- package/lib/node/anthropic-language-models-manager-impl.d.ts +21 -3
- package/lib/node/anthropic-language-models-manager-impl.d.ts.map +1 -1
- package/lib/node/anthropic-language-models-manager-impl.js +68 -8
- package/lib/node/anthropic-language-models-manager-impl.js.map +1 -1
- package/lib/node/anthropic-language-models-manager-impl.spec.js +195 -0
- package/lib/node/anthropic-language-models-manager-impl.spec.js.map +1 -1
- package/package.json +4 -4
- package/src/browser/anthropic-frontend-application-contribution.ts +70 -69
- package/src/common/anthropic-language-models-manager.ts +22 -1
- package/src/common/anthropic-preferences.ts +17 -15
- package/src/node/anthropic-language-model.ts +29 -5
- package/src/node/anthropic-language-models-manager-impl.spec.ts +198 -1
- package/src/node/anthropic-language-models-manager-impl.ts +80 -12
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
2
1
|
import { AnthropicLanguageModelsManager, AnthropicModelDescription } from '../common';
|
|
3
2
|
import { AICorePreferences } from '@theia/ai-core/lib/common/ai-core-preferences';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { PreferenceChange } from '@theia/core';
|
|
4
|
+
import { DiscoveringProviderContribution, ModelDiscoveryMessages } from '@theia/ai-core/lib/browser';
|
|
5
|
+
import { DiscoveredModel } from '@theia/ai-core/lib/common';
|
|
6
|
+
export declare class AnthropicFrontendApplicationContribution extends DiscoveringProviderContribution<AnthropicModelDescription> {
|
|
7
|
+
protected readonly manager: AnthropicLanguageModelsManager;
|
|
8
8
|
protected aiCorePreferences: AICorePreferences;
|
|
9
|
-
protected
|
|
9
|
+
protected readonly providerId = "anthropic";
|
|
10
|
+
protected readonly providerLabel = "Anthropic";
|
|
11
|
+
protected readonly modelOverridesPreference = "ai-features.anthropic.modelOverrides";
|
|
12
|
+
protected readonly allowEnvironmentApiKeyPreference = "ai-features.anthropic.allowEnvironmentApiKey";
|
|
10
13
|
protected prevCustomModels: Partial<AnthropicModelDescription>[];
|
|
11
|
-
|
|
12
|
-
protected
|
|
14
|
+
protected get discoveryMessages(): ModelDiscoveryMessages;
|
|
15
|
+
protected initializeProvider(): void;
|
|
16
|
+
protected handlePreferenceChange(event: PreferenceChange): void;
|
|
17
|
+
protected updateDiscoveredModels(): void;
|
|
18
|
+
/** Re-applies the model descriptions of the configured custom endpoints. */
|
|
19
|
+
protected updateCustomModels(): void;
|
|
13
20
|
protected handleCustomModelChanges(newCustomModels: Partial<AnthropicModelDescription>[]): void;
|
|
14
|
-
protected updateAllModels(): void;
|
|
15
21
|
/** Per-model details are resolved by the backend from the Anthropic /v1/models endpoint. */
|
|
16
|
-
protected
|
|
22
|
+
protected createModelDescription(model: DiscoveredModel): AnthropicModelDescription;
|
|
17
23
|
protected createCustomModelDescriptionsFromPreferences(preferences: Partial<AnthropicModelDescription>[]): AnthropicModelDescription[];
|
|
18
24
|
}
|
|
19
25
|
//# sourceMappingURL=anthropic-frontend-application-contribution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/anthropic-frontend-application-contribution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"anthropic-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/anthropic-frontend-application-contribution.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAItF,OAAO,EACH,iBAAiB,EAEpB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAO,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAI5D,qBACa,wCAAyC,SAAQ,+BAA+B,CAAC,yBAAyB,CAAC;IAGpH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,8BAA8B,CAAC;IAG3D,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAE/C,SAAS,CAAC,QAAQ,CAAC,UAAU,eAAyB;IACtD,SAAS,CAAC,QAAQ,CAAC,aAAa,eAAe;IAC/C,SAAS,CAAC,QAAQ,CAAC,wBAAwB,0CAAwB;IACnE,SAAS,CAAC,QAAQ,CAAC,gCAAgC,kDAA0B;IAE7E,SAAS,CAAC,gBAAgB,EAAE,OAAO,CAAC,yBAAyB,CAAC,EAAE,CAAM;IAEtE,SAAS,KAAK,iBAAiB,IAAI,sBAAsB,CAYxD;cAEkB,kBAAkB,IAAI,IAAI;cAe1B,sBAAsB,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;cAoBrD,sBAAsB,IAAI,IAAI;IAKjD,4EAA4E;IAC5E,SAAS,CAAC,kBAAkB,IAAI,IAAI;IAKpC,SAAS,CAAC,wBAAwB,CAAC,eAAe,EAAE,OAAO,CAAC,yBAAyB,CAAC,EAAE,GAAG,IAAI;IAuB/F,4FAA4F;IAC5F,SAAS,CAAC,sBAAsB,CAAC,KAAK,EAAE,eAAe,GAAG,yBAAyB;IAuBnF,SAAS,CAAC,4CAA4C,CAAC,WAAW,EAAE,OAAO,CAAC,yBAAyB,CAAC,EAAE,GAAG,yBAAyB,EAAE;CA8BzI"}
|
|
@@ -23,61 +23,69 @@ const anthropic_preferences_1 = require("../common/anthropic-preferences");
|
|
|
23
23
|
const ai_core_preferences_1 = require("@theia/ai-core/lib/common/ai-core-preferences");
|
|
24
24
|
const core_1 = require("@theia/core");
|
|
25
25
|
const ai_core_1 = require("@theia/ai-core");
|
|
26
|
+
const browser_1 = require("@theia/ai-core/lib/browser");
|
|
26
27
|
const ANTHROPIC_PROVIDER_ID = 'anthropic';
|
|
27
|
-
let AnthropicFrontendApplicationContribution = class AnthropicFrontendApplicationContribution {
|
|
28
|
+
let AnthropicFrontendApplicationContribution = class AnthropicFrontendApplicationContribution extends browser_1.DiscoveringProviderContribution {
|
|
28
29
|
constructor() {
|
|
29
|
-
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.providerId = ANTHROPIC_PROVIDER_ID;
|
|
32
|
+
this.providerLabel = 'Anthropic';
|
|
33
|
+
this.modelOverridesPreference = anthropic_preferences_1.MODEL_OVERRIDES_PREF;
|
|
34
|
+
this.allowEnvironmentApiKeyPreference = anthropic_preferences_1.ALLOW_ENV_API_KEY_PREF;
|
|
30
35
|
this.prevCustomModels = [];
|
|
31
36
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
else if (event.preferenceName === 'http.proxy') {
|
|
53
|
-
this.manager.setProxyUrl(this.preferenceService.get('http.proxy', undefined));
|
|
54
|
-
this.updateAllModels();
|
|
55
|
-
}
|
|
56
|
-
else if (event.preferenceName === anthropic_preferences_1.SERVER_SIDE_COMPACTION_PREF ||
|
|
57
|
-
event.preferenceName === ai_core_preferences_1.PREFERENCE_NAME_SERVER_SIDE_COMPACTION ||
|
|
58
|
-
event.preferenceName === anthropic_preferences_1.SERVER_SIDE_COMPACTION_TOKEN_THRESHOLD_PREF ||
|
|
59
|
-
event.preferenceName === ai_core_preferences_1.PREFERENCE_NAME_SERVER_SIDE_COMPACTION_TOKEN_THRESHOLD) {
|
|
60
|
-
this.updateAllModels();
|
|
61
|
-
}
|
|
62
|
-
else if (event.preferenceName === anthropic_preferences_1.CUSTOM_ENDPOINTS_PREF) {
|
|
63
|
-
this.handleCustomModelChanges(this.preferenceService.get(anthropic_preferences_1.CUSTOM_ENDPOINTS_PREF, []));
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
this.aiCorePreferences.onPreferenceChanged(event => {
|
|
67
|
-
if (event.preferenceName === ai_core_preferences_1.PREFERENCE_NAME_MAX_RETRIES) {
|
|
68
|
-
this.updateAllModels();
|
|
69
|
-
}
|
|
70
|
-
});
|
|
37
|
+
get discoveryMessages() {
|
|
38
|
+
return {
|
|
39
|
+
noCredentials: core_1.nls.localize('theia/ai/anthropic/discovery/noKey', 'No Anthropic API key set. Add a key to discover models.'),
|
|
40
|
+
consentRequired: core_1.nls.localize('theia/ai/anthropic/discovery/consentRequired', 'An Anthropic API key was found in the environment. Confirm its use to discover models.'),
|
|
41
|
+
consentPrompt: core_1.nls.localize('theia/ai/anthropic/discovery/consentPrompt', 'An Anthropic API key was found in the environment (ANTHROPIC_API_KEY). Allow Theia to use it to discover and call Anthropic models?'),
|
|
42
|
+
useEnvironmentKey: core_1.nls.localize('theia/ai/anthropic/discovery/useEnvKey', 'Use key'),
|
|
43
|
+
overridden: core_1.nls.localize('theia/ai/anthropic/discovery/overridden', 'The model list is configured manually. Clear the model overrides to discover the models from the provider again.'),
|
|
44
|
+
cached: error => core_1.nls.localize('theia/ai/anthropic/discovery/cached', 'Showing cached models; last refresh failed: {0}', error)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
initializeProvider() {
|
|
48
|
+
this.manager.setApiKey(this.preferenceService.get(anthropic_preferences_1.API_KEY_PREF, undefined));
|
|
49
|
+
this.manager.setProxyUrl(this.preferenceService.get('http.proxy', undefined));
|
|
50
|
+
const customModels = this.preferenceService.get(anthropic_preferences_1.CUSTOM_ENDPOINTS_PREF, []);
|
|
51
|
+
this.manager.createOrUpdateLanguageModels(...this.createCustomModelDescriptionsFromPreferences(customModels));
|
|
52
|
+
this.prevCustomModels = [...customModels];
|
|
53
|
+
this.aiCorePreferences.onPreferenceChanged(event => {
|
|
54
|
+
if (event.preferenceName === ai_core_preferences_1.PREFERENCE_NAME_MAX_RETRIES) {
|
|
55
|
+
this.updateDiscoveredModels();
|
|
56
|
+
}
|
|
71
57
|
});
|
|
72
58
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
59
|
+
handlePreferenceChange(event) {
|
|
60
|
+
if (event.preferenceName === anthropic_preferences_1.API_KEY_PREF) {
|
|
61
|
+
this.manager.setApiKey(this.preferenceService.get(anthropic_preferences_1.API_KEY_PREF, undefined));
|
|
62
|
+
this.discoverAndRegisterModels();
|
|
63
|
+
}
|
|
64
|
+
else if (event.preferenceName === 'http.proxy') {
|
|
65
|
+
this.manager.setProxyUrl(this.preferenceService.get('http.proxy', undefined));
|
|
66
|
+
// A model keeps the proxy it was registered with, so the custom endpoints have to be
|
|
67
|
+
// re-registered as well: discovery only covers the models it registers itself.
|
|
68
|
+
this.updateCustomModels();
|
|
69
|
+
this.discoverAndRegisterModels();
|
|
70
|
+
}
|
|
71
|
+
else if (event.preferenceName === anthropic_preferences_1.SERVER_SIDE_COMPACTION_PREF ||
|
|
72
|
+
event.preferenceName === ai_core_preferences_1.PREFERENCE_NAME_SERVER_SIDE_COMPACTION ||
|
|
73
|
+
event.preferenceName === anthropic_preferences_1.SERVER_SIDE_COMPACTION_TOKEN_THRESHOLD_PREF ||
|
|
74
|
+
event.preferenceName === ai_core_preferences_1.PREFERENCE_NAME_SERVER_SIDE_COMPACTION_TOKEN_THRESHOLD) {
|
|
75
|
+
this.updateDiscoveredModels();
|
|
76
|
+
}
|
|
77
|
+
else if (event.preferenceName === anthropic_preferences_1.CUSTOM_ENDPOINTS_PREF) {
|
|
78
|
+
this.handleCustomModelChanges(this.preferenceService.get(anthropic_preferences_1.CUSTOM_ENDPOINTS_PREF, []));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
updateDiscoveredModels() {
|
|
82
|
+
super.updateDiscoveredModels();
|
|
83
|
+
this.updateCustomModels();
|
|
84
|
+
}
|
|
85
|
+
/** Re-applies the model descriptions of the configured custom endpoints. */
|
|
86
|
+
updateCustomModels() {
|
|
87
|
+
const customModels = this.preferenceService.get(anthropic_preferences_1.CUSTOM_ENDPOINTS_PREF, []);
|
|
88
|
+
this.manager.createOrUpdateLanguageModels(...this.createCustomModelDescriptionsFromPreferences(customModels));
|
|
81
89
|
}
|
|
82
90
|
handleCustomModelChanges(newCustomModels) {
|
|
83
91
|
const oldModels = this.createCustomModelDescriptionsFromPreferences(this.prevCustomModels);
|
|
@@ -97,15 +105,9 @@ let AnthropicFrontendApplicationContribution = class AnthropicFrontendApplicatio
|
|
|
97
105
|
this.manager.createOrUpdateLanguageModels(...modelsToAddOrUpdate);
|
|
98
106
|
this.prevCustomModels = [...newCustomModels];
|
|
99
107
|
}
|
|
100
|
-
updateAllModels() {
|
|
101
|
-
const models = this.preferenceService.get(anthropic_preferences_1.MODELS_PREF, []);
|
|
102
|
-
this.manager.createOrUpdateLanguageModels(...models.map(modelId => this.createAnthropicModelDescription(modelId)));
|
|
103
|
-
const customModels = this.preferenceService.get(anthropic_preferences_1.CUSTOM_ENDPOINTS_PREF, []);
|
|
104
|
-
this.manager.createOrUpdateLanguageModels(...this.createCustomModelDescriptionsFromPreferences(customModels));
|
|
105
|
-
}
|
|
106
108
|
/** Per-model details are resolved by the backend from the Anthropic /v1/models endpoint. */
|
|
107
|
-
|
|
108
|
-
const id = `${ANTHROPIC_PROVIDER_ID}/${
|
|
109
|
+
createModelDescription(model) {
|
|
110
|
+
const id = `${ANTHROPIC_PROVIDER_ID}/${model.id}`;
|
|
109
111
|
const maxRetries = this.aiCorePreferences.get(ai_core_preferences_1.PREFERENCE_NAME_MAX_RETRIES) ?? 3;
|
|
110
112
|
const globalCompaction = this.preferenceService.get(ai_core_preferences_1.PREFERENCE_NAME_SERVER_SIDE_COMPACTION, true);
|
|
111
113
|
const compactionOverride = this.preferenceService.get(anthropic_preferences_1.SERVER_SIDE_COMPACTION_PREF, 'default');
|
|
@@ -115,13 +117,14 @@ let AnthropicFrontendApplicationContribution = class AnthropicFrontendApplicatio
|
|
|
115
117
|
const serverSideCompactionTokenThresholdByDefault = (0, ai_core_1.resolveCompactionTokenThresholdDefault)(globalThreshold, providerThreshold);
|
|
116
118
|
return {
|
|
117
119
|
id: id,
|
|
118
|
-
model:
|
|
120
|
+
model: model.id,
|
|
119
121
|
apiKey: true,
|
|
120
122
|
enableStreaming: true,
|
|
121
123
|
useCaching: true,
|
|
122
124
|
maxRetries: maxRetries,
|
|
123
125
|
serverSideCompactionEnabledByDefault,
|
|
124
|
-
serverSideCompactionTokenThresholdByDefault
|
|
126
|
+
serverSideCompactionTokenThresholdByDefault,
|
|
127
|
+
released: model.released
|
|
125
128
|
};
|
|
126
129
|
}
|
|
127
130
|
createCustomModelDescriptionsFromPreferences(preferences) {
|
|
@@ -155,10 +158,6 @@ let AnthropicFrontendApplicationContribution = class AnthropicFrontendApplicatio
|
|
|
155
158
|
}
|
|
156
159
|
};
|
|
157
160
|
exports.AnthropicFrontendApplicationContribution = AnthropicFrontendApplicationContribution;
|
|
158
|
-
tslib_1.__decorate([
|
|
159
|
-
(0, inversify_1.inject)(core_1.PreferenceService),
|
|
160
|
-
tslib_1.__metadata("design:type", Object)
|
|
161
|
-
], AnthropicFrontendApplicationContribution.prototype, "preferenceService", void 0);
|
|
162
161
|
tslib_1.__decorate([
|
|
163
162
|
(0, inversify_1.inject)(common_1.AnthropicLanguageModelsManager),
|
|
164
163
|
tslib_1.__metadata("design:type", Object)
|
|
@@ -1 +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;;;;
|
|
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,4DAAkE;AAClE,sCAAsF;AACtF,2EAEyC;AACzC,uFAGuD;AACvD,sCAAoD;AACpD,4CAA0J;AAC1J,wDAAqG;AAGrG,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAGnC,IAAM,wCAAwC,GAA9C,MAAM,wCAAyC,SAAQ,yCAA0D;IAAjH;;QAQgB,eAAU,GAAG,qBAAqB,CAAC;QACnC,kBAAa,GAAG,WAAW,CAAC;QAC5B,6BAAwB,GAAG,4C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IAAI,CAAC,KAAK;oBACjE,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,MAAM,EAAE,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;oBACzF,eAAe,EAAE,IAAI,CAAC,eAAe,IAAI,IAAI;oBAC7C,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI;oBACnC,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,UAAU;oBACzC,OAAO,EAAE,IAAA,mCAAyB,EAAC,IAAI,CAAC,OAAO,CAAC;oBAChD,oCAAoC;oBACpC,2CAA2C;iBAC9C;aACJ,CAAC;QACN,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC;CAEJ,CAAA;AAxJY,4FAAwC;AAG9B;IADlB,IAAA,kBAAM,EAAC,uCAA8B,CAAC;;yEACoB;AAGjD;IADT,IAAA,kBAAM,EAAC,uCAAiB,CAAC;;mFACqB;mDANtC,wCAAwC;IADpD,IAAA,sBAAU,GAAE;GACA,wCAAwC,CAwJpD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ApiKeySource, ModelDiscoveryResult } from '@theia/ai-core/lib/common';
|
|
1
2
|
export declare const ANTHROPIC_LANGUAGE_MODELS_MANAGER_PATH = "/services/anthropic/language-model-manager";
|
|
2
3
|
export declare const AnthropicLanguageModelsManager: unique symbol;
|
|
3
4
|
export interface AnthropicModelDescription {
|
|
@@ -19,14 +20,33 @@ export interface AnthropicModelDescription {
|
|
|
19
20
|
headers?: Record<string, string>;
|
|
20
21
|
/** Resolved default enablement of server-side compaction (global preference folded with the per-provider override). Defaults to disabled when omitted. */
|
|
21
22
|
serverSideCompactionEnabledByDefault?: boolean;
|
|
23
|
+
/** Release date (ms since epoch) reported by discovery, surfaced as {@link LanguageModelMetaData.released}. */
|
|
24
|
+
released?: number;
|
|
22
25
|
/** Resolved default input-token threshold for server-side compaction. `undefined` preserves the provider default. */
|
|
23
26
|
serverSideCompactionTokenThresholdByDefault?: number;
|
|
24
27
|
}
|
|
25
28
|
export interface AnthropicLanguageModelsManager {
|
|
26
29
|
apiKey: string | undefined;
|
|
27
30
|
setApiKey(key: string | undefined): void;
|
|
31
|
+
/**
|
|
32
|
+
* Allows or refuses the use of an API key found in the environment. Refused by default: an
|
|
33
|
+
* environment key is only used once the user has confirmed it, and setting this back to `false`
|
|
34
|
+
* stops it being used immediately, wherever it would have been used.
|
|
35
|
+
*/
|
|
36
|
+
setAllowEnvironmentApiKey(allowed: boolean): void;
|
|
28
37
|
setProxyUrl(proxyUrl: string | undefined): void;
|
|
29
38
|
createOrUpdateLanguageModels(...models: AnthropicModelDescription[]): Promise<void>;
|
|
30
39
|
removeLanguageModels(...modelIds: string[]): void;
|
|
40
|
+
/**
|
|
41
|
+
* Fetches the models Anthropic currently offers from its `/v1/models` endpoint, retrying
|
|
42
|
+
* transient connection failures and persisting a snapshot for offline use.
|
|
43
|
+
*
|
|
44
|
+
* Requires an API key. Returns an empty result when no key is configured. On a live-fetch
|
|
45
|
+
* failure it falls back to the cached snapshot (`fromCache: true`) when one exists, and only
|
|
46
|
+
* throws when there is no cache to fall back to.
|
|
47
|
+
*/
|
|
48
|
+
fetchAvailableModels(): Promise<ModelDiscoveryResult>;
|
|
49
|
+
/** Reports where the effective API key comes from (preference, environment, or none). */
|
|
50
|
+
getApiKeySource(): Promise<ApiKeySource>;
|
|
31
51
|
}
|
|
32
52
|
//# sourceMappingURL=anthropic-language-models-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-language-models-manager.d.ts","sourceRoot":"","sources":["../../src/common/anthropic-language-models-manager.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,sCAAsC,+CAA+C,CAAC;AACnG,eAAO,MAAM,8BAA8B,eAA2C,CAAC;AAEvF,MAAM,WAAW,yBAAyB;IACtC,iEAAiE;IACjE,EAAE,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,oIAAoI;IACpI,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8FAA8F;IAC9F,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,wDAAwD;IACxD,eAAe,EAAE,OAAO,CAAC;IACzB,0DAA0D;IAC1D,UAAU,EAAE,OAAO,CAAC;IACpB,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC;IACnB,+HAA+H;IAC/H,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,0JAA0J;IAC1J,oCAAoC,CAAC,EAAE,OAAO,CAAC;IAC/C,qHAAqH;IACrH,2CAA2C,CAAC,EAAE,MAAM,CAAC;CACxD;AACD,MAAM,WAAW,8BAA8B;IAC3C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACzC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAChD,4BAA4B,CAAC,GAAG,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpF,oBAAoB,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"anthropic-language-models-manager.d.ts","sourceRoot":"","sources":["../../src/common/anthropic-language-models-manager.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAE/E,eAAO,MAAM,sCAAsC,+CAA+C,CAAC;AACnG,eAAO,MAAM,8BAA8B,eAA2C,CAAC;AAEvF,MAAM,WAAW,yBAAyB;IACtC,iEAAiE;IACjE,EAAE,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,oIAAoI;IACpI,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8FAA8F;IAC9F,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,wDAAwD;IACxD,eAAe,EAAE,OAAO,CAAC;IACzB,0DAA0D;IAC1D,UAAU,EAAE,OAAO,CAAC;IACpB,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC;IACnB,+HAA+H;IAC/H,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,0JAA0J;IAC1J,oCAAoC,CAAC,EAAE,OAAO,CAAC;IAC/C,+GAA+G;IAC/G,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qHAAqH;IACrH,2CAA2C,CAAC,EAAE,MAAM,CAAC;CACxD;AACD,MAAM,WAAW,8BAA8B;IAC3C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACzC;;;;OAIG;IACH,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAClD,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAChD,4BAA4B,CAAC,GAAG,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpF,oBAAoB,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAClD;;;;;;;OAOG;IACH,oBAAoB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACtD,yFAAyF;IACzF,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;CAC5C"}
|
|
@@ -1 +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;;;
|
|
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;;;AAInE,QAAA,sCAAsC,GAAG,4CAA4C,CAAC;AACtF,QAAA,8BAA8B,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PreferenceSchema } from '@theia/core';
|
|
2
2
|
export declare const API_KEY_PREF = "ai-features.anthropic.AnthropicApiKey";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const ALLOW_ENV_API_KEY_PREF = "ai-features.anthropic.allowEnvironmentApiKey";
|
|
4
|
+
export declare const MODEL_OVERRIDES_PREF = "ai-features.anthropic.modelOverrides";
|
|
4
5
|
export declare const CUSTOM_ENDPOINTS_PREF = "ai-features.anthropicCustom.customAnthropicModels";
|
|
5
6
|
export declare const SERVER_SIDE_COMPACTION_PREF = "ai-features.anthropic.serverSideCompaction";
|
|
6
7
|
export declare const SERVER_SIDE_COMPACTION_TOKEN_THRESHOLD_PREF = "ai-features.anthropic.serverSideCompactionTokenThreshold";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-preferences.d.ts","sourceRoot":"","sources":["../../src/common/anthropic-preferences.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAuB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpE,eAAO,MAAM,YAAY,0CAA0C,CAAC;AACpE,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"anthropic-preferences.d.ts","sourceRoot":"","sources":["../../src/common/anthropic-preferences.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAuB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpE,eAAO,MAAM,YAAY,0CAA0C,CAAC;AACpE,eAAO,MAAM,sBAAsB,iDAAiD,CAAC;AACrF,eAAO,MAAM,oBAAoB,yCAAyC,CAAC;AAC3E,eAAO,MAAM,qBAAqB,sDAAsD,CAAC;AACzF,eAAO,MAAM,2BAA2B,+CAA+C,CAAC;AACxF,eAAO,MAAM,2CAA2C,6DAA6D,CAAC;AAEtH,eAAO,MAAM,0BAA0B,EAAE,gBA2HxC,CAAC"}
|
|
@@ -15,12 +15,13 @@
|
|
|
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.AnthropicPreferencesSchema = exports.SERVER_SIDE_COMPACTION_TOKEN_THRESHOLD_PREF = exports.SERVER_SIDE_COMPACTION_PREF = exports.CUSTOM_ENDPOINTS_PREF = exports.
|
|
18
|
+
exports.AnthropicPreferencesSchema = exports.SERVER_SIDE_COMPACTION_TOKEN_THRESHOLD_PREF = exports.SERVER_SIDE_COMPACTION_PREF = exports.CUSTOM_ENDPOINTS_PREF = exports.MODEL_OVERRIDES_PREF = exports.ALLOW_ENV_API_KEY_PREF = exports.API_KEY_PREF = void 0;
|
|
19
19
|
const ai_core_preferences_1 = require("@theia/ai-core/lib/common/ai-core-preferences");
|
|
20
20
|
const language_model_1 = require("@theia/ai-core/lib/common/language-model");
|
|
21
21
|
const core_1 = require("@theia/core");
|
|
22
22
|
exports.API_KEY_PREF = 'ai-features.anthropic.AnthropicApiKey';
|
|
23
|
-
exports.
|
|
23
|
+
exports.ALLOW_ENV_API_KEY_PREF = 'ai-features.anthropic.allowEnvironmentApiKey';
|
|
24
|
+
exports.MODEL_OVERRIDES_PREF = 'ai-features.anthropic.modelOverrides';
|
|
24
25
|
exports.CUSTOM_ENDPOINTS_PREF = 'ai-features.anthropicCustom.customAnthropicModels';
|
|
25
26
|
exports.SERVER_SIDE_COMPACTION_PREF = 'ai-features.anthropic.serverSideCompaction';
|
|
26
27
|
exports.SERVER_SIDE_COMPACTION_TOKEN_THRESHOLD_PREF = 'ai-features.anthropic.serverSideCompactionTokenThreshold';
|
|
@@ -33,23 +34,22 @@ exports.AnthropicPreferencesSchema = {
|
|
|
33
34
|
on the machine running Theia. Use the environment variable `ANTHROPIC_API_KEY` to set the key securely.') + core_1.LINUX_ENV_HINT,
|
|
34
35
|
title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
|
|
35
36
|
},
|
|
36
|
-
[exports.
|
|
37
|
-
type: '
|
|
38
|
-
|
|
37
|
+
[exports.ALLOW_ENV_API_KEY_PREF]: {
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
default: false,
|
|
39
40
|
title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
|
|
40
|
-
|
|
41
|
-
'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
'claude-opus-4-6',
|
|
47
|
-
'claude-sonnet-4-6',
|
|
48
|
-
'claude-haiku-4-5',
|
|
49
|
-
],
|
|
41
|
+
markdownDescription: core_1.nls.localize('theia/ai/anthropic/allowEnvApiKey/description', 'Allow Theia to use an Anthropic API key found in the environment (`ANTHROPIC_API_KEY`). '
|
|
42
|
+
+ 'You are asked to confirm this once before the key is used; set it back to `false` to revoke consent.'),
|
|
43
|
+
},
|
|
44
|
+
[exports.MODEL_OVERRIDES_PREF]: {
|
|
45
|
+
type: 'array',
|
|
46
|
+
default: [],
|
|
50
47
|
items: {
|
|
51
48
|
type: 'string'
|
|
52
|
-
}
|
|
49
|
+
},
|
|
50
|
+
title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
|
|
51
|
+
markdownDescription: core_1.nls.localize('theia/ai/anthropic/modelOverrides/description', 'Override the models discovered from Anthropic. When empty (default), the available models are discovered from the provider. '
|
|
52
|
+
+ 'Set explicit model ids to use exactly those instead; discovery is then not used at all.')
|
|
53
53
|
},
|
|
54
54
|
[exports.SERVER_SIDE_COMPACTION_PREF]: {
|
|
55
55
|
type: 'string',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-preferences.js","sourceRoot":"","sources":["../../src/common/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;;;AAEhF,uFAEuD;AACvD,6EAA0G;AAC1G,sCAAoE;AAEvD,QAAA,YAAY,GAAG,uCAAuC,CAAC;AACvD,QAAA,
|
|
1
|
+
{"version":3,"file":"anthropic-preferences.js","sourceRoot":"","sources":["../../src/common/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;;;AAEhF,uFAEuD;AACvD,6EAA0G;AAC1G,sCAAoE;AAEvD,QAAA,YAAY,GAAG,uCAAuC,CAAC;AACvD,QAAA,sBAAsB,GAAG,8CAA8C,CAAC;AACxE,QAAA,oBAAoB,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AAC;wBAC3B,KAAK,EAAE,UAAG,CAAC,QAAQ,CAAC,iDAAiD,EACjE,wGAAwG,CAAC;qBAChH;oBACD,eAAe,EAAE;wBACb,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,UAAG,CAAC,QAAQ,CAAC,0DAA0D,EAC1E,uEAAuE,CAAC;qBAC/E;oBACD,UAAU,EAAE;wBACR,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,UAAG,CAAC,QAAQ,CAAC,qDAAqD,EACrE,wEAAwE,CAAC;qBAChF;oBACD,UAAU,EAAE;wBACR,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,UAAG,CAAC,QAAQ,CAAC,qDAAqD,EACrE,8DAA8D,CAAC;qBACtE;oBACD,OAAO,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,oBAAoB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACxC,KAAK,EAAE,UAAG,CAAC,QAAQ,CAAC,kDAAkD,EAClE,iEAAiE,CAAC;qBACzE;iBACJ;aACJ;SACJ;KACJ;CACJ,CAAC"}
|
|
@@ -34,6 +34,22 @@ export declare const AnthropicModelIdentifier: unique symbol;
|
|
|
34
34
|
* Implements the Anthropic language model integration for Theia. Reasoning-level
|
|
35
35
|
* translation lives in {@link anthropicReasoningFor}.
|
|
36
36
|
*/
|
|
37
|
+
/** Options for {@link createAnthropicClient}. */
|
|
38
|
+
export interface AnthropicClientOptions {
|
|
39
|
+
/** The key to authenticate with. A custom endpoint may need none. */
|
|
40
|
+
readonly apiKey: string | undefined;
|
|
41
|
+
/** Base URL of a custom endpoint; the SDK's own default is used without one. */
|
|
42
|
+
readonly baseURL?: string;
|
|
43
|
+
readonly proxyUrl?: string;
|
|
44
|
+
/** Additional HTTP headers sent with every request, e.g. headers required by a gateway in front of the API. */
|
|
45
|
+
readonly headers?: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The single place an Anthropic SDK client is built, so that a chat request, a model lookup and the
|
|
49
|
+
* model discovery all reach the provider the same way: through the configured proxy, and with a key
|
|
50
|
+
* the SDK accepts.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createAnthropicClient(options: AnthropicClientOptions): Anthropic;
|
|
37
53
|
export declare class AnthropicModel implements LanguageModel {
|
|
38
54
|
readonly id: string;
|
|
39
55
|
model: string;
|
|
@@ -54,9 +70,10 @@ export declare class AnthropicModel implements LanguageModel {
|
|
|
54
70
|
serverSideCompactionEnabledByDefault: boolean;
|
|
55
71
|
serverSideCompactionTokenThresholdByDefault?: number | undefined;
|
|
56
72
|
headers?: Record<string, string> | undefined;
|
|
73
|
+
released?: number | undefined;
|
|
57
74
|
/** Provider identifier, used to key per-provider settings (e.g. server tool selections) and the capabilities UI. */
|
|
58
75
|
readonly vendor = "anthropic";
|
|
59
|
-
constructor(id: string, model: string, status: LanguageModelStatus, enableStreaming: boolean, useCaching: boolean, apiKey: () => string | undefined, url: string | undefined, maxTokens?: number, maxRetries?: number, proxy?: string | undefined, reasoningSupport?: ReasoningSupport | undefined, reasoningApi?: ReasoningApi | undefined, supportsXHighEffort?: boolean | undefined, maxInputTokens?: number | undefined, serverTools?: ServerToolDescriptor[] | undefined, serverSideCompactionSupport?: boolean, serverSideCompactionEnabledByDefault?: boolean, serverSideCompactionTokenThresholdByDefault?: number | undefined, headers?: Record<string, string> | undefined);
|
|
76
|
+
constructor(id: string, model: string, status: LanguageModelStatus, enableStreaming: boolean, useCaching: boolean, apiKey: () => string | undefined, url: string | undefined, maxTokens?: number, maxRetries?: number, proxy?: string | undefined, reasoningSupport?: ReasoningSupport | undefined, reasoningApi?: ReasoningApi | undefined, supportsXHighEffort?: boolean | undefined, maxInputTokens?: number | undefined, serverTools?: ServerToolDescriptor[] | undefined, serverSideCompactionSupport?: boolean, serverSideCompactionEnabledByDefault?: boolean, serverSideCompactionTokenThresholdByDefault?: number | undefined, headers?: Record<string, string> | undefined, released?: number | undefined);
|
|
60
77
|
protected getSettings(request: LanguageModelRequest): Readonly<Record<string, unknown>>;
|
|
61
78
|
/** Resolves whether this request will route through the Anthropic Beta Messages API for server-side compaction. */
|
|
62
79
|
protected useServerSideCompaction(request: LanguageModelRequest): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-language-model.d.ts","sourceRoot":"","sources":["../../src/node/anthropic-language-model.ts"],"names":[],"mappings":"AAgBA,OAAO,EAIH,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,2BAA2B,EAE3B,yBAAyB,EACzB,YAAY,EACZ,gBAAgB,EAIhB,oBAAoB,EAIpB,WAAW,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAgB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAA+C,YAAY,EAAwC,MAAM,6BAA6B,CAAC;AAKnJ,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,yBAAyB,CAAC;AAkHtE;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACtC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,EACzC,eAAe,GAAE,OAAc,EAC/B,iBAAiB,GAAE,OAAe,GACnC;IAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IAAC,aAAa,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAA;CAAE,CAuBnF;AAED,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAwBzF;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,CA2B3H;AAED,eAAO,MAAM,wBAAwB,eAAqC,CAAC;AAmE3E;;;GAGG;AACH,qBAAa,cAAe,YAAW,aAAa;aAM5B,EAAE,EAAE,MAAM;IACnB,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,mBAAmB;IAC3B,eAAe,EAAE,OAAO;IACxB,UAAU,EAAE,OAAO;IACnB,MAAM,EAAE,MAAM,MAAM,GAAG,SAAS;IAChC,GAAG,EAAE,MAAM,GAAG,SAAS;IACvB,SAAS,EAAE,MAAM;IACjB,UAAU,EAAE,MAAM;IAClB,KAAK,CAAC,EAAE,MAAM;IACd,gBAAgB,CAAC,EAAE,gBAAgB;IACnC,YAAY,CAAC,EAAE,YAAY;IAC3B,mBAAmB,CAAC,EAAE,OAAO;IAC7B,cAAc,CAAC,EAAE,MAAM;IACvB,WAAW,CAAC,EAAE,oBAAoB,EAAE;IACpC,2BAA2B,EAAE,OAAO;IACpC,oCAAoC,EAAE,OAAO;IAC7C,2CAA2C,CAAC,EAAE,MAAM;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"anthropic-language-model.d.ts","sourceRoot":"","sources":["../../src/node/anthropic-language-model.ts"],"names":[],"mappings":"AAgBA,OAAO,EAIH,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,2BAA2B,EAE3B,yBAAyB,EACzB,YAAY,EACZ,gBAAgB,EAIhB,oBAAoB,EAIpB,WAAW,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAgB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAA+C,YAAY,EAAwC,MAAM,6BAA6B,CAAC;AAKnJ,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,yBAAyB,CAAC;AAkHtE;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACtC,QAAQ,EAAE,SA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;IAIzE;;;OAGG;IACH,SAAS,CAAC,qBAAqB,CAAC,CAAC,SAAS,SAAS,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,oBAAoB,GAAG,CAAC;IAgB/G,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAkB1F,sBAAsB,CAClC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,WAAW,EACpB,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,YAAY,CAAC,EAAE,SAAS,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,GAC1D,OAAO,CAAC,2BAA2B,CAAC;IAgPvC,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,SAAS;IAsBhG,sGAAsG;IACtG,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE;cAY1E,yBAAyB,CACrC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,WAAW,GACrB,OAAO,CAAC,yBAAyB,CAAC;IAqCrC,SAAS,CAAC,mBAAmB,IAAI,SAAS;CAQ7C"}
|
|
@@ -19,6 +19,7 @@ exports.AnthropicModel = exports.AnthropicModelIdentifier = exports.ANTHROPIC_RE
|
|
|
19
19
|
exports.transformToAnthropicParams = transformToAnthropicParams;
|
|
20
20
|
exports.mergeConsecutiveSameRoleMessages = mergeConsecutiveSameRoleMessages;
|
|
21
21
|
exports.addCacheControlToLastMessage = addCacheControlToLastMessage;
|
|
22
|
+
exports.createAnthropicClient = createAnthropicClient;
|
|
22
23
|
const ai_core_1 = require("@theia/ai-core");
|
|
23
24
|
const core_1 = require("@theia/core");
|
|
24
25
|
const sdk_1 = require("@anthropic-ai/sdk");
|
|
@@ -283,11 +284,21 @@ function buildServerToolResultPart(serverToolCalls, toolUseId, nativeName, resul
|
|
|
283
284
|
};
|
|
284
285
|
}
|
|
285
286
|
/**
|
|
286
|
-
*
|
|
287
|
-
*
|
|
287
|
+
* The single place an Anthropic SDK client is built, so that a chat request, a model lookup and the
|
|
288
|
+
* model discovery all reach the provider the same way: through the configured proxy, and with a key
|
|
289
|
+
* the SDK accepts.
|
|
288
290
|
*/
|
|
291
|
+
function createAnthropicClient(options) {
|
|
292
|
+
return new sdk_1.Anthropic({
|
|
293
|
+
// The SDK refuses to be constructed without a key, so an endpoint that needs none still gets one.
|
|
294
|
+
apiKey: options.apiKey ?? 'no-key',
|
|
295
|
+
baseURL: options.baseURL,
|
|
296
|
+
fetch: (0, node_1.createProxyFetch)(options.proxyUrl),
|
|
297
|
+
defaultHeaders: options.headers
|
|
298
|
+
});
|
|
299
|
+
}
|
|
289
300
|
class AnthropicModel {
|
|
290
|
-
constructor(id, model, status, enableStreaming, useCaching, apiKey, url, maxTokens = exports.DEFAULT_MAX_TOKENS, maxRetries = 3, proxy, reasoningSupport, reasoningApi, supportsXHighEffort, maxInputTokens, serverTools, serverSideCompactionSupport = false, serverSideCompactionEnabledByDefault = false, serverSideCompactionTokenThresholdByDefault, headers) {
|
|
301
|
+
constructor(id, model, status, enableStreaming, useCaching, apiKey, url, maxTokens = exports.DEFAULT_MAX_TOKENS, maxRetries = 3, proxy, reasoningSupport, reasoningApi, supportsXHighEffort, maxInputTokens, serverTools, serverSideCompactionSupport = false, serverSideCompactionEnabledByDefault = false, serverSideCompactionTokenThresholdByDefault, headers, released) {
|
|
291
302
|
this.id = id;
|
|
292
303
|
this.model = model;
|
|
293
304
|
this.status = status;
|
|
@@ -307,6 +318,7 @@ class AnthropicModel {
|
|
|
307
318
|
this.serverSideCompactionEnabledByDefault = serverSideCompactionEnabledByDefault;
|
|
308
319
|
this.serverSideCompactionTokenThresholdByDefault = serverSideCompactionTokenThresholdByDefault;
|
|
309
320
|
this.headers = headers;
|
|
321
|
+
this.released = released;
|
|
310
322
|
/** Provider identifier, used to key per-provider settings (e.g. server tool selections) and the capabilities UI. */
|
|
311
323
|
this.vendor = 'anthropic';
|
|
312
324
|
}
|
|
@@ -652,9 +664,7 @@ class AnthropicModel {
|
|
|
652
664
|
if (!apiKey && !(this.url)) {
|
|
653
665
|
throw new Error('Please provide ANTHROPIC_API_KEY in preferences or via environment variable');
|
|
654
666
|
}
|
|
655
|
-
|
|
656
|
-
const key = apiKey ?? 'no-key';
|
|
657
|
-
return new sdk_1.Anthropic({ apiKey: key, baseURL: this.url, fetch: (0, node_1.createProxyFetch)(this.proxy), defaultHeaders: this.headers });
|
|
667
|
+
return createAnthropicClient({ apiKey, baseURL: this.url, proxyUrl: this.proxy, headers: this.headers });
|
|
658
668
|
}
|
|
659
669
|
}
|
|
660
670
|
exports.AnthropicModel = AnthropicModel;
|