@theia/ai-core 1.76.0-next.7 → 1.76.0

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 (128) hide show
  1. package/lib/browser/ai-core-frontend-module.d.ts.map +1 -1
  2. package/lib/browser/ai-core-frontend-module.js +4 -0
  3. package/lib/browser/ai-core-frontend-module.js.map +1 -1
  4. package/lib/browser/discovering-provider-contribution.d.ts +92 -0
  5. package/lib/browser/discovering-provider-contribution.d.ts.map +1 -0
  6. package/lib/browser/discovering-provider-contribution.js +189 -0
  7. package/lib/browser/discovering-provider-contribution.js.map +1 -0
  8. package/lib/browser/discovering-provider-contribution.spec.d.ts +2 -0
  9. package/lib/browser/discovering-provider-contribution.spec.d.ts.map +1 -0
  10. package/lib/browser/discovering-provider-contribution.spec.js +233 -0
  11. package/lib/browser/discovering-provider-contribution.spec.js.map +1 -0
  12. package/lib/browser/favorite-models-service.d.ts +135 -0
  13. package/lib/browser/favorite-models-service.d.ts.map +1 -0
  14. package/lib/browser/favorite-models-service.js +279 -0
  15. package/lib/browser/favorite-models-service.js.map +1 -0
  16. package/lib/browser/favorite-models-service.spec.d.ts +2 -0
  17. package/lib/browser/favorite-models-service.spec.d.ts.map +1 -0
  18. package/lib/browser/favorite-models-service.spec.js +277 -0
  19. package/lib/browser/favorite-models-service.spec.js.map +1 -0
  20. package/lib/browser/frontend-language-model-alias-registry.js +1 -1
  21. package/lib/browser/frontend-language-model-service.d.ts.map +1 -1
  22. package/lib/browser/frontend-language-model-service.js +8 -0
  23. package/lib/browser/frontend-language-model-service.js.map +1 -1
  24. package/lib/browser/frontend-language-model-service.spec.d.ts +2 -0
  25. package/lib/browser/frontend-language-model-service.spec.d.ts.map +1 -0
  26. package/lib/browser/frontend-language-model-service.spec.js +76 -0
  27. package/lib/browser/frontend-language-model-service.spec.js.map +1 -0
  28. package/lib/browser/index.d.ts +3 -0
  29. package/lib/browser/index.d.ts.map +1 -1
  30. package/lib/browser/index.js +3 -0
  31. package/lib/browser/index.js.map +1 -1
  32. package/lib/browser/model-discovery-status-service.d.ts +52 -0
  33. package/lib/browser/model-discovery-status-service.d.ts.map +1 -0
  34. package/lib/browser/model-discovery-status-service.js +110 -0
  35. package/lib/browser/model-discovery-status-service.js.map +1 -0
  36. package/lib/browser/model-discovery-status-service.spec.d.ts +2 -0
  37. package/lib/browser/model-discovery-status-service.spec.d.ts.map +1 -0
  38. package/lib/browser/model-discovery-status-service.spec.js +86 -0
  39. package/lib/browser/model-discovery-status-service.spec.js.map +1 -0
  40. package/lib/common/ai-core-preferences.d.ts +11 -0
  41. package/lib/common/ai-core-preferences.d.ts.map +1 -1
  42. package/lib/common/ai-core-preferences.js +37 -1
  43. package/lib/common/ai-core-preferences.js.map +1 -1
  44. package/lib/common/index.d.ts +2 -0
  45. package/lib/common/index.d.ts.map +1 -1
  46. package/lib/common/index.js +2 -0
  47. package/lib/common/index.js.map +1 -1
  48. package/lib/common/language-model-ordering.spec.d.ts +2 -0
  49. package/lib/common/language-model-ordering.spec.d.ts.map +1 -0
  50. package/lib/common/language-model-ordering.spec.js +72 -0
  51. package/lib/common/language-model-ordering.spec.js.map +1 -0
  52. package/lib/common/language-model-util.d.ts +17 -1
  53. package/lib/common/language-model-util.d.ts.map +1 -1
  54. package/lib/common/language-model-util.js +44 -1
  55. package/lib/common/language-model-util.js.map +1 -1
  56. package/lib/common/language-model.d.ts +21 -0
  57. package/lib/common/language-model.d.ts.map +1 -1
  58. package/lib/common/language-model.js +50 -1
  59. package/lib/common/language-model.js.map +1 -1
  60. package/lib/common/language-model.spec.js +36 -0
  61. package/lib/common/language-model.spec.js.map +1 -1
  62. package/lib/common/model-discovery-status.d.ts +112 -0
  63. package/lib/common/model-discovery-status.d.ts.map +1 -0
  64. package/lib/common/model-discovery-status.js +18 -0
  65. package/lib/common/model-discovery-status.js.map +1 -0
  66. package/lib/common/model-discovery-util.d.ts +46 -0
  67. package/lib/common/model-discovery-util.d.ts.map +1 -0
  68. package/lib/common/model-discovery-util.js +128 -0
  69. package/lib/common/model-discovery-util.js.map +1 -0
  70. package/lib/common/model-discovery-util.spec.d.ts +2 -0
  71. package/lib/common/model-discovery-util.spec.d.ts.map +1 -0
  72. package/lib/common/model-discovery-util.spec.js +95 -0
  73. package/lib/common/model-discovery-util.spec.js.map +1 -0
  74. package/lib/common/prompt-service.js +3 -3
  75. package/lib/common/prompt-service.js.map +1 -1
  76. package/lib/common/prompt-service.spec.js +5 -0
  77. package/lib/common/prompt-service.spec.js.map +1 -1
  78. package/lib/node/ai-core-backend-module.d.ts.map +1 -1
  79. package/lib/node/ai-core-backend-module.js +8 -0
  80. package/lib/node/ai-core-backend-module.js.map +1 -1
  81. package/lib/node/backend-language-model-registry.d.ts.map +1 -1
  82. package/lib/node/backend-language-model-registry.js +1 -0
  83. package/lib/node/backend-language-model-registry.js.map +1 -1
  84. package/lib/node/index.d.ts +2 -0
  85. package/lib/node/index.d.ts.map +1 -1
  86. package/lib/node/index.js +2 -0
  87. package/lib/node/index.js.map +1 -1
  88. package/lib/node/model-discovery-fetcher.d.ts +43 -0
  89. package/lib/node/model-discovery-fetcher.d.ts.map +1 -0
  90. package/lib/node/model-discovery-fetcher.js +85 -0
  91. package/lib/node/model-discovery-fetcher.js.map +1 -0
  92. package/lib/node/model-snapshot-store.d.ts +26 -0
  93. package/lib/node/model-snapshot-store.d.ts.map +1 -0
  94. package/lib/node/model-snapshot-store.js +73 -0
  95. package/lib/node/model-snapshot-store.js.map +1 -0
  96. package/lib/node/test/test-model-discovery-fetcher.d.ts +21 -0
  97. package/lib/node/test/test-model-discovery-fetcher.d.ts.map +1 -0
  98. package/lib/node/test/test-model-discovery-fetcher.js +54 -0
  99. package/lib/node/test/test-model-discovery-fetcher.js.map +1 -0
  100. package/package.json +12 -12
  101. package/src/browser/ai-core-frontend-module.ts +5 -0
  102. package/src/browser/discovering-provider-contribution.spec.ts +304 -0
  103. package/src/browser/discovering-provider-contribution.ts +241 -0
  104. package/src/browser/favorite-models-service.spec.ts +336 -0
  105. package/src/browser/favorite-models-service.ts +297 -0
  106. package/src/browser/frontend-language-model-alias-registry.ts +1 -1
  107. package/src/browser/frontend-language-model-service.spec.ts +86 -0
  108. package/src/browser/frontend-language-model-service.ts +9 -1
  109. package/src/browser/index.ts +3 -0
  110. package/src/browser/model-discovery-status-service.spec.ts +101 -0
  111. package/src/browser/model-discovery-status-service.ts +123 -0
  112. package/src/common/ai-core-preferences.ts +40 -0
  113. package/src/common/index.ts +2 -0
  114. package/src/common/language-model-ordering.spec.ts +83 -0
  115. package/src/common/language-model-util.ts +43 -0
  116. package/src/common/language-model.spec.ts +45 -0
  117. package/src/common/language-model.ts +54 -0
  118. package/src/common/model-discovery-status.ts +132 -0
  119. package/src/common/model-discovery-util.spec.ts +105 -0
  120. package/src/common/model-discovery-util.ts +129 -0
  121. package/src/common/prompt-service.spec.ts +6 -0
  122. package/src/common/prompt-service.ts +3 -3
  123. package/src/node/ai-core-backend-module.ts +8 -0
  124. package/src/node/backend-language-model-registry.ts +1 -0
  125. package/src/node/index.ts +2 -0
  126. package/src/node/model-discovery-fetcher.ts +105 -0
  127. package/src/node/model-snapshot-store.ts +80 -0
  128. package/src/node/test/test-model-discovery-fetcher.ts +62 -0
@@ -1 +1 @@
1
- {"version":3,"file":"backend-language-model-registry.js","sourceRoot":"","sources":["../../src/node/backend-language-model-registry.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,4DAA0D;AAC1D,sCAAgI;AAEhI;;GAEG;AAEI,IAAM,gCAAgC,GAAtC,MAAM,gCAAiC,SAAQ,yCAAgC;IAIlF,SAAS,CAAC,MAAmC;QACzC,IAAI,CAAC,MA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,eAAe;YACtC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;YACxC,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,2BAA2B,EAAE,KAAK,CAAC,2BAA2B;SACjE,CAAC;IACN,CAAC;CACJ,CAAA;AA9CY,4EAAgC;2CAAhC,gCAAgC;IAD5C,IAAA,sBAAU,GAAE;GACA,gCAAgC,CA8C5C"}
1
+ {"version":3,"file":"backend-language-model-registry.js","sourceRoot":"","sources":["../../src/node/backend-language-model-registry.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,4DAA0D;AAC1D,sCAAgI;AAEhI;;GAEG;AAEI,IAAM,gCAAgC,GAAtC,MAAM,gCAAiC,SAAQ,yCAAgC;IAIlF,SAAS,CAAC,MAAmC;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEQ,iBAAiB,CAAC,MAAuB;QAC9C,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;QAChD,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAChC,iDAAiD;QACjD,KAAK,IAAI,CAAC,GAAG,YAAY,EAAE,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7D,IAAI,CAAC,MAAM,EAAE,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChF,CAAC;IACL,CAAC;IAEQ,oBAAoB,CAAC,GAAa;QACvC,KAAK,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAChC,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACnB,IAAI,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAAE,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAEQ,KAAK,CAAC,kBAAkB,CAA0C,EAAU,EAAE,KAAiB;QACpG,MAAM,KAAK,CAAC,kBAAkB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAC1C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;IAED,aAAa,CAAC,KAAoB;QAC9B,OAAO;YACH,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;YACxC,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,2BAA2B,EAAE,KAAK,CAAC,2BAA2B;SACjE,CAAC;IACN,CAAC;CACJ,CAAA;AA/CY,4EAAgC;2CAAhC,gCAAgC;IAD5C,IAAA,sBAAU,GAAE;GACA,gCAAgC,CA+C5C"}
@@ -1,2 +1,4 @@
1
1
  export * from './proxy-util';
2
+ export * from './model-snapshot-store';
3
+ export * from './model-discovery-fetcher';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAgBA,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAgBA,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC"}
package/lib/node/index.js CHANGED
@@ -17,4 +17,6 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const tslib_1 = require("tslib");
19
19
  tslib_1.__exportStar(require("./proxy-util"), exports);
20
+ tslib_1.__exportStar(require("./model-snapshot-store"), exports);
21
+ tslib_1.__exportStar(require("./model-discovery-fetcher"), exports);
20
22
  //# 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,uDAA6B"}
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,uDAA6B;AAC7B,iEAAuC;AACvC,oEAA0C"}
@@ -0,0 +1,43 @@
1
+ import { ILogger } from '@theia/core';
2
+ import { DiscoveredModel, ModelDiscoveryResult } from '../common/model-discovery-status';
3
+ import { ModelSnapshotStore } from './model-snapshot-store';
4
+ export declare const ModelDiscoveryFetcher: unique symbol;
5
+ /** What a provider contributes to a discovery run; everything around it is the same for all of them. */
6
+ export interface ModelDiscoveryRequest {
7
+ /** Name the provider's snapshot is kept under, e.g. `anthropic-models.json`. */
8
+ readonly snapshotFile: string;
9
+ /** The provider, for the log entry a failed fetch leaves, e.g. `Anthropic`. */
10
+ readonly providerLabel: string;
11
+ /** Asks the provider what it offers. Called again while {@link isRetryable} accepts the failure. */
12
+ listModels(): Promise<DiscoveredModel[]>;
13
+ /**
14
+ * Whether a failure is transient enough to try again. Nothing is retried by default: a provider
15
+ * knows which of its SDK's errors are a connection giving out and which are an answer.
16
+ */
17
+ isRetryable?(error: unknown): boolean;
18
+ }
19
+ /**
20
+ * Runs a provider's model discovery: asks it what it offers, retries a transient failure, and keeps
21
+ * the answer as a snapshot so the models survive a later failure or an offline start.
22
+ */
23
+ export interface ModelDiscoveryFetcher {
24
+ /**
25
+ * Discovers the models of one provider. Returns the snapshot with `fromCache` set when the fetch
26
+ * failed and there is one, and rejects with the fetch's own error when there is not.
27
+ */
28
+ fetch(request: ModelDiscoveryRequest): Promise<ModelDiscoveryResult>;
29
+ }
30
+ export declare class ModelDiscoveryFetcherImpl implements ModelDiscoveryFetcher {
31
+ /** Number of attempts (including the first) for a discovery fetch on a retryable error. */
32
+ protected maxAttempts: number;
33
+ /** Base linear backoff between attempts; multiplied by the number of the attempt that failed. */
34
+ protected retryDelayMs: number;
35
+ protected readonly snapshotStore: ModelSnapshotStore;
36
+ protected readonly logger: ILogger;
37
+ fetch(request: ModelDiscoveryRequest): Promise<ModelDiscoveryResult>;
38
+ /** Lists the models, retrying a transient failure with a linear backoff. */
39
+ protected listWithRetry(request: ModelDiscoveryRequest): Promise<DiscoveredModel[]>;
40
+ /** Waits between two attempts. Overridable so a test does not have to. */
41
+ protected delay(ms: number): Promise<void>;
42
+ }
43
+ //# sourceMappingURL=model-discovery-fetcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-discovery-fetcher.d.ts","sourceRoot":"","sources":["../../src/node/model-discovery-fetcher.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,eAAO,MAAM,qBAAqB,eAAkC,CAAC;AAErE,wGAAwG;AACxG,MAAM,WAAW,qBAAqB;IAClC,gFAAgF;IAChF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+EAA+E;IAC/E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,oGAAoG;IACpG,UAAU,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACzC;;;OAGG;IACH,WAAW,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;CACzC;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IAClC;;;OAGG;IACH,KAAK,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACxE;AAED,qBACa,yBAA0B,YAAW,qBAAqB;IAEnE,2FAA2F;IAC3F,SAAS,CAAC,WAAW,SAAK;IAC1B,iGAAiG;IACjG,SAAS,CAAC,YAAY,SAAO;IAG7B,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,kBAAkB,CAAC;IAGrD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAE7B,KAAK,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkB1E,4EAA4E;cAC5D,aAAa,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAgBzF,0EAA0E;IAC1E,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG7C"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 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.ModelDiscoveryFetcherImpl = exports.ModelDiscoveryFetcher = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const core_1 = require("@theia/core");
21
+ const promise_util_1 = require("@theia/core/lib/common/promise-util");
22
+ const inversify_1 = require("@theia/core/shared/inversify");
23
+ const model_snapshot_store_1 = require("./model-snapshot-store");
24
+ exports.ModelDiscoveryFetcher = Symbol('ModelDiscoveryFetcher');
25
+ let ModelDiscoveryFetcherImpl = class ModelDiscoveryFetcherImpl {
26
+ constructor() {
27
+ /** Number of attempts (including the first) for a discovery fetch on a retryable error. */
28
+ this.maxAttempts = 3;
29
+ /** Base linear backoff between attempts; multiplied by the number of the attempt that failed. */
30
+ this.retryDelayMs = 500;
31
+ }
32
+ async fetch(request) {
33
+ try {
34
+ const models = await this.listWithRetry(request);
35
+ await this.snapshotStore.write(request.snapshotFile, models);
36
+ return { models, fromCache: false };
37
+ }
38
+ catch (error) {
39
+ const message = error instanceof Error ? error.message : String(error);
40
+ const cached = await this.snapshotStore.read(request.snapshotFile);
41
+ if (cached) {
42
+ this.logger.warn(`${request.providerLabel}: model discovery failed (${message}); using cached snapshot.`);
43
+ return { models: cached, fromCache: true, error: message };
44
+ }
45
+ // A run that never succeeded has no snapshot to fall back on, so record the failure here.
46
+ this.logger.error(`${request.providerLabel}: model discovery failed; no cached snapshot to fall back on.`, error);
47
+ throw error;
48
+ }
49
+ }
50
+ /** Lists the models, retrying a transient failure with a linear backoff. */
51
+ async listWithRetry(request) {
52
+ let lastError;
53
+ for (let attempt = 1; attempt <= this.maxAttempts; attempt++) {
54
+ try {
55
+ return await request.listModels();
56
+ }
57
+ catch (error) {
58
+ lastError = error;
59
+ if (attempt === this.maxAttempts || !request.isRetryable?.(error)) {
60
+ break;
61
+ }
62
+ await this.delay(this.retryDelayMs * attempt);
63
+ }
64
+ }
65
+ throw lastError;
66
+ }
67
+ /** Waits between two attempts. Overridable so a test does not have to. */
68
+ delay(ms) {
69
+ return (0, promise_util_1.timeout)(ms);
70
+ }
71
+ };
72
+ exports.ModelDiscoveryFetcherImpl = ModelDiscoveryFetcherImpl;
73
+ tslib_1.__decorate([
74
+ (0, inversify_1.inject)(model_snapshot_store_1.ModelSnapshotStore),
75
+ tslib_1.__metadata("design:type", Object)
76
+ ], ModelDiscoveryFetcherImpl.prototype, "snapshotStore", void 0);
77
+ tslib_1.__decorate([
78
+ (0, inversify_1.inject)(core_1.ILogger),
79
+ (0, inversify_1.named)('ai-core:ModelDiscoveryFetcherImpl'),
80
+ tslib_1.__metadata("design:type", Object)
81
+ ], ModelDiscoveryFetcherImpl.prototype, "logger", void 0);
82
+ exports.ModelDiscoveryFetcherImpl = ModelDiscoveryFetcherImpl = tslib_1.__decorate([
83
+ (0, inversify_1.injectable)()
84
+ ], ModelDiscoveryFetcherImpl);
85
+ //# sourceMappingURL=model-discovery-fetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-discovery-fetcher.js","sourceRoot":"","sources":["../../src/node/model-discovery-fetcher.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,sCAAsC;AACtC,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AC,aAAa,CAAC,OAA8B;QACxD,IAAI,SAAkB,CAAC;QACvB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC;YAC3D,IAAI,CAAC;gBACD,OAAO,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;YACtC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,SAAS,GAAG,KAAK,CAAC;gBAClB,IAAI,OAAO,KAAK,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;oBAChE,MAAM;gBACV,CAAC;gBACD,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,CAAC;YAClD,CAAC;QACL,CAAC;QACD,MAAM,SAAS,CAAC;IACpB,CAAC;IAED,0EAA0E;IAChE,KAAK,CAAC,EAAU;QACtB,OAAO,IAAA,sBAAO,EAAC,EAAE,CAAC,CAAC;IACvB,CAAC;CACJ,CAAA;AApDY,8DAAyB;AAQf;IADlB,IAAA,kBAAM,EAAC,yCAAkB,CAAC;;gEAC0B;AAGlC;IADlB,IAAA,kBAAM,EAAC,cAAO,CAAC;IAAE,IAAA,iBAAK,EAAC,mCAAmC,CAAC;;yDACzB;oCAX1B,yBAAyB;IADrC,IAAA,sBAAU,GAAE;GACA,yBAAyB,CAoDrC"}
@@ -0,0 +1,26 @@
1
+ import { ILogger } from '@theia/core';
2
+ import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
3
+ import { DiscoveredModel } from '../common/model-discovery-status';
4
+ export declare const ModelSnapshotStore: unique symbol;
5
+ /** Directory below the configuration directory that holds the snapshots, one file per provider. */
6
+ export declare const MODEL_SNAPSHOT_DIRECTORY = "model-snapshots";
7
+ /**
8
+ * Persists what a provider's model discovery found, so the models stay available when a later
9
+ * fetch fails or the application starts offline.
10
+ */
11
+ export interface ModelSnapshotStore {
12
+ /** Reads a provider's snapshot, or `undefined` when there is none (or it cannot be read). */
13
+ read(fileName: string): Promise<DiscoveredModel[] | undefined>;
14
+ /** Writes a provider's snapshot. Failures are logged, not thrown: a snapshot is a convenience. */
15
+ write(fileName: string, models: DiscoveredModel[]): Promise<void>;
16
+ }
17
+ /** Stores one JSON file per provider in {@link MODEL_SNAPSHOT_DIRECTORY} below the configuration directory. */
18
+ export declare class ModelSnapshotStoreImpl implements ModelSnapshotStore {
19
+ protected readonly envVariablesServer: EnvVariablesServer;
20
+ protected readonly logger: ILogger;
21
+ read(fileName: string): Promise<DiscoveredModel[] | undefined>;
22
+ write(fileName: string, models: DiscoveredModel[]): Promise<void>;
23
+ protected isDiscoveredModel(candidate: unknown): candidate is DiscoveredModel;
24
+ protected snapshotPath(fileName: string): Promise<string>;
25
+ }
26
+ //# sourceMappingURL=model-snapshot-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-snapshot-store.d.ts","sourceRoot":"","sources":["../../src/node/model-snapshot-store.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,OAAO,EAAY,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAE/D,mGAAmG;AACnG,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAC/B,6FAA6F;IAC7F,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,SAAS,CAAC,CAAC;IAC/D,kGAAkG;IAClG,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrE;AAED,+GAA+G;AAC/G,qBACa,sBAAuB,YAAW,kBAAkB;IAG7D,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAG1D,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAE7B,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,SAAS,CAAC;IAW9D,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUvE,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,eAAe;cAI7D,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAIlE"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 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.ModelSnapshotStoreImpl = exports.MODEL_SNAPSHOT_DIRECTORY = exports.ModelSnapshotStore = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const fs_1 = require("fs");
21
+ const path = require("path");
22
+ const core_1 = require("@theia/core");
23
+ const env_variables_1 = require("@theia/core/lib/common/env-variables");
24
+ const uri_1 = require("@theia/core/lib/common/uri");
25
+ const inversify_1 = require("@theia/core/shared/inversify");
26
+ exports.ModelSnapshotStore = Symbol('ModelSnapshotStore');
27
+ /** Directory below the configuration directory that holds the snapshots, one file per provider. */
28
+ exports.MODEL_SNAPSHOT_DIRECTORY = 'model-snapshots';
29
+ /** Stores one JSON file per provider in {@link MODEL_SNAPSHOT_DIRECTORY} below the configuration directory. */
30
+ let ModelSnapshotStoreImpl = class ModelSnapshotStoreImpl {
31
+ async read(fileName) {
32
+ try {
33
+ const content = await fs_1.promises.readFile(await this.snapshotPath(fileName), 'utf8');
34
+ const models = JSON.parse(content).models;
35
+ return Array.isArray(models) ? models.filter(model => this.isDiscoveredModel(model)) : undefined;
36
+ }
37
+ catch {
38
+ // A missing or unreadable snapshot is an expected state, not an error: discovery falls back to a live fetch.
39
+ return undefined;
40
+ }
41
+ }
42
+ async write(fileName, models) {
43
+ try {
44
+ const file = await this.snapshotPath(fileName);
45
+ await fs_1.promises.mkdir(path.dirname(file), { recursive: true });
46
+ await fs_1.promises.writeFile(file, JSON.stringify({ models }, undefined, 2));
47
+ }
48
+ catch (error) {
49
+ this.logger.warn(`Failed to persist the model snapshot '${fileName}':`, error instanceof Error ? error.message : error);
50
+ }
51
+ }
52
+ isDiscoveredModel(candidate) {
53
+ return (0, core_1.isObject)(candidate) && typeof candidate.id === 'string';
54
+ }
55
+ async snapshotPath(fileName) {
56
+ const configDirUri = await this.envVariablesServer.getConfigDirUri();
57
+ return new uri_1.default(configDirUri).resolve(exports.MODEL_SNAPSHOT_DIRECTORY).resolve(fileName).path.fsPath();
58
+ }
59
+ };
60
+ exports.ModelSnapshotStoreImpl = ModelSnapshotStoreImpl;
61
+ tslib_1.__decorate([
62
+ (0, inversify_1.inject)(env_variables_1.EnvVariablesServer),
63
+ tslib_1.__metadata("design:type", Object)
64
+ ], ModelSnapshotStoreImpl.prototype, "envVariablesServer", void 0);
65
+ tslib_1.__decorate([
66
+ (0, inversify_1.inject)(core_1.ILogger),
67
+ (0, inversify_1.named)('ai-core:ModelSnapshotStoreImpl'),
68
+ tslib_1.__metadata("design:type", Object)
69
+ ], ModelSnapshotStoreImpl.prototype, "logger", void 0);
70
+ exports.ModelSnapshotStoreImpl = ModelSnapshotStoreImpl = tslib_1.__decorate([
71
+ (0, inversify_1.injectable)()
72
+ ], ModelSnapshotStoreImpl);
73
+ //# sourceMappingURL=model-snapshot-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-snapshot-store.js","sourceRoot":"","sources":["../../src/node/model-snapshot-store.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,2BAAoC;AACpC,6BAA6B;AAC7B,sCAAgD;AAChD,wEAA0E;AAC1E,oDAA6C;AAC7C,4DAAyE;AAG5D,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAE/D,mGAAmG;AACtF,QAAA,wBAAwB,GAAG,iBAAiB,CAAC;AAa1D,+GAA+G;AAExG,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAQ/B,KAAK,CAAC,IAAI,CAAC,QAAgB;QACvB,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,aAAE,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;YAC7E,MAAM,MAAM,GAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAA0B,CAAC,MAAM,CAAC;YACpE,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrG,CAAC;QAAC,MAAM,CAAC;YACL,6GAA6G;YAC7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tB;iCAN1B,sBAAsB;IADlC,IAAA,sBAAU,GAAE;GACA,sBAAsB,CAqClC"}
@@ -0,0 +1,21 @@
1
+ import { DiscoveredModel } from '../../common/model-discovery-status';
2
+ import { ModelDiscoveryFetcherImpl } from '../model-discovery-fetcher';
3
+ import { ModelSnapshotStore } from '../model-snapshot-store';
4
+ /** Keeps what a discovery run writes in memory, so a test can seed and inspect the snapshot. */
5
+ export declare class InMemoryModelSnapshotStore implements ModelSnapshotStore {
6
+ snapshot: DiscoveredModel[] | undefined;
7
+ read(): Promise<DiscoveredModel[] | undefined>;
8
+ write(_fileName: string, models: DiscoveredModel[]): Promise<void>;
9
+ }
10
+ /**
11
+ * The real fetcher against an in-memory snapshot store and without the waiting, so that a provider's
12
+ * spec exercises the retry and fallback behaviour it actually runs with.
13
+ */
14
+ export declare class TestModelDiscoveryFetcher extends ModelDiscoveryFetcherImpl {
15
+ readonly store: InMemoryModelSnapshotStore;
16
+ get snapshot(): DiscoveredModel[] | undefined;
17
+ set snapshot(models: DiscoveredModel[] | undefined);
18
+ constructor();
19
+ protected delay(): Promise<void>;
20
+ }
21
+ //# sourceMappingURL=test-model-discovery-fetcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-model-discovery-fetcher.d.ts","sourceRoot":"","sources":["../../../src/node/test/test-model-discovery-fetcher.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,gGAAgG;AAChG,qBAAa,0BAA2B,YAAW,kBAAkB;IAEjE,QAAQ,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC;IAElC,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,SAAS,CAAC;IAI9C,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3E;AAED;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,yBAAyB;IAEpE,QAAQ,CAAC,KAAK,6BAAoC;IAElD,IAAI,QAAQ,IAAI,eAAe,EAAE,GAAG,SAAS,CAE5C;IAED,IAAI,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,SAAS,EAEjD;;cASkB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5C"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 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.TestModelDiscoveryFetcher = exports.InMemoryModelSnapshotStore = void 0;
19
+ const mock_logger_1 = require("@theia/core/lib/common/test/mock-logger");
20
+ const model_discovery_fetcher_1 = require("../model-discovery-fetcher");
21
+ /** Keeps what a discovery run writes in memory, so a test can seed and inspect the snapshot. */
22
+ class InMemoryModelSnapshotStore {
23
+ async read() {
24
+ return this.snapshot;
25
+ }
26
+ async write(_fileName, models) {
27
+ this.snapshot = [...models];
28
+ }
29
+ }
30
+ exports.InMemoryModelSnapshotStore = InMemoryModelSnapshotStore;
31
+ /**
32
+ * The real fetcher against an in-memory snapshot store and without the waiting, so that a provider's
33
+ * spec exercises the retry and fallback behaviour it actually runs with.
34
+ */
35
+ class TestModelDiscoveryFetcher extends model_discovery_fetcher_1.ModelDiscoveryFetcherImpl {
36
+ get snapshot() {
37
+ return this.store.snapshot;
38
+ }
39
+ set snapshot(models) {
40
+ this.store.snapshot = models;
41
+ }
42
+ constructor() {
43
+ super();
44
+ this.store = new InMemoryModelSnapshotStore();
45
+ const injected = this;
46
+ injected.snapshotStore = this.store;
47
+ injected.logger = new mock_logger_1.MockLogger();
48
+ }
49
+ delay() {
50
+ return Promise.resolve();
51
+ }
52
+ }
53
+ exports.TestModelDiscoveryFetcher = TestModelDiscoveryFetcher;
54
+ //# sourceMappingURL=test-model-discovery-fetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-model-discovery-fetcher.js","sourceRoot":"","sources":["../../../src/node/test/test-model-discovery-fetcher.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,yEAAqE;AAErE,wEAAuE;AAGvE,gGAAgG;AAChG,MAAa,0BAA0B;IAInC,KAAK,CAAC,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,SAAiB,EAAE,MAAyB;QACpD,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAChC,CAAC;CACJ;AAXD,gEAWC;AAED;;;GAGG;AACH,MAAa,yBAA0B,SAAQ,mDAAyB;IAIpE,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED,IAAI,QAAQ,CAAC,MAAqC;QAC9C,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC;IACjC,CAAC;IAED;QACI,KAAK,EAAE,CAAC;QAXH,UAAK,GAAG,IAAI,0BAA0B,EAAE,CAAC;QAY9C,MAAM,QAAQ,GAAG,IAA4E,CAAC;QAC9F,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC;QACpC,QAAQ,CAAC,MAAM,GAAG,IAAI,wBAAU,EAAE,CAAC;IACvC,CAAC;IAEkB,KAAK;QACpB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ;AAtBD,8DAsBC"}
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@theia/ai-core",
3
- "version": "1.76.0-next.7+7c303b183",
3
+ "version": "1.76.0",
4
4
  "description": "Theia - AI Core",
5
5
  "dependencies": {
6
- "@theia/core": "1.76.0-next.7+7c303b183",
7
- "@theia/editor": "1.76.0-next.7+7c303b183",
8
- "@theia/filesystem": "1.76.0-next.7+7c303b183",
9
- "@theia/monaco": "1.76.0-next.7+7c303b183",
6
+ "@theia/core": "1.76.0",
7
+ "@theia/editor": "1.76.0",
8
+ "@theia/filesystem": "1.76.0",
9
+ "@theia/monaco": "1.76.0",
10
10
  "@theia/monaco-editor-core": "1.108.201",
11
- "@theia/output": "1.76.0-next.7+7c303b183",
12
- "@theia/variable-resolver": "1.76.0-next.7+7c303b183",
13
- "@theia/workspace": "1.76.0-next.7+7c303b183",
11
+ "@theia/output": "1.76.0",
12
+ "@theia/variable-resolver": "1.76.0",
13
+ "@theia/workspace": "1.76.0",
14
14
  "@types/js-yaml": "^4.0.9",
15
15
  "fast-deep-equal": "^3.1.3",
16
- "js-yaml": "^4.3.1",
16
+ "js-yaml": "^4.3.2",
17
17
  "tslib": "^2.8.1",
18
- "undici": "^7.29.0"
18
+ "undici": "^7.29.1"
19
19
  },
20
20
  "main": "lib/common",
21
21
  "publishConfig": {
@@ -53,10 +53,10 @@
53
53
  "watch": "theiaext watch"
54
54
  },
55
55
  "devDependencies": {
56
- "@theia/ext-scripts": "1.75.0"
56
+ "@theia/ext-scripts": "1.76.0"
57
57
  },
58
58
  "nyc": {
59
59
  "extends": "../../configs/nyc.json"
60
60
  },
61
- "gitHead": "7c303b1836421183d7013f0bd679a9a30ff0b5dc"
61
+ "gitHead": "b9b54c500b46515512e2b44371bc0c7122947bed"
62
62
  }
@@ -22,6 +22,8 @@ import {
22
22
  import { ContainerModule } from '@theia/core/shared/inversify';
23
23
  import { DefaultLanguageModelAliasRegistry } from './frontend-language-model-alias-registry';
24
24
  import { HideAiPreferencesContribution, aiConfigurationOpenPlaceholderSchema } from './hide-ai-preferences-contribution';
25
+ import { ModelDiscoveryStatusService } from './model-discovery-status-service';
26
+ import { FavoriteModelsService } from './favorite-models-service';
25
27
  import { TrustAwarePreferenceReader } from './trust-aware-preference-reader';
26
28
  import { AiConfigurationServiceImpl } from './ai-configuration-service-impl';
27
29
  import { LanguageModelAliasRegistry } from '../common/language-model-alias';
@@ -207,6 +209,9 @@ export default new ContainerModule(bind => {
207
209
  // ...and leave a single placeholder entry there that links to the AI Configuration view.
208
210
  bind(PreferenceContribution).toConstantValue({ schema: aiConfigurationOpenPlaceholderSchema });
209
211
 
212
+ bind(ModelDiscoveryStatusService).toSelf().inSingletonScope();
213
+ bind(FavoriteModelsService).toSelf().inSingletonScope();
214
+
210
215
  // Internal implementation detail of AiConfigurationService; consumers inject AiConfigurationService.
211
216
  bind(TrustAwarePreferenceReader).toSelf().inSingletonScope();
212
217