@theia/ai-core 1.76.0-next.4 → 1.76.0-next.42

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 (122) 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/node/ai-core-backend-module.d.ts.map +1 -1
  75. package/lib/node/ai-core-backend-module.js +8 -0
  76. package/lib/node/ai-core-backend-module.js.map +1 -1
  77. package/lib/node/backend-language-model-registry.d.ts.map +1 -1
  78. package/lib/node/backend-language-model-registry.js +1 -0
  79. package/lib/node/backend-language-model-registry.js.map +1 -1
  80. package/lib/node/index.d.ts +2 -0
  81. package/lib/node/index.d.ts.map +1 -1
  82. package/lib/node/index.js +2 -0
  83. package/lib/node/index.js.map +1 -1
  84. package/lib/node/model-discovery-fetcher.d.ts +43 -0
  85. package/lib/node/model-discovery-fetcher.d.ts.map +1 -0
  86. package/lib/node/model-discovery-fetcher.js +85 -0
  87. package/lib/node/model-discovery-fetcher.js.map +1 -0
  88. package/lib/node/model-snapshot-store.d.ts +26 -0
  89. package/lib/node/model-snapshot-store.d.ts.map +1 -0
  90. package/lib/node/model-snapshot-store.js +73 -0
  91. package/lib/node/model-snapshot-store.js.map +1 -0
  92. package/lib/node/test/test-model-discovery-fetcher.d.ts +21 -0
  93. package/lib/node/test/test-model-discovery-fetcher.d.ts.map +1 -0
  94. package/lib/node/test/test-model-discovery-fetcher.js +54 -0
  95. package/lib/node/test/test-model-discovery-fetcher.js.map +1 -0
  96. package/package.json +11 -11
  97. package/src/browser/ai-core-frontend-module.ts +5 -0
  98. package/src/browser/discovering-provider-contribution.spec.ts +304 -0
  99. package/src/browser/discovering-provider-contribution.ts +241 -0
  100. package/src/browser/favorite-models-service.spec.ts +336 -0
  101. package/src/browser/favorite-models-service.ts +297 -0
  102. package/src/browser/frontend-language-model-alias-registry.ts +1 -1
  103. package/src/browser/frontend-language-model-service.spec.ts +86 -0
  104. package/src/browser/frontend-language-model-service.ts +9 -1
  105. package/src/browser/index.ts +3 -0
  106. package/src/browser/model-discovery-status-service.spec.ts +101 -0
  107. package/src/browser/model-discovery-status-service.ts +123 -0
  108. package/src/common/ai-core-preferences.ts +40 -0
  109. package/src/common/index.ts +2 -0
  110. package/src/common/language-model-ordering.spec.ts +83 -0
  111. package/src/common/language-model-util.ts +43 -0
  112. package/src/common/language-model.spec.ts +45 -0
  113. package/src/common/language-model.ts +54 -0
  114. package/src/common/model-discovery-status.ts +132 -0
  115. package/src/common/model-discovery-util.spec.ts +105 -0
  116. package/src/common/model-discovery-util.ts +129 -0
  117. package/src/node/ai-core-backend-module.ts +8 -0
  118. package/src/node/backend-language-model-registry.ts +1 -0
  119. package/src/node/index.ts +2 -0
  120. package/src/node/model-discovery-fetcher.ts +105 -0
  121. package/src/node/model-snapshot-store.ts +80 -0
  122. package/src/node/test/test-model-discovery-fetcher.ts +62 -0
@@ -0,0 +1,128 @@
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.DiscoveredModels = void 0;
19
+ /**
20
+ * Helpers for the dated model ids that provider list endpoints report. Providers call these from
21
+ * an overridable method of their language-models manager, so a provider (or an adopter) can opt
22
+ * out or refine the behaviour without reimplementing it.
23
+ */
24
+ var DiscoveredModels;
25
+ (function (DiscoveredModels) {
26
+ /**
27
+ * The date suffix providers append to a release-pinned id: `-20260401` and `-2026-04-01`, plus the
28
+ * `-0613` (month and day only) form OpenAI used for its older snapshots. The month and day are
29
+ * range-checked so that an id merely ending in four digits — a context size, a version — is not
30
+ * mistaken for a release.
31
+ */
32
+ const DATE_SUFFIX = /-(?:(\d{4})-?(0[1-9]|1[0-2])-?(0[1-9]|[12]\d|3[01])|(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01]))$/;
33
+ /**
34
+ * The undated form of a release-pinned model id, e.g. `claude-opus-5-20260401` → `claude-opus-5`.
35
+ * Returns `undefined` when the id carries no date suffix.
36
+ */
37
+ function undatedId(id) {
38
+ const match = DATE_SUFFIX.exec(id);
39
+ return match ? id.substring(0, match.index) : undefined;
40
+ }
41
+ DiscoveredModels.undatedId = undatedId;
42
+ /**
43
+ * Adds the undated alias for every release-pinned model, keeping the pinned releases themselves.
44
+ *
45
+ * Providers such as Anthropic and OpenAI list one entry per release (`claude-opus-5-20260401`,
46
+ * `claude-opus-5-20251120`, …) while accepting the undated form (`claude-opus-5`) as a
47
+ * request-time alias for the newest of them. The undated id is what the built-in model aliases
48
+ * reference and what does not change from under a configuration when a new release ships, so it
49
+ * is registered even when the provider does not list it. The pinned releases stay registered too,
50
+ * so a specific release can be selected; what keeps them out of the way of the model pickers is
51
+ * that only undated ids are featured (see the favorite models service), not that they are hidden.
52
+ *
53
+ * The alias takes the metadata of the most recent variant. Aliases come first; the reported models
54
+ * keep their relative order after them. An alias the provider reported itself is left untouched.
55
+ */
56
+ function withUndatedAliases(models) {
57
+ const reported = new Set(models.map(model => model.id));
58
+ const aliases = new Map();
59
+ for (const model of models) {
60
+ const id = undatedId(model.id);
61
+ if (!id || reported.has(id)) {
62
+ continue;
63
+ }
64
+ const previous = aliases.get(id);
65
+ if (!previous || isNewer(model, previous)) {
66
+ aliases.set(id, { ...model, id });
67
+ }
68
+ }
69
+ return [...aliases.values(), ...models];
70
+ }
71
+ DiscoveredModels.withUndatedAliases = withUndatedAliases;
72
+ /**
73
+ * Whether the id is a pointer a provider maintains at the current model of a family, e.g.
74
+ * `gemini-flash-latest`. Such an id carries no version to compare, and does not need one: it
75
+ * resolves to whatever is newest by definition.
76
+ */
77
+ function isLatestPointer(id) {
78
+ return id.endsWith('-latest');
79
+ }
80
+ DiscoveredModels.isLatestPointer = isLatestPointer;
81
+ /**
82
+ * The version numbers in a model id, e.g. `gemini-3.7-flash` → `[3, 7]` and `claude-sonnet-4-5`
83
+ * → `[4, 5]`. A heuristic, and only meaningful between the models of one provider — and one
84
+ * vendor at that: it says nothing about `gpt-5` against `claude-sonnet-4.5`.
85
+ */
86
+ function versionOf(id) {
87
+ return (id.match(/\d+/g) ?? []).map(Number);
88
+ }
89
+ DiscoveredModels.versionOf = versionOf;
90
+ /**
91
+ * Compares two model ids by the version numbers in them, most recent first. A longer sequence wins
92
+ * a shared prefix, so `gemini-3.7` sorts before `gemini-3`.
93
+ */
94
+ function compareByVersion(left, right) {
95
+ const leftVersion = versionOf(left);
96
+ const rightVersion = versionOf(right);
97
+ for (let index = 0; index < Math.max(leftVersion.length, rightVersion.length); index++) {
98
+ const difference = (rightVersion[index] ?? -1) - (leftVersion[index] ?? -1);
99
+ if (difference !== 0) {
100
+ return difference;
101
+ }
102
+ }
103
+ return 0;
104
+ }
105
+ DiscoveredModels.compareByVersion = compareByVersion;
106
+ /**
107
+ * Whether `candidate` is a more recent variant than `current`. The release date the provider
108
+ * reported is authoritative and always comparable, so it decides whenever both carry one; the date
109
+ * in the id is the fallback, and it only orders ids of the same shape — a year-less `-0613` says
110
+ * nothing about which year it belongs to.
111
+ */
112
+ function isNewer(candidate, current) {
113
+ if (candidate.released !== undefined && current.released !== undefined) {
114
+ return candidate.released > current.released;
115
+ }
116
+ return idDate(candidate.id) > idDate(current.id);
117
+ }
118
+ /** The date in a release-pinned id as a comparable number, or `0` when there is none. */
119
+ function idDate(id) {
120
+ const match = DATE_SUFFIX.exec(id);
121
+ if (!match) {
122
+ return 0;
123
+ }
124
+ // Either the full `YYYYMMDD` (groups 1-3) or the year-less `MMDD` (groups 4-5).
125
+ return match[1] ? Number(`${match[1]}${match[2]}${match[3]}`) : Number(`${match[4]}${match[5]}`);
126
+ }
127
+ })(DiscoveredModels || (exports.DiscoveredModels = DiscoveredModels = {}));
128
+ //# sourceMappingURL=model-discovery-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-discovery-util.js","sourceRoot":"","sources":["../../src/common/model-discovery-util.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;;;AAIhF;;;;GAIG;AACH,IAAiB,gBAAgB,CAyGhC;AAzGD,WAAiB,gBAAgB;IAE7B;;;;;OAKG;IACH,MAAM,WAAW,GAAG,4FAA4F,CAAC;IAEjH;;;OAGG;IACH,SAAgB,SAAS,CAAC,EAAU;QAChC,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5D,CAAC;IAHe,0BAAS,YAGxB,CAAA;IAED;;;;;;;;;;;;;OAaG;IACH,SAAgB,kBAAkB,CAAC,MAAyB;QACxD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,IAAI,GAAG,EAA2B,CAAC;QACnD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC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3,"file":"model-discovery-util.spec.d.ts","sourceRoot":"","sources":["../../src/common/model-discovery-util.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,95 @@
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
+ const chai_1 = require("chai");
19
+ const model_discovery_util_1 = require("./model-discovery-util");
20
+ describe('DiscoveredModels.undatedId', () => {
21
+ it('strips a compact date suffix, as Anthropic uses', () => {
22
+ (0, chai_1.expect)(model_discovery_util_1.DiscoveredModels.undatedId('claude-opus-5-20260401')).to.equal('claude-opus-5');
23
+ });
24
+ it('strips a dashed date suffix, as OpenAI uses', () => {
25
+ (0, chai_1.expect)(model_discovery_util_1.DiscoveredModels.undatedId('gpt-4o-2024-11-20')).to.equal('gpt-4o');
26
+ });
27
+ it('strips the year-less snapshot suffix of OpenAI\'s older models', () => {
28
+ (0, chai_1.expect)(model_discovery_util_1.DiscoveredModels.undatedId('gpt-4-0613')).to.equal('gpt-4');
29
+ (0, chai_1.expect)(model_discovery_util_1.DiscoveredModels.undatedId('gpt-3.5-turbo-0125')).to.equal('gpt-3.5-turbo');
30
+ });
31
+ it('returns undefined for an id without a date suffix', () => {
32
+ (0, chai_1.expect)(model_discovery_util_1.DiscoveredModels.undatedId('claude-opus-5')).to.equal(undefined);
33
+ (0, chai_1.expect)(model_discovery_util_1.DiscoveredModels.undatedId('gemini-3.7-flash')).to.equal(undefined);
34
+ // A version suffix is not a date and must not be mistaken for one.
35
+ (0, chai_1.expect)(model_discovery_util_1.DiscoveredModels.undatedId('gemini-1.5-pro-002')).to.equal(undefined);
36
+ // Nor is a context size, even though it is four digits like a month and day.
37
+ (0, chai_1.expect)(model_discovery_util_1.DiscoveredModels.undatedId('some-model-4096')).to.equal(undefined);
38
+ (0, chai_1.expect)(model_discovery_util_1.DiscoveredModels.undatedId('gpt-4-1340')).to.equal(undefined);
39
+ });
40
+ });
41
+ describe('DiscoveredModels.withUndatedAliases', () => {
42
+ it('adds the undated alias while keeping the release-pinned ids', () => {
43
+ const result = model_discovery_util_1.DiscoveredModels.withUndatedAliases([
44
+ { id: 'claude-opus-5-20260401' },
45
+ { id: 'claude-haiku-4-5-20251001' }
46
+ ]);
47
+ (0, chai_1.expect)(result.map(model => model.id)).to.deep.equal([
48
+ 'claude-opus-5',
49
+ 'claude-haiku-4-5',
50
+ 'claude-opus-5-20260401',
51
+ 'claude-haiku-4-5-20251001'
52
+ ]);
53
+ });
54
+ it('adds one alias per family and gives it the metadata of the newest release', () => {
55
+ const result = model_discovery_util_1.DiscoveredModels.withUndatedAliases([
56
+ { id: 'claude-opus-5-20251120', label: 'Claude Opus 5 (November)', released: Date.parse('2025-11-20') },
57
+ { id: 'claude-opus-5-20260401', label: 'Claude Opus 5', released: Date.parse('2026-04-01') }
58
+ ]);
59
+ (0, chai_1.expect)(result.map(model => model.id)).to.deep.equal([
60
+ 'claude-opus-5',
61
+ 'claude-opus-5-20251120',
62
+ 'claude-opus-5-20260401'
63
+ ]);
64
+ (0, chai_1.expect)(result[0].label).to.equal('Claude Opus 5');
65
+ });
66
+ it('orders the variants by the reported release date, which the year-less ids cannot express', () => {
67
+ const result = model_discovery_util_1.DiscoveredModels.withUndatedAliases([
68
+ // June 2023 sorts after January 2024 by id alone; the reported dates say otherwise.
69
+ { id: 'gpt-4-0613', label: 'older', released: Date.parse('2023-06-13') },
70
+ { id: 'gpt-4-0125', label: 'newer', released: Date.parse('2024-01-25') }
71
+ ]);
72
+ (0, chai_1.expect)(result[0].id).to.equal('gpt-4');
73
+ (0, chai_1.expect)(result[0].label).to.equal('newer');
74
+ });
75
+ it('falls back to the date in the id when the provider reports none', () => {
76
+ const result = model_discovery_util_1.DiscoveredModels.withUndatedAliases([
77
+ { id: 'claude-opus-5-20251120', label: 'older' },
78
+ { id: 'claude-opus-5-20260401', label: 'newer' }
79
+ ]);
80
+ (0, chai_1.expect)(result[0].label).to.equal('newer');
81
+ });
82
+ it('leaves an alias the provider reported itself untouched', () => {
83
+ const result = model_discovery_util_1.DiscoveredModels.withUndatedAliases([
84
+ { id: 'gpt-4o', label: 'GPT-4o' },
85
+ { id: 'gpt-4o-2024-11-20', label: 'GPT-4o (2024-11-20)' }
86
+ ]);
87
+ (0, chai_1.expect)(result.map(model => model.id)).to.deep.equal(['gpt-4o', 'gpt-4o-2024-11-20']);
88
+ (0, chai_1.expect)(result[0].label).to.equal('GPT-4o');
89
+ });
90
+ it('passes undated models through unchanged', () => {
91
+ const models = [{ id: 'gemini-3.7-flash' }, { id: 'gemini-3.1-pro-preview' }];
92
+ (0, chai_1.expect)(model_discovery_util_1.DiscoveredModels.withUndatedAliases(models)).to.deep.equal(models);
93
+ });
94
+ });
95
+ //# sourceMappingURL=model-discovery-util.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-discovery-util.spec.js","sourceRoot":"","sources":["../../src/common/model-discovery-util.spec.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,+BAA8B;AAC9B,iEAA0D;AAE1D,QAAQ,CAAC,4BAA4B,EAAE,GAA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,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;YACjC,EAAE,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE,qBAAqB,EAAE;SAC5D,CAAC,CAAC;QACH,IAAA,aAAM,EAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC;QACrF,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QAC/C,MAAM,MAAM,GAAG,CAAC,EAAE,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,EAAE,EAAE,wBAAwB,EAAE,CAAC,CAAC;QAC9E,IAAA,aAAM,EAAC,uCAAgB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-core-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/ai-core-backend-module.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAgG/D,wBAIG"}
1
+ {"version":3,"file":"ai-core-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/ai-core-backend-module.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAkG/D,wBAUG"}
@@ -22,6 +22,8 @@ const connection_container_module_1 = require("@theia/core/lib/node/messaging/co
22
22
  const common_1 = require("../common");
23
23
  const backend_language_model_registry_1 = require("./backend-language-model-registry");
24
24
  const token_usage_service_impl_1 = require("./token-usage-service-impl");
25
+ const model_snapshot_store_1 = require("./model-snapshot-store");
26
+ const model_discovery_fetcher_1 = require("./model-discovery-fetcher");
25
27
  const agent_preferences_1 = require("../common/agent-preferences");
26
28
  const ai_core_preferences_1 = require("../common/ai-core-preferences");
27
29
  // We use a connection module to handle AI services separately for each frontend.
@@ -60,6 +62,12 @@ const aiCoreConnectionModule = connection_container_module_1.ConnectionContainer
60
62
  exports.default = new inversify_1.ContainerModule(bind => {
61
63
  bind(core_1.PreferenceContribution).toConstantValue({ schema: agent_preferences_1.AgentSettingsPreferenceSchema });
62
64
  (0, ai_core_preferences_1.bindAICorePreferences)(bind);
65
+ // Bound in the root container: the snapshots are per provider, not per frontend connection,
66
+ // and the provider managers resolving them live in connection-scoped child containers.
67
+ bind(model_snapshot_store_1.ModelSnapshotStoreImpl).toSelf().inSingletonScope();
68
+ bind(model_snapshot_store_1.ModelSnapshotStore).toService(model_snapshot_store_1.ModelSnapshotStoreImpl);
69
+ bind(model_discovery_fetcher_1.ModelDiscoveryFetcherImpl).toSelf().inSingletonScope();
70
+ bind(model_discovery_fetcher_1.ModelDiscoveryFetcher).toService(model_discovery_fetcher_1.ModelDiscoveryFetcherImpl);
63
71
  bind(connection_container_module_1.ConnectionContainerModule).toConstantValue(aiCoreConnectionModule);
64
72
  });
65
73
  //# sourceMappingURL=ai-core-backend-module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-core-backend-module.js","sourceRoot":"","sources":["../../src/node/ai-core-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;AAChF,4DAA+D;AAC/D,yFAG4C;AAC5C,s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AC;IAC5B,CAAC,CACJ,CACR;SACA,gBAAgB,EAAE,CAAC;IAExB,IAAI,CAAC,oEAAiC,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACpE,IAAI,CAAC,sCAA6B,CAAC,CAAC,SAAS,CAAC,oEAAiC,CAAC,CAAC;IACjF,IAAI,CAAC,wBAAiB,CAAC;SAClB,cAAc,CACX,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CACd,IAAI,2BAAoB,CACpB,kCAAyB,EACzB,MAAM,CAAC,EAAE;QACL,MAAM,OAAO,GACT,SAAS,CAAC,GAAG,CACT,oEAAiC,CACpC,CAAC;QACN,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC1B,OAAO,OAAO,CAAC;IACnB,CAAC,CACJ,CACR;SACA,gBAAgB,EAAE,CAAC;IAExB,IAAI,CAAC,0BAAiB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACpD,IAAI,CAAC,sBAAa,CAAC,CAAC,SAAS,CAAC,0BAAiB,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC;AAEH,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,6BAAsB,CAAC,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,iDAA6B,EAAE,CAAC,CAAC;IACxF,IAAA,2CAAqB,EAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CAAC,uDAAyB,CAAC,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC;AAC5E,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"ai-core-backend-module.js","sourceRoot":"","sources":["../../src/node/ai-core-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;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MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC5D,IAAI,CAAC,+CAAqB,CAAC,CAAC,SAAS,CAAC,mDAAyB,CAAC,CAAC;IACjE,IAAI,CAAC,uDAAyB,CAAC,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC;AAC5E,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"backend-language-model-registry.d.ts","sourceRoot":"","sources":["../../src/node/backend-language-model-registry.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,gCAAgC,EAAE,aAAa,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAEhI;;GAEG;AACH,qBACa,gCAAiC,SAAQ,gCAAgC;IAElF,OAAO,CAAC,MAAM,CAA0C;IAExD,SAAS,CAAC,MAAM,EAAE,2BAA2B,GAAG,IAAI;IAI3C,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI;IAShD,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI;IAOnC,kBAAkB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAOxH,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,qBAAqB;CAe7D"}
1
+ {"version":3,"file":"backend-language-model-registry.d.ts","sourceRoot":"","sources":["../../src/node/backend-language-model-registry.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,gCAAgC,EAAE,aAAa,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAEhI;;GAEG;AACH,qBACa,gCAAiC,SAAQ,gCAAgC;IAElF,OAAO,CAAC,MAAM,CAA0C;IAExD,SAAS,CAAC,MAAM,EAAE,2BAA2B,GAAG,IAAI;IAI3C,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI;IAShD,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI;IAOnC,kBAAkB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAOxH,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,qBAAqB;CAgB7D"}
@@ -56,6 +56,7 @@ let BackendLanguageModelRegistryImpl = class BackendLanguageModelRegistryImpl ex
56
56
  family: model.family,
57
57
  maxInputTokens: model.maxInputTokens,
58
58
  maxOutputTokens: model.maxOutputTokens,
59
+ released: model.released,
59
60
  reasoningSupport: model.reasoningSupport,
60
61
  serverTools: model.serverTools,
61
62
  serverSideCompactionSupport: model.serverSideCompactionSupport,
@@ -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,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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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,sEAA8D;AAC9D,4DAAyE;AAEzE,iEAA4D;AAE/C,QAAA,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AA8B9D,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAA/B;QAEH,2FAA2F;QACjF,gBAAW,GAAG,CAAC,CAAC;QAC1B,iGAAiG;QACvF,iBAAY,GAAG,GAAG,CAAC;IA+CjC,CAAC;IAvCG,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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,gFAA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E,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACxD,MAAM,aAAE,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;QACvE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yCAAyC,QAAQ,IAAI,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC5H,CAAC;IACL,CAAC;IAES,iBAAiB,CAAC,SAAkB;QAC1C,OAAO,IAAA,eAAQ,EAAkB,SAAS,CAAC,IAAI,OAAO,SAAS,CAAC,EAAE,KAAK,QAAQ,CAAC;IACpF,CAAC;IAES,KAAK,CAAC,YAAY,CAAC,QAAgB;QACzC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,eAAe,EAAE,CAAC;QACrE,OAAO,IAAI,aAAG,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,gCAAwB,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACnG,CAAC;CACJ,CAAA;AArCY,wDAAsB;AAGZ;IADlB,IAAA,kBAAM,EAAC,kCAAkB,CAAC;;kEAC+B;AAGvC;IADlB,IAAA,kBAAM,EAAC,cAAO,CAAC;IAAE,IAAA,iBAAK,EAAC,gCAAgC,CAAC;;sDACtB;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