@theia/ai-core 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.
Files changed (107) 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 +232 -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/index.d.ts +3 -0
  21. package/lib/browser/index.d.ts.map +1 -1
  22. package/lib/browser/index.js +3 -0
  23. package/lib/browser/index.js.map +1 -1
  24. package/lib/browser/model-discovery-status-service.d.ts +51 -0
  25. package/lib/browser/model-discovery-status-service.d.ts.map +1 -0
  26. package/lib/browser/model-discovery-status-service.js +103 -0
  27. package/lib/browser/model-discovery-status-service.js.map +1 -0
  28. package/lib/browser/model-discovery-status-service.spec.d.ts +2 -0
  29. package/lib/browser/model-discovery-status-service.spec.d.ts.map +1 -0
  30. package/lib/browser/model-discovery-status-service.spec.js +81 -0
  31. package/lib/browser/model-discovery-status-service.spec.js.map +1 -0
  32. package/lib/common/ai-core-preferences.d.ts +11 -0
  33. package/lib/common/ai-core-preferences.d.ts.map +1 -1
  34. package/lib/common/ai-core-preferences.js +37 -1
  35. package/lib/common/ai-core-preferences.js.map +1 -1
  36. package/lib/common/index.d.ts +2 -0
  37. package/lib/common/index.d.ts.map +1 -1
  38. package/lib/common/index.js +2 -0
  39. package/lib/common/index.js.map +1 -1
  40. package/lib/common/language-model-ordering.spec.d.ts +2 -0
  41. package/lib/common/language-model-ordering.spec.d.ts.map +1 -0
  42. package/lib/common/language-model-ordering.spec.js +72 -0
  43. package/lib/common/language-model-ordering.spec.js.map +1 -0
  44. package/lib/common/language-model-util.d.ts +17 -1
  45. package/lib/common/language-model-util.d.ts.map +1 -1
  46. package/lib/common/language-model-util.js +44 -1
  47. package/lib/common/language-model-util.js.map +1 -1
  48. package/lib/common/language-model.d.ts +5 -0
  49. package/lib/common/language-model.d.ts.map +1 -1
  50. package/lib/common/language-model.js.map +1 -1
  51. package/lib/common/model-discovery-status.d.ts +112 -0
  52. package/lib/common/model-discovery-status.d.ts.map +1 -0
  53. package/lib/common/model-discovery-status.js +18 -0
  54. package/lib/common/model-discovery-status.js.map +1 -0
  55. package/lib/common/model-discovery-util.d.ts +46 -0
  56. package/lib/common/model-discovery-util.d.ts.map +1 -0
  57. package/lib/common/model-discovery-util.js +128 -0
  58. package/lib/common/model-discovery-util.js.map +1 -0
  59. package/lib/common/model-discovery-util.spec.d.ts +2 -0
  60. package/lib/common/model-discovery-util.spec.d.ts.map +1 -0
  61. package/lib/common/model-discovery-util.spec.js +95 -0
  62. package/lib/common/model-discovery-util.spec.js.map +1 -0
  63. package/lib/node/ai-core-backend-module.d.ts.map +1 -1
  64. package/lib/node/ai-core-backend-module.js +8 -0
  65. package/lib/node/ai-core-backend-module.js.map +1 -1
  66. package/lib/node/backend-language-model-registry.d.ts.map +1 -1
  67. package/lib/node/backend-language-model-registry.js +1 -0
  68. package/lib/node/backend-language-model-registry.js.map +1 -1
  69. package/lib/node/index.d.ts +2 -0
  70. package/lib/node/index.d.ts.map +1 -1
  71. package/lib/node/index.js +2 -0
  72. package/lib/node/index.js.map +1 -1
  73. package/lib/node/model-discovery-fetcher.d.ts +43 -0
  74. package/lib/node/model-discovery-fetcher.d.ts.map +1 -0
  75. package/lib/node/model-discovery-fetcher.js +83 -0
  76. package/lib/node/model-discovery-fetcher.js.map +1 -0
  77. package/lib/node/model-snapshot-store.d.ts +26 -0
  78. package/lib/node/model-snapshot-store.d.ts.map +1 -0
  79. package/lib/node/model-snapshot-store.js +73 -0
  80. package/lib/node/model-snapshot-store.js.map +1 -0
  81. package/lib/node/test/test-model-discovery-fetcher.d.ts +21 -0
  82. package/lib/node/test/test-model-discovery-fetcher.d.ts.map +1 -0
  83. package/lib/node/test/test-model-discovery-fetcher.js +54 -0
  84. package/lib/node/test/test-model-discovery-fetcher.js.map +1 -0
  85. package/package.json +9 -9
  86. package/src/browser/ai-core-frontend-module.ts +5 -0
  87. package/src/browser/discovering-provider-contribution.spec.ts +303 -0
  88. package/src/browser/discovering-provider-contribution.ts +241 -0
  89. package/src/browser/favorite-models-service.spec.ts +336 -0
  90. package/src/browser/favorite-models-service.ts +297 -0
  91. package/src/browser/index.ts +3 -0
  92. package/src/browser/model-discovery-status-service.spec.ts +95 -0
  93. package/src/browser/model-discovery-status-service.ts +118 -0
  94. package/src/common/ai-core-preferences.ts +40 -0
  95. package/src/common/index.ts +2 -0
  96. package/src/common/language-model-ordering.spec.ts +83 -0
  97. package/src/common/language-model-util.ts +43 -0
  98. package/src/common/language-model.ts +5 -0
  99. package/src/common/model-discovery-status.ts +132 -0
  100. package/src/common/model-discovery-util.spec.ts +105 -0
  101. package/src/common/model-discovery-util.ts +129 -0
  102. package/src/node/ai-core-backend-module.ts +8 -0
  103. package/src/node/backend-language-model-registry.ts +1 -0
  104. package/src/node/index.ts +2 -0
  105. package/src/node/model-discovery-fetcher.ts +103 -0
  106. package/src/node/model-snapshot-store.ts +80 -0
  107. package/src/node/test/test-model-discovery-fetcher.ts +62 -0
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Provider-level state of dynamic model discovery.
3
+ *
4
+ * This is distinct from the per-model {@link LanguageModelStatus} (`ready`/`unavailable`):
5
+ * it describes whether a provider's list of models is currently being fetched, has failed,
6
+ * needs credentials or user consent, etc. It gives the UI a place to communicate fetching
7
+ * progress and error state for the whole provider.
8
+ */
9
+ export type ModelDiscoveryState =
10
+ /** No credential (API key / host) is configured, so nothing can be fetched. */
11
+ 'no-credentials'
12
+ /** A credential was found in the environment and awaits the user's one-time confirmation. */
13
+ | 'awaiting-consent'
14
+ /** Nothing in progress; no fetch has run yet. */
15
+ | 'idle'
16
+ /** A fetch is currently in flight. */
17
+ | 'fetching'
18
+ /** The last fetch (or cache load) succeeded and models are registered. */
19
+ | 'ready'
20
+ /** The last fetch failed. */
21
+ | 'error'
22
+ /** The model list is configured manually, so the provider is not asked what it offers. */
23
+ | 'overridden';
24
+ /** Where a provider's effective API key comes from. Used to gate env-var keys behind a one-time consent. */
25
+ export type ApiKeySource = 'preference' | 'environment' | 'none';
26
+ /**
27
+ * A model a provider reported from its list endpoint.
28
+ *
29
+ * Only {@link id} is guaranteed: the endpoints differ widely in what they report about a model.
30
+ * Anthropic gives a display name and a release date, Google additionally a description, and
31
+ * OpenAI nothing but the id.
32
+ */
33
+ export interface DiscoveredModel {
34
+ /** Provider-native model id, without the `<provider>/` prefix. */
35
+ readonly id: string;
36
+ /** Human-readable name reported by the provider, e.g. `Claude Opus 5`. */
37
+ readonly label?: string;
38
+ /** Longer description reported by the provider. */
39
+ readonly description?: string;
40
+ /** Release date (ms since epoch) reported by the provider, used to order dated variants. */
41
+ readonly released?: number;
42
+ /**
43
+ * Set by a provider that knows better than the generic ranking which of its models should be
44
+ * offered in the model pickers without the user asking. GitHub Copilot serves several vendors, so
45
+ * "the five newest" would offer five models of whichever vendor names its models with the highest
46
+ * numbers; it therefore nominates one per vendor itself. Left unset by the other providers.
47
+ */
48
+ readonly featured?: boolean;
49
+ }
50
+ /**
51
+ * Result of a provider model-discovery attempt.
52
+ *
53
+ * On a successful live fetch, `fromCache` is `false`. When the live fetch fails but a cached
54
+ * snapshot is available, the cached models are returned with `fromCache: true` and `error` set to
55
+ * the failure reason, so the UI can keep the models usable while indicating they may be stale.
56
+ */
57
+ export interface ModelDiscoveryResult {
58
+ /** The discovered models, in the order they should be registered. */
59
+ readonly models: DiscoveredModel[];
60
+ /** Whether the models came from the cached snapshot because the live fetch failed. */
61
+ readonly fromCache: boolean;
62
+ /** Failure reason when the live fetch failed (even if a cached result was returned). */
63
+ readonly error?: string;
64
+ }
65
+ /**
66
+ * What to do about a discovery state, offered as a button next to the explanation.
67
+ *
68
+ * Most providers need none: what a missing credential wants is the API key setting, which sits on the
69
+ * same page right above. A provider whose credential is established by a command rather than a
70
+ * preference — GitHub Copilot signs in through its CLI — names that command here.
71
+ */
72
+ export interface ModelDiscoveryAction {
73
+ /** Button label, already localized. */
74
+ readonly label: string;
75
+ readonly commandId: string;
76
+ readonly args?: unknown[];
77
+ }
78
+ /**
79
+ * Snapshot of a provider's model-discovery state, as observed on the frontend.
80
+ */
81
+ export interface ModelDiscoveryStatus {
82
+ /** Provider id, e.g. `anthropic`. Matches the provider node in the Models configuration category. */
83
+ readonly providerId: string;
84
+ /** Human-readable provider label, e.g. `Anthropic`. */
85
+ readonly label: string;
86
+ /**
87
+ * Prefix used for this provider's registered model ids (e.g. `openai` while the provider id is
88
+ * `openAiOfficial`). Defaults to {@link providerId} when omitted.
89
+ */
90
+ readonly modelIdPrefix?: string;
91
+ readonly state: ModelDiscoveryState;
92
+ /**
93
+ * Overrides the badge label the state would otherwise carry, for a provider the generic wording
94
+ * does not fit: what GitHub Copilot lacks when it has no credential is a sign-in, not an API key.
95
+ */
96
+ readonly stateLabel?: string;
97
+ /** Optional human-readable detail (error message, hint). */
98
+ readonly message?: string;
99
+ /** Timestamp (ms since epoch) of the last successful fetch, if any. */
100
+ readonly lastFetch?: number;
101
+ /** Whether the currently registered models came from a cached snapshot rather than a live fetch. */
102
+ readonly fromCache?: boolean;
103
+ /**
104
+ * What the provider reported about the models it discovered, keyed by id in
105
+ * {@link DiscoveredModel.id}. The registry stays the source of truth for which models are
106
+ * registered; this only carries the extra metadata (label, description) for display.
107
+ */
108
+ readonly discovered?: readonly DiscoveredModel[];
109
+ /** What the user can do about the current state, where a command settles it. */
110
+ readonly action?: ModelDiscoveryAction;
111
+ }
112
+ //# sourceMappingURL=model-discovery-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-discovery-status.d.ts","sourceRoot":"","sources":["../../src/common/model-discovery-status.ts"],"names":[],"mappings":"AAgBA;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB;AAC3B,+EAA+E;AAC7E,gBAAgB;AAClB,6FAA6F;GAC3F,kBAAkB;AACpB,iDAAiD;GAC/C,MAAM;AACR,sCAAsC;GACpC,UAAU;AACZ,0EAA0E;GACxE,OAAO;AACT,6BAA6B;GAC3B,OAAO;AACT,0FAA0F;GACxF,YAAY,CAAC;AAEnB,4GAA4G;AAC5G,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,aAAa,GAAG,MAAM,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,mDAAmD;IACnD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACjC,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC;IACnC,sFAAsF;IACtF,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,wFAAwF;IACxF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACjC,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,qGAAqG;IACrG,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,uEAAuE;IACvE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,oGAAoG;IACpG,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IACjD,gFAAgF;IAChF,QAAQ,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC1C"}
@@ -0,0 +1,18 @@
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
+ //# sourceMappingURL=model-discovery-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-discovery-status.js","sourceRoot":"","sources":["../../src/common/model-discovery-status.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"}
@@ -0,0 +1,46 @@
1
+ import { DiscoveredModel } from './model-discovery-status';
2
+ /**
3
+ * Helpers for the dated model ids that provider list endpoints report. Providers call these from
4
+ * an overridable method of their language-models manager, so a provider (or an adopter) can opt
5
+ * out or refine the behaviour without reimplementing it.
6
+ */
7
+ export declare namespace DiscoveredModels {
8
+ /**
9
+ * The undated form of a release-pinned model id, e.g. `claude-opus-5-20260401` → `claude-opus-5`.
10
+ * Returns `undefined` when the id carries no date suffix.
11
+ */
12
+ function undatedId(id: string): string | undefined;
13
+ /**
14
+ * Adds the undated alias for every release-pinned model, keeping the pinned releases themselves.
15
+ *
16
+ * Providers such as Anthropic and OpenAI list one entry per release (`claude-opus-5-20260401`,
17
+ * `claude-opus-5-20251120`, …) while accepting the undated form (`claude-opus-5`) as a
18
+ * request-time alias for the newest of them. The undated id is what the built-in model aliases
19
+ * reference and what does not change from under a configuration when a new release ships, so it
20
+ * is registered even when the provider does not list it. The pinned releases stay registered too,
21
+ * so a specific release can be selected; what keeps them out of the way of the model pickers is
22
+ * that only undated ids are featured (see the favorite models service), not that they are hidden.
23
+ *
24
+ * The alias takes the metadata of the most recent variant. Aliases come first; the reported models
25
+ * keep their relative order after them. An alias the provider reported itself is left untouched.
26
+ */
27
+ function withUndatedAliases(models: DiscoveredModel[]): DiscoveredModel[];
28
+ /**
29
+ * Whether the id is a pointer a provider maintains at the current model of a family, e.g.
30
+ * `gemini-flash-latest`. Such an id carries no version to compare, and does not need one: it
31
+ * resolves to whatever is newest by definition.
32
+ */
33
+ function isLatestPointer(id: string): boolean;
34
+ /**
35
+ * The version numbers in a model id, e.g. `gemini-3.7-flash` → `[3, 7]` and `claude-sonnet-4-5`
36
+ * → `[4, 5]`. A heuristic, and only meaningful between the models of one provider — and one
37
+ * vendor at that: it says nothing about `gpt-5` against `claude-sonnet-4.5`.
38
+ */
39
+ function versionOf(id: string): number[];
40
+ /**
41
+ * Compares two model ids by the version numbers in them, most recent first. A longer sequence wins
42
+ * a shared prefix, so `gemini-3.7` sorts before `gemini-3`.
43
+ */
44
+ function compareByVersion(left: string, right: string): number;
45
+ }
46
+ //# sourceMappingURL=model-discovery-util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-discovery-util.d.ts","sourceRoot":"","sources":["../../src/common/model-discovery-util.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;;;GAIG;AACH,yBAAiB,gBAAgB,CAAC;IAU9B;;;OAGG;IACH,SAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGxD;IAED;;;;;;;;;;;;;OAaG;IACH,SAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,eAAe,EAAE,CAc/E;IAED;;;;OAIG;IACH,SAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEnD;IAED;;;;OAIG;IACH,SAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAE9C;IAED;;;OAGG;IACH,SAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAUpE;CAwBJ"}
@@ -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,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AAC,QAAQ,CAAC;QACjD,CAAC;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,yFAAyF;IACzF,SAAS,MAAM,CAAC,EAAU;QACtB,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,OAAO,CAAC,CAAC;QACb,CAAC;QACD,gFAAgF;QAChF,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACrG,CAAC;AACL,CAAC,EAzGgB,gBAAgB,gCAAhB,gBAAgB,QAyGhC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=model-discovery-util.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":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,GAAG,EAAE;IAExC,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACvD,IAAA,aAAM,EAAC,uCAAgB,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACnD,IAAA,aAAM,EAAC,uCAAgB,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACtE,IAAA,aAAM,EAAC,uCAAgB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H,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,sCAKqB;AACrB,4GAEoE;AACpE,sCAcmB;AACnB,uFAAqF;AACrF,yEAAmE;AACnE,mEAA4E;AAC5E,uEAAsE;AAEtE,iFAAiF;AACjF,MAAM,sBAAsB,GAAG,uDAAyB,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,EAAE,EAAE;IAClH,IAAA,+BAAwB,EAAC,IAAI,EAAE,8BAAqB,CAAC,CAAC;IACtD,IAAI,CAAC,kEAAgC,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACnE,IAAI,CAAC,8BAAqB,CAAC,CAAC,SAAS,CAAC,kEAAgC,CAAC,CAAC;IAExE,IAAI,CAAC,0BAAiB,C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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;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,4DAA+D;AAC/D,yFAG4C;AAC5C,sCAKqB;AACrB,4GAEoE;AACpE,sCAcmB;AACnB,uFAAqF;AACrF,yEAAmE;AACnE,iEAAoF;AACpF,uEAA6F;AAC7F,mEAA4E;AAC5E,uEAAsE;AAEtE,iFAAiF;AACjF,MAAM,sBAAsB,GAAG,uDAAyB,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,EAAE,EAAE;IAClH,IAAA,+BAAwB,EAAC,IAAI,EAAE,8BAAqB,CAAC,CAAC;IACtD,IAAI,CAAC,kEAAgC,CAAC,CAAC,MAAM,EAAE,CA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AE;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,4FAA4F;IAC5F,uFAAuF;IACvF,IAAI,CAAC,6CAAsB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACzD,IAAI,CAAC,yCAAkB,CAAC,CAAC,SAAS,CAAC,6CAAsB,CAAC,CAAC;IAC3D,IAAI,CAAC,mDAAyB,CAAC,CAAC,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,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,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;IA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C,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,YA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