@jupyterlite/ai 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/lib/chat-commands/clear.d.ts +1 -0
  2. package/lib/chat-commands/index.d.ts +1 -0
  3. package/lib/chat-commands/skills.d.ts +2 -1
  4. package/lib/chat-model-handler.d.ts +4 -3
  5. package/lib/chat-model-handler.js +2 -1
  6. package/lib/chat-model.d.ts +148 -8
  7. package/lib/chat-model.js +368 -79
  8. package/lib/completion/completion-provider.d.ts +3 -1
  9. package/lib/completion/completion-provider.js +1 -2
  10. package/lib/completion/index.d.ts +1 -0
  11. package/lib/components/clear-button.d.ts +1 -0
  12. package/lib/components/clear-button.js +3 -4
  13. package/lib/components/completion-status.d.ts +1 -0
  14. package/lib/components/completion-status.js +5 -4
  15. package/lib/components/index.d.ts +1 -0
  16. package/lib/components/model-select.d.ts +1 -0
  17. package/lib/components/model-select.js +62 -67
  18. package/lib/components/save-button.d.ts +3 -2
  19. package/lib/components/save-button.js +4 -5
  20. package/lib/components/stop-button.d.ts +1 -0
  21. package/lib/components/stop-button.js +3 -4
  22. package/lib/components/tool-select.d.ts +3 -1
  23. package/lib/components/tool-select.js +47 -60
  24. package/lib/components/usage-display.d.ts +4 -2
  25. package/lib/components/usage-display.js +50 -61
  26. package/lib/diff-manager.d.ts +3 -1
  27. package/lib/index.d.ts +3 -2
  28. package/lib/index.js +50 -59
  29. package/lib/models/settings-model.d.ts +3 -1
  30. package/lib/models/settings-model.js +1 -0
  31. package/lib/rendered-message-outputarea.d.ts +1 -0
  32. package/lib/tokens.d.ts +48 -597
  33. package/lib/tokens.js +2 -31
  34. package/lib/widgets/ai-settings.d.ts +3 -1
  35. package/lib/widgets/ai-settings.js +185 -344
  36. package/lib/widgets/main-area-chat.d.ts +3 -3
  37. package/lib/widgets/main-area-chat.js +2 -4
  38. package/lib/widgets/provider-config-dialog.d.ts +2 -1
  39. package/lib/widgets/provider-config-dialog.js +102 -167
  40. package/package.json +111 -258
  41. package/schema/settings-model.json +6 -0
  42. package/src/chat-commands/skills.ts +2 -2
  43. package/src/chat-model-handler.ts +10 -6
  44. package/src/chat-model.ts +488 -96
  45. package/src/completion/completion-provider.ts +6 -6
  46. package/src/components/clear-button.tsx +0 -2
  47. package/src/components/completion-status.tsx +2 -2
  48. package/src/components/model-select.tsx +1 -1
  49. package/src/components/save-button.tsx +3 -3
  50. package/src/components/stop-button.tsx +0 -2
  51. package/src/components/tool-select.tsx +10 -9
  52. package/src/components/usage-display.tsx +4 -2
  53. package/src/diff-manager.ts +4 -3
  54. package/src/index.ts +103 -107
  55. package/src/models/settings-model.ts +7 -6
  56. package/src/tokens.ts +54 -744
  57. package/src/widgets/ai-settings.tsx +40 -11
  58. package/src/widgets/main-area-chat.ts +5 -8
  59. package/src/widgets/provider-config-dialog.tsx +8 -8
  60. package/LICENSE +0 -30
  61. package/README.md +0 -49
  62. package/lib/agent.d.ts +0 -277
  63. package/lib/agent.js +0 -1116
  64. package/lib/icons.d.ts +0 -3
  65. package/lib/icons.js +0 -8
  66. package/lib/providers/built-in-providers.d.ts +0 -21
  67. package/lib/providers/built-in-providers.js +0 -233
  68. package/lib/providers/generated-context-windows.d.ts +0 -8
  69. package/lib/providers/generated-context-windows.js +0 -96
  70. package/lib/providers/model-info.d.ts +0 -3
  71. package/lib/providers/model-info.js +0 -58
  72. package/lib/providers/models.d.ts +0 -37
  73. package/lib/providers/models.js +0 -28
  74. package/lib/providers/provider-registry.d.ts +0 -49
  75. package/lib/providers/provider-registry.js +0 -72
  76. package/lib/providers/provider-tools.d.ts +0 -36
  77. package/lib/providers/provider-tools.js +0 -93
  78. package/lib/skills/index.d.ts +0 -4
  79. package/lib/skills/index.js +0 -7
  80. package/lib/skills/parse-skill.d.ts +0 -25
  81. package/lib/skills/parse-skill.js +0 -69
  82. package/lib/skills/skill-loader.d.ts +0 -25
  83. package/lib/skills/skill-loader.js +0 -133
  84. package/lib/skills/skill-registry.d.ts +0 -31
  85. package/lib/skills/skill-registry.js +0 -100
  86. package/lib/skills/types.d.ts +0 -29
  87. package/lib/skills/types.js +0 -5
  88. package/lib/tools/commands.d.ts +0 -11
  89. package/lib/tools/commands.js +0 -154
  90. package/lib/tools/skills.d.ts +0 -9
  91. package/lib/tools/skills.js +0 -73
  92. package/lib/tools/tool-registry.d.ts +0 -35
  93. package/lib/tools/tool-registry.js +0 -55
  94. package/lib/tools/web.d.ts +0 -8
  95. package/lib/tools/web.js +0 -196
  96. package/src/agent.ts +0 -1441
  97. package/src/icons.ts +0 -11
  98. package/src/providers/built-in-providers.ts +0 -241
  99. package/src/providers/generated-context-windows.ts +0 -102
  100. package/src/providers/model-info.ts +0 -88
  101. package/src/providers/models.ts +0 -76
  102. package/src/providers/provider-registry.ts +0 -88
  103. package/src/providers/provider-tools.ts +0 -179
  104. package/src/skills/index.ts +0 -14
  105. package/src/skills/parse-skill.ts +0 -91
  106. package/src/skills/skill-loader.ts +0 -175
  107. package/src/skills/skill-registry.ts +0 -137
  108. package/src/skills/types.ts +0 -37
  109. package/src/tools/commands.ts +0 -210
  110. package/src/tools/skills.ts +0 -84
  111. package/src/tools/tool-registry.ts +0 -63
  112. package/src/tools/web.ts +0 -238
  113. package/src/types.d.ts +0 -4
  114. package/style/icons/jupyternaut-lite.svg +0 -7
package/lib/icons.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { LabIcon } from '@jupyterlab/ui-components';
2
- export declare const jupyternautIcon: LabIcon;
3
- export declare const AI_AVATAR: string;
package/lib/icons.js DELETED
@@ -1,8 +0,0 @@
1
- import { LabIcon } from '@jupyterlab/ui-components';
2
- import jupyternautSvg from '../style/icons/jupyternaut-lite.svg';
3
- export const jupyternautIcon = new LabIcon({
4
- name: '@jupyterlite/ai:jupyternaut',
5
- svgstr: jupyternautSvg
6
- });
7
- const AI_AVATAR_BASE64 = btoa(jupyternautIcon.svgstr);
8
- export const AI_AVATAR = `data:image/svg+xml;base64,${AI_AVATAR_BASE64}`;
@@ -1,21 +0,0 @@
1
- import type { IProviderInfo } from '../tokens';
2
- /**
3
- * Anthropic provider
4
- */
5
- export declare const anthropicProvider: IProviderInfo;
6
- /**
7
- * Google Generative AI provider
8
- */
9
- export declare const googleProvider: IProviderInfo;
10
- /**
11
- * Mistral provider
12
- */
13
- export declare const mistralProvider: IProviderInfo;
14
- /**
15
- * OpenAI provider
16
- */
17
- export declare const openaiProvider: IProviderInfo;
18
- /**
19
- * Generic OpenAI-compatible provider
20
- */
21
- export declare const genericProvider: IProviderInfo;
@@ -1,233 +0,0 @@
1
- import { createAnthropic } from '@ai-sdk/anthropic';
2
- import { createGoogleGenerativeAI } from '@ai-sdk/google';
3
- import { createMistral } from '@ai-sdk/mistral';
4
- import { createOpenAI } from '@ai-sdk/openai';
5
- import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
6
- import { BUILT_IN_PROVIDER_MODEL_INFO } from './generated-context-windows';
7
- /**
8
- * Anthropic provider
9
- */
10
- export const anthropicProvider = {
11
- id: 'anthropic',
12
- name: 'Anthropic Claude',
13
- apiKeyRequirement: 'required',
14
- defaultModels: [
15
- 'claude-opus-4-6',
16
- 'claude-sonnet-4-6',
17
- 'claude-opus-4-5',
18
- 'claude-opus-4-5-20251101',
19
- 'claude-sonnet-4-5',
20
- 'claude-sonnet-4-5-20250929',
21
- 'claude-haiku-4-5',
22
- 'claude-haiku-4-5-20251001',
23
- 'claude-opus-4-1',
24
- 'claude-opus-4-1-20250805',
25
- 'claude-opus-4-0',
26
- 'claude-opus-4-20250514',
27
- 'claude-sonnet-4-0',
28
- 'claude-sonnet-4-20250514'
29
- ],
30
- modelInfo: BUILT_IN_PROVIDER_MODEL_INFO.anthropic,
31
- supportsBaseURL: true,
32
- supportsHeaders: true,
33
- providerToolCapabilities: {
34
- webSearch: { implementation: 'anthropic' },
35
- webFetch: { implementation: 'anthropic' }
36
- },
37
- factory: (options) => {
38
- if (!options.apiKey) {
39
- throw new Error('API key required for Anthropic');
40
- }
41
- const anthropic = createAnthropic({
42
- apiKey: options.apiKey,
43
- headers: {
44
- 'anthropic-dangerous-direct-browser-access': 'true',
45
- ...options.headers
46
- },
47
- ...(options.baseURL && { baseURL: options.baseURL })
48
- });
49
- const modelName = options.model ?? '';
50
- return anthropic(modelName);
51
- }
52
- };
53
- /**
54
- * Google Generative AI provider
55
- */
56
- export const googleProvider = {
57
- id: 'google',
58
- name: 'Google Generative AI',
59
- apiKeyRequirement: 'required',
60
- defaultModels: [
61
- 'gemini-3.1-pro-preview',
62
- 'gemini-3.1-pro-preview-customtools',
63
- 'gemini-3.1-flash-image-preview',
64
- 'gemini-3.1-flash-lite-preview',
65
- 'gemini-3-pro-image-preview',
66
- 'gemini-3-flash-preview',
67
- 'gemini-2.5-pro',
68
- 'gemini-2.5-flash',
69
- 'gemini-2.5-flash-image',
70
- 'gemini-2.5-flash-lite',
71
- 'gemini-2.5-computer-use-preview-10-2025',
72
- 'deep-research-pro-preview-12-2025',
73
- 'gemini-pro-latest',
74
- 'gemini-flash-latest',
75
- 'gemini-flash-lite-latest'
76
- ],
77
- modelInfo: BUILT_IN_PROVIDER_MODEL_INFO.google,
78
- supportsBaseURL: true,
79
- factory: (options) => {
80
- if (!options.apiKey) {
81
- throw new Error('API key required for Google Generative AI');
82
- }
83
- const google = createGoogleGenerativeAI({
84
- apiKey: options.apiKey,
85
- ...(options.baseURL && { baseURL: options.baseURL })
86
- });
87
- const modelName = options.model || 'gemini-2.5-flash';
88
- return google(modelName);
89
- }
90
- };
91
- /**
92
- * Mistral provider
93
- */
94
- export const mistralProvider = {
95
- id: 'mistral',
96
- name: 'Mistral AI',
97
- apiKeyRequirement: 'required',
98
- defaultModels: [
99
- 'mistral-large-latest',
100
- 'mistral-medium-latest',
101
- 'mistral-medium-2508',
102
- 'mistral-small-latest',
103
- 'mistral-small-2506',
104
- 'ministral-3b-latest',
105
- 'ministral-8b-latest',
106
- 'ministral-14b-latest',
107
- 'magistral-small-latest',
108
- 'magistral-medium-latest',
109
- 'pixtral-large-latest',
110
- 'codestral-latest',
111
- 'devstral-latest'
112
- ],
113
- modelInfo: BUILT_IN_PROVIDER_MODEL_INFO.mistral,
114
- supportsBaseURL: true,
115
- factory: (options) => {
116
- if (!options.apiKey) {
117
- throw new Error('API key required for Mistral');
118
- }
119
- const mistral = createMistral({
120
- apiKey: options.apiKey,
121
- ...(options.baseURL && { baseURL: options.baseURL })
122
- });
123
- const modelName = options.model || 'mistral-large-latest';
124
- return mistral(modelName);
125
- }
126
- };
127
- /**
128
- * OpenAI provider
129
- */
130
- export const openaiProvider = {
131
- id: 'openai',
132
- name: 'OpenAI',
133
- apiKeyRequirement: 'required',
134
- defaultModels: [
135
- 'gpt-5.4',
136
- 'gpt-5.4-mini',
137
- 'gpt-5.4-nano',
138
- 'gpt-5.2',
139
- 'gpt-5.2-2025-12-11',
140
- 'gpt-5.2-chat-latest',
141
- 'gpt-5.2-pro',
142
- 'gpt-5.2-pro-2025-12-11',
143
- 'gpt-5.2-codex',
144
- 'gpt-5.1',
145
- 'gpt-5.1-2025-11-13',
146
- 'gpt-5.1-chat-latest',
147
- 'gpt-5',
148
- 'gpt-5-2025-08-07',
149
- 'gpt-5-chat-latest',
150
- 'gpt-5-mini',
151
- 'gpt-5-mini-2025-08-07',
152
- 'gpt-5-nano',
153
- 'gpt-5-nano-2025-08-07',
154
- 'o4-mini',
155
- 'o4-mini-2025-04-16',
156
- 'o3-pro',
157
- 'o3',
158
- 'o3-2025-04-16',
159
- 'o3-mini',
160
- 'o3-mini-2025-01-31',
161
- 'o1',
162
- 'o1-2024-12-17',
163
- 'gpt-4.1',
164
- 'gpt-4.1-2025-04-14',
165
- 'gpt-4.1-mini',
166
- 'gpt-4.1-mini-2025-04-14',
167
- 'gpt-4.1-nano',
168
- 'gpt-4.1-nano-2025-04-14',
169
- 'gpt-4o',
170
- 'gpt-4o-2024-05-13',
171
- 'gpt-4o-2024-08-06',
172
- 'gpt-4o-2024-11-20',
173
- 'gpt-4o-mini',
174
- 'gpt-4o-mini-2024-07-18',
175
- 'gpt-4o-search-preview',
176
- 'gpt-4o-search-preview-2025-03-11',
177
- 'gpt-4o-mini-search-preview',
178
- 'gpt-4o-mini-search-preview-2025-03-11',
179
- 'gpt-3.5-turbo',
180
- 'gpt-3.5-turbo-0125'
181
- ],
182
- modelInfo: BUILT_IN_PROVIDER_MODEL_INFO.openai,
183
- supportsBaseURL: true,
184
- supportsHeaders: true,
185
- providerToolCapabilities: {
186
- webSearch: { implementation: 'openai' }
187
- },
188
- factory: (options) => {
189
- if (!options.apiKey) {
190
- throw new Error('API key required for OpenAI');
191
- }
192
- const openai = createOpenAI({
193
- apiKey: options.apiKey,
194
- ...(options.baseURL && { baseURL: options.baseURL }),
195
- ...(options.headers && { headers: options.headers })
196
- });
197
- const modelName = options.model || 'gpt-4o';
198
- return openai(modelName);
199
- }
200
- };
201
- /**
202
- * Generic OpenAI-compatible provider
203
- */
204
- export const genericProvider = {
205
- id: 'generic',
206
- name: 'Generic (OpenAI-compatible)',
207
- apiKeyRequirement: 'optional',
208
- defaultModels: [],
209
- supportsBaseURL: true,
210
- supportsHeaders: true,
211
- supportsToolCalling: true,
212
- description: 'Uses /chat/completions endpoint',
213
- baseUrls: [
214
- {
215
- url: 'http://localhost:4000',
216
- description: 'Default for local LiteLLM server'
217
- },
218
- {
219
- url: 'http://localhost:11434/v1',
220
- description: 'Default for local Ollama server'
221
- }
222
- ],
223
- factory: (options) => {
224
- const openaiCompatible = createOpenAICompatible({
225
- name: options.provider,
226
- apiKey: options.apiKey || 'dummy',
227
- baseURL: options.baseURL ?? '',
228
- ...(options.headers && { headers: options.headers })
229
- });
230
- const modelName = options.model || 'gpt-4o';
231
- return openaiCompatible(modelName);
232
- }
233
- };
@@ -1,8 +0,0 @@
1
- /**
2
- * This file is generated by `jlpm sync:model-context-windows`.
3
- * Source: https://models.dev/api.json
4
- * Backed by: https://github.com/anomalyco/models.dev
5
- * Generated: 2026-04-08T16:23:34.080Z
6
- */
7
- import type { IProviderModelInfo } from '../tokens';
8
- export declare const BUILT_IN_PROVIDER_MODEL_INFO: Record<string, Record<string, IProviderModelInfo>>;
@@ -1,96 +0,0 @@
1
- /**
2
- * This file is generated by `jlpm sync:model-context-windows`.
3
- * Source: https://models.dev/api.json
4
- * Backed by: https://github.com/anomalyco/models.dev
5
- * Generated: 2026-04-08T16:23:34.080Z
6
- */
7
- export const BUILT_IN_PROVIDER_MODEL_INFO = {
8
- anthropic: {
9
- 'claude-opus-4-6': { contextWindow: 1000000 },
10
- 'claude-sonnet-4-6': { contextWindow: 1000000 },
11
- 'claude-opus-4-5': { contextWindow: 200000 },
12
- 'claude-opus-4-5-20251101': { contextWindow: 200000 },
13
- 'claude-sonnet-4-5': { contextWindow: 200000 },
14
- 'claude-sonnet-4-5-20250929': { contextWindow: 200000 },
15
- 'claude-haiku-4-5': { contextWindow: 200000 },
16
- 'claude-haiku-4-5-20251001': { contextWindow: 200000 },
17
- 'claude-opus-4-1': { contextWindow: 200000 },
18
- 'claude-opus-4-1-20250805': { contextWindow: 200000 },
19
- 'claude-opus-4-0': { contextWindow: 200000 },
20
- 'claude-opus-4-20250514': { contextWindow: 200000 },
21
- 'claude-sonnet-4-0': { contextWindow: 200000 },
22
- 'claude-sonnet-4-20250514': { contextWindow: 200000 }
23
- },
24
- google: {
25
- 'gemini-3.1-pro-preview': { contextWindow: 1048576 },
26
- 'gemini-3.1-pro-preview-customtools': { contextWindow: 1048576 },
27
- 'gemini-3.1-flash-image-preview': { contextWindow: 131072 },
28
- 'gemini-3.1-flash-lite-preview': { contextWindow: 1048576 },
29
- 'gemini-3-flash-preview': { contextWindow: 1048576 },
30
- 'gemini-2.5-pro': { contextWindow: 1048576 },
31
- 'gemini-2.5-flash': { contextWindow: 1048576 },
32
- 'gemini-2.5-flash-image': { contextWindow: 32768 },
33
- 'gemini-2.5-flash-lite': { contextWindow: 1048576 },
34
- 'gemini-flash-latest': { contextWindow: 1048576 },
35
- 'gemini-flash-lite-latest': { contextWindow: 1048576 }
36
- },
37
- mistral: {
38
- 'mistral-large-latest': { contextWindow: 262144 },
39
- 'mistral-medium-latest': { contextWindow: 128000 },
40
- 'mistral-medium-2508': { contextWindow: 262144 },
41
- 'mistral-small-latest': { contextWindow: 256000 },
42
- 'mistral-small-2506': { contextWindow: 128000 },
43
- 'ministral-3b-latest': { contextWindow: 128000 },
44
- 'ministral-8b-latest': { contextWindow: 128000 },
45
- 'magistral-small-latest': { contextWindow: 128000 },
46
- 'magistral-medium-latest': { contextWindow: 128000 },
47
- 'pixtral-large-latest': { contextWindow: 128000 },
48
- 'codestral-latest': { contextWindow: 256000 },
49
- 'devstral-latest': { contextWindow: 262144 },
50
- 'devstral-2512': { contextWindow: 262144 }
51
- },
52
- openai: {
53
- 'gpt-5.4': { contextWindow: 1050000 },
54
- 'gpt-5.4-mini': { contextWindow: 400000 },
55
- 'gpt-5.4-nano': { contextWindow: 400000 },
56
- 'gpt-5.2': { contextWindow: 400000 },
57
- 'gpt-5.2-2025-12-11': { contextWindow: 400000 },
58
- 'gpt-5.2-chat-latest': { contextWindow: 128000 },
59
- 'gpt-5.2-pro': { contextWindow: 400000 },
60
- 'gpt-5.2-pro-2025-12-11': { contextWindow: 400000 },
61
- 'gpt-5.2-codex': { contextWindow: 400000 },
62
- 'gpt-5.1': { contextWindow: 400000 },
63
- 'gpt-5.1-2025-11-13': { contextWindow: 400000 },
64
- 'gpt-5.1-chat-latest': { contextWindow: 128000 },
65
- 'gpt-5': { contextWindow: 400000 },
66
- 'gpt-5-2025-08-07': { contextWindow: 400000 },
67
- 'gpt-5-chat-latest': { contextWindow: 400000 },
68
- 'gpt-5-mini': { contextWindow: 400000 },
69
- 'gpt-5-mini-2025-08-07': { contextWindow: 400000 },
70
- 'gpt-5-nano': { contextWindow: 400000 },
71
- 'gpt-5-nano-2025-08-07': { contextWindow: 400000 },
72
- 'o4-mini': { contextWindow: 200000 },
73
- 'o4-mini-2025-04-16': { contextWindow: 200000 },
74
- 'o3-pro': { contextWindow: 200000 },
75
- o3: { contextWindow: 200000 },
76
- 'o3-2025-04-16': { contextWindow: 200000 },
77
- 'o3-mini': { contextWindow: 200000 },
78
- 'o3-mini-2025-01-31': { contextWindow: 200000 },
79
- o1: { contextWindow: 200000 },
80
- 'o1-2024-12-17': { contextWindow: 200000 },
81
- 'gpt-4.1': { contextWindow: 1047576 },
82
- 'gpt-4.1-2025-04-14': { contextWindow: 1047576 },
83
- 'gpt-4.1-mini': { contextWindow: 1047576 },
84
- 'gpt-4.1-mini-2025-04-14': { contextWindow: 1047576 },
85
- 'gpt-4.1-nano': { contextWindow: 1047576 },
86
- 'gpt-4.1-nano-2025-04-14': { contextWindow: 1047576 },
87
- 'gpt-4o': { contextWindow: 128000 },
88
- 'gpt-4o-2024-05-13': { contextWindow: 128000 },
89
- 'gpt-4o-2024-08-06': { contextWindow: 128000 },
90
- 'gpt-4o-2024-11-20': { contextWindow: 128000 },
91
- 'gpt-4o-mini': { contextWindow: 128000 },
92
- 'gpt-4o-mini-2024-07-18': { contextWindow: 128000 },
93
- 'gpt-3.5-turbo': { contextWindow: 16385 },
94
- 'gpt-3.5-turbo-0125': { contextWindow: 16385 }
95
- }
96
- };
@@ -1,3 +0,0 @@
1
- import type { IProviderConfig, IProviderInfo, IProviderModelInfo, IProviderRegistry } from '../tokens';
2
- export declare function getProviderModelInfo(providerInfo: IProviderInfo | null | undefined, model: string | undefined): IProviderModelInfo | undefined;
3
- export declare function getEffectiveContextWindow(providerConfig: IProviderConfig | undefined, providerRegistry?: IProviderRegistry): number | undefined;
@@ -1,58 +0,0 @@
1
- const DATE_SUFFIX = /^(.*)-\d{4}-\d{2}-\d{2}$/;
2
- const SHORT_VERSION_SUFFIX = /^(.*)-\d{4}$/;
3
- // Treat rolling aliases and dated releases as the same model family so they
4
- // can share provider metadata such as context windows.
5
- function normalizeModelId(modelId) {
6
- if (modelId.endsWith('-latest')) {
7
- return modelId.slice(0, -7);
8
- }
9
- const dateSuffixMatch = modelId.match(DATE_SUFFIX);
10
- if (dateSuffixMatch) {
11
- return dateSuffixMatch[1];
12
- }
13
- const shortVersionSuffixMatch = modelId.match(SHORT_VERSION_SUFFIX);
14
- if (shortVersionSuffixMatch) {
15
- return shortVersionSuffixMatch[1];
16
- }
17
- return modelId;
18
- }
19
- function getCandidateModelIds(modelId) {
20
- const candidates = [modelId];
21
- const normalizedModelId = normalizeModelId(modelId);
22
- candidates.push(normalizedModelId);
23
- if (normalizedModelId !== modelId) {
24
- candidates.push(`${normalizedModelId}-latest`);
25
- }
26
- return [...new Set(candidates)];
27
- }
28
- export function getProviderModelInfo(providerInfo, model) {
29
- if (!providerInfo || !model) {
30
- return undefined;
31
- }
32
- const modelInfo = providerInfo.modelInfo;
33
- if (!modelInfo) {
34
- return undefined;
35
- }
36
- for (const candidateId of getCandidateModelIds(model)) {
37
- if (modelInfo[candidateId]) {
38
- return modelInfo[candidateId];
39
- }
40
- }
41
- const normalizedModelId = normalizeModelId(model);
42
- // As a last resort, match any known model entry that normalizes to the same
43
- // base ID, even if the exact alias/version string differs.
44
- return Object.entries(modelInfo).find(([candidateId]) => {
45
- return normalizeModelId(candidateId) === normalizedModelId;
46
- })?.[1];
47
- }
48
- export function getEffectiveContextWindow(providerConfig, providerRegistry) {
49
- if (!providerConfig) {
50
- return undefined;
51
- }
52
- if (providerConfig.parameters?.contextWindow !== undefined) {
53
- return providerConfig.parameters.contextWindow;
54
- }
55
- const providerInfo = providerRegistry?.getProviderInfo(providerConfig.provider);
56
- return getProviderModelInfo(providerInfo, providerConfig.model)
57
- ?.contextWindow;
58
- }
@@ -1,37 +0,0 @@
1
- import type { LanguageModel } from 'ai';
2
- import type { IProviderRegistry } from '../tokens';
3
- /**
4
- * Configuration options for creating language models.
5
- */
6
- export interface IModelOptions {
7
- /**
8
- * The provider name (e.g., 'openai', 'anthropic', 'huggingface')
9
- */
10
- provider: string;
11
- /**
12
- * The specific model name. If not provided, uses provider's default model
13
- */
14
- model?: string;
15
- /**
16
- * API key for authentication with the provider
17
- */
18
- apiKey?: string;
19
- /**
20
- * Additional HTTP headers to send with requests
21
- */
22
- headers?: Record<string, string>;
23
- /**
24
- * Custom base URL for the provider's API endpoint
25
- */
26
- baseURL?: string;
27
- }
28
- /**
29
- * Create a completion model using the provider registry.
30
- * Built-in providers are automatically registered during extension initialization.
31
- */
32
- export declare function createCompletionModel(options: IModelOptions, registry?: IProviderRegistry): LanguageModel;
33
- /**
34
- * Create a chat model using the provider registry.
35
- * Built-in providers are automatically registered during extension initialization.
36
- */
37
- export declare function createModel(options: IModelOptions, registry?: IProviderRegistry): LanguageModel;
@@ -1,28 +0,0 @@
1
- /**
2
- * Create a completion model using the provider registry.
3
- * Built-in providers are automatically registered during extension initialization.
4
- */
5
- export function createCompletionModel(options, registry) {
6
- if (!registry) {
7
- throw new Error('Provider registry not available');
8
- }
9
- const model = registry.createCompletionModel(options.provider, options);
10
- if (!model) {
11
- throw new Error(`Provider ${options.provider} not found or failed to create model`);
12
- }
13
- return model;
14
- }
15
- /**
16
- * Create a chat model using the provider registry.
17
- * Built-in providers are automatically registered during extension initialization.
18
- */
19
- export function createModel(options, registry) {
20
- if (!registry) {
21
- throw new Error('Provider registry not available');
22
- }
23
- const model = registry.createChatModel(options.provider, options);
24
- if (!model) {
25
- throw new Error(`Provider ${options.provider} not found or failed to create model`);
26
- }
27
- return model;
28
- }
@@ -1,49 +0,0 @@
1
- import { ISignal } from '@lumino/signaling';
2
- import type { LanguageModel } from 'ai';
3
- import type { IModelOptions } from './models';
4
- import { IProviderInfo, IProviderRegistry } from '../tokens';
5
- /**
6
- * Implementation of the provider registry
7
- */
8
- export declare class ProviderRegistry implements IProviderRegistry {
9
- /**
10
- * Get a copy of all registered providers
11
- */
12
- get providers(): Record<string, IProviderInfo>;
13
- /**
14
- * Signal emitted when providers are added or removed
15
- */
16
- get providersChanged(): ISignal<IProviderRegistry, void>;
17
- /**
18
- * Register a new provider
19
- * @param info Provider information with factories for chat and completion
20
- */
21
- registerProvider(info: IProviderInfo): void;
22
- /**
23
- * Get provider information by ID
24
- * @param id Provider ID
25
- * @returns Provider info or null if not found
26
- */
27
- getProviderInfo(id: string): IProviderInfo | null;
28
- /**
29
- * Create a chat model instance using the specified provider
30
- * @param id Provider ID
31
- * @param options Model configuration options
32
- * @returns Chat model instance or null if creation fails
33
- */
34
- createChatModel(id: string, options: IModelOptions): LanguageModel | null;
35
- /**
36
- * Create a completion model instance using the specified provider
37
- * @param id Provider ID
38
- * @param options Model configuration options
39
- * @returns Language model instance or null if creation fails
40
- */
41
- createCompletionModel(id: string, options: IModelOptions): LanguageModel | null;
42
- /**
43
- * Get list of all available provider IDs
44
- * @returns Array of provider IDs
45
- */
46
- getAvailableProviders(): string[];
47
- private _providers;
48
- private _providersChanged;
49
- }
@@ -1,72 +0,0 @@
1
- import { Signal } from '@lumino/signaling';
2
- /**
3
- * Implementation of the provider registry
4
- */
5
- export class ProviderRegistry {
6
- /**
7
- * Get a copy of all registered providers
8
- */
9
- get providers() {
10
- return { ...this._providers };
11
- }
12
- /**
13
- * Signal emitted when providers are added or removed
14
- */
15
- get providersChanged() {
16
- return this._providersChanged;
17
- }
18
- /**
19
- * Register a new provider
20
- * @param info Provider information with factories for chat and completion
21
- */
22
- registerProvider(info) {
23
- if (info.id in this._providers) {
24
- throw new Error(`Provider with id "${info.id}" is already registered`);
25
- }
26
- this._providers[info.id] = { ...info };
27
- this._providersChanged.emit();
28
- }
29
- /**
30
- * Get provider information by ID
31
- * @param id Provider ID
32
- * @returns Provider info or null if not found
33
- */
34
- getProviderInfo(id) {
35
- return this._providers[id] || null;
36
- }
37
- /**
38
- * Create a chat model instance using the specified provider
39
- * @param id Provider ID
40
- * @param options Model configuration options
41
- * @returns Chat model instance or null if creation fails
42
- */
43
- createChatModel(id, options) {
44
- const provider = this._providers[id];
45
- if (!provider) {
46
- return null;
47
- }
48
- return provider.factory(options);
49
- }
50
- /**
51
- * Create a completion model instance using the specified provider
52
- * @param id Provider ID
53
- * @param options Model configuration options
54
- * @returns Language model instance or null if creation fails
55
- */
56
- createCompletionModel(id, options) {
57
- const provider = this._providers[id];
58
- if (!provider) {
59
- return null;
60
- }
61
- return provider.factory(options);
62
- }
63
- /**
64
- * Get list of all available provider IDs
65
- * @returns Array of provider IDs
66
- */
67
- getAvailableProviders() {
68
- return Object.keys(this._providers);
69
- }
70
- _providers = {};
71
- _providersChanged = new Signal(this);
72
- }
@@ -1,36 +0,0 @@
1
- import type { Tool } from 'ai';
2
- import type { IProviderInfo } from '../tokens';
3
- type ToolMap = Record<string, Tool>;
4
- interface IWebSearchSettings {
5
- enabled?: boolean;
6
- externalWebAccess?: boolean;
7
- searchContextSize?: 'low' | 'medium' | 'high';
8
- allowedDomains?: string[];
9
- blockedDomains?: string[];
10
- maxUses?: number;
11
- }
12
- interface IWebFetchSettings {
13
- enabled?: boolean;
14
- maxUses?: number;
15
- maxContentTokens?: number;
16
- allowedDomains?: string[];
17
- blockedDomains?: string[];
18
- citationsEnabled?: boolean;
19
- }
20
- /**
21
- * Provider-level custom settings that control built-in web tools.
22
- */
23
- export interface IProviderCustomSettings {
24
- webSearch?: IWebSearchSettings;
25
- webFetch?: IWebFetchSettings;
26
- }
27
- interface IProviderToolContext {
28
- providerInfo?: IProviderInfo | null;
29
- customSettings?: IProviderCustomSettings;
30
- hasFunctionTools: boolean;
31
- }
32
- /**
33
- * Create provider-defined tools from custom settings and provider capabilities.
34
- */
35
- export declare function createProviderTools(options: IProviderToolContext): ToolMap;
36
- export {};