@jupyterlite/ai 0.18.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 (108) 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 +3 -1
  5. package/lib/chat-model.d.ts +46 -8
  6. package/lib/chat-model.js +51 -21
  7. package/lib/completion/completion-provider.d.ts +3 -1
  8. package/lib/completion/completion-provider.js +1 -2
  9. package/lib/completion/index.d.ts +1 -0
  10. package/lib/components/clear-button.d.ts +1 -0
  11. package/lib/components/clear-button.js +3 -4
  12. package/lib/components/completion-status.d.ts +1 -0
  13. package/lib/components/completion-status.js +5 -4
  14. package/lib/components/index.d.ts +1 -0
  15. package/lib/components/model-select.d.ts +1 -0
  16. package/lib/components/model-select.js +62 -67
  17. package/lib/components/save-button.d.ts +1 -0
  18. package/lib/components/save-button.js +4 -5
  19. package/lib/components/stop-button.d.ts +1 -0
  20. package/lib/components/stop-button.js +3 -4
  21. package/lib/components/tool-select.d.ts +3 -1
  22. package/lib/components/tool-select.js +47 -60
  23. package/lib/components/usage-display.d.ts +4 -2
  24. package/lib/components/usage-display.js +50 -61
  25. package/lib/diff-manager.d.ts +3 -1
  26. package/lib/index.d.ts +3 -2
  27. package/lib/index.js +28 -17
  28. package/lib/models/settings-model.d.ts +3 -1
  29. package/lib/rendered-message-outputarea.d.ts +1 -0
  30. package/lib/tokens.d.ts +18 -640
  31. package/lib/tokens.js +2 -31
  32. package/lib/widgets/ai-settings.d.ts +3 -1
  33. package/lib/widgets/ai-settings.js +185 -349
  34. package/lib/widgets/main-area-chat.d.ts +1 -0
  35. package/lib/widgets/provider-config-dialog.d.ts +2 -1
  36. package/lib/widgets/provider-config-dialog.js +102 -167
  37. package/package.json +111 -258
  38. package/src/chat-commands/skills.ts +2 -2
  39. package/src/chat-model-handler.ts +6 -4
  40. package/src/chat-model.ts +66 -19
  41. package/src/completion/completion-provider.ts +6 -6
  42. package/src/components/clear-button.tsx +0 -2
  43. package/src/components/completion-status.tsx +2 -2
  44. package/src/components/model-select.tsx +1 -1
  45. package/src/components/stop-button.tsx +0 -2
  46. package/src/components/tool-select.tsx +10 -9
  47. package/src/components/usage-display.tsx +4 -2
  48. package/src/diff-manager.ts +4 -3
  49. package/src/index.ts +62 -44
  50. package/src/models/settings-model.ts +6 -6
  51. package/src/tokens.ts +23 -788
  52. package/src/widgets/ai-settings.tsx +14 -11
  53. package/src/widgets/provider-config-dialog.tsx +8 -8
  54. package/LICENSE +0 -30
  55. package/README.md +0 -49
  56. package/lib/agent.d.ts +0 -280
  57. package/lib/agent.js +0 -1103
  58. package/lib/icons.d.ts +0 -3
  59. package/lib/icons.js +0 -8
  60. package/lib/providers/built-in-providers.d.ts +0 -21
  61. package/lib/providers/built-in-providers.js +0 -233
  62. package/lib/providers/generated-model-info.d.ts +0 -8
  63. package/lib/providers/generated-model-info.js +0 -502
  64. package/lib/providers/model-info.d.ts +0 -6
  65. package/lib/providers/model-info.js +0 -91
  66. package/lib/providers/models.d.ts +0 -37
  67. package/lib/providers/models.js +0 -28
  68. package/lib/providers/provider-registry.d.ts +0 -49
  69. package/lib/providers/provider-registry.js +0 -72
  70. package/lib/providers/provider-tools.d.ts +0 -36
  71. package/lib/providers/provider-tools.js +0 -93
  72. package/lib/skills/index.d.ts +0 -4
  73. package/lib/skills/index.js +0 -7
  74. package/lib/skills/parse-skill.d.ts +0 -25
  75. package/lib/skills/parse-skill.js +0 -69
  76. package/lib/skills/skill-loader.d.ts +0 -25
  77. package/lib/skills/skill-loader.js +0 -133
  78. package/lib/skills/skill-registry.d.ts +0 -31
  79. package/lib/skills/skill-registry.js +0 -100
  80. package/lib/skills/types.d.ts +0 -29
  81. package/lib/skills/types.js +0 -5
  82. package/lib/tools/commands.d.ts +0 -11
  83. package/lib/tools/commands.js +0 -154
  84. package/lib/tools/skills.d.ts +0 -9
  85. package/lib/tools/skills.js +0 -73
  86. package/lib/tools/tool-registry.d.ts +0 -35
  87. package/lib/tools/tool-registry.js +0 -55
  88. package/lib/tools/web.d.ts +0 -8
  89. package/lib/tools/web.js +0 -196
  90. package/src/agent.ts +0 -1431
  91. package/src/icons.ts +0 -11
  92. package/src/providers/built-in-providers.ts +0 -241
  93. package/src/providers/generated-model-info.ts +0 -508
  94. package/src/providers/model-info.ts +0 -145
  95. package/src/providers/models.ts +0 -76
  96. package/src/providers/provider-registry.ts +0 -88
  97. package/src/providers/provider-tools.ts +0 -179
  98. package/src/skills/index.ts +0 -14
  99. package/src/skills/parse-skill.ts +0 -91
  100. package/src/skills/skill-loader.ts +0 -175
  101. package/src/skills/skill-registry.ts +0 -137
  102. package/src/skills/types.ts +0 -37
  103. package/src/tools/commands.ts +0 -210
  104. package/src/tools/skills.ts +0 -84
  105. package/src/tools/tool-registry.ts +0 -63
  106. package/src/tools/web.ts +0 -238
  107. package/src/types.d.ts +0 -4
  108. package/style/icons/jupyternaut-lite.svg +0 -7
@@ -1,3 +1,15 @@
1
+ import {
2
+ getEffectiveContextWindow,
3
+ SECRETS_REPLACEMENT
4
+ } from '@jupyternaut/agent';
5
+ import type {
6
+ IAgentManagerFactory,
7
+ IAIConfig,
8
+ IAISecretsAccess,
9
+ IMCPServerConfig,
10
+ IProviderConfig,
11
+ IProviderRegistry
12
+ } from '@jupyternaut/agent';
1
13
  import { IThemeManager } from '@jupyterlab/apputils';
2
14
  import { ReactWidget } from '@jupyterlab/ui-components';
3
15
  import type { TranslationBundle } from '@jupyterlab/translation';
@@ -45,17 +57,8 @@ import {
45
57
  createTheme
46
58
  } from '@mui/material';
47
59
  import React, { useEffect, useMemo, useState } from 'react';
48
- import { getEffectiveContextWindow } from '../providers/model-info';
49
- import {
50
- type IAgentManagerFactory,
51
- type IAIConfig,
52
- type IAISecretsAccess,
53
- type IAISettingsModel,
54
- type IMCPServerConfig,
55
- type IProviderConfig,
56
- type IProviderRegistry,
57
- SECRETS_REPLACEMENT
58
- } from '../tokens';
60
+
61
+ import type { IAISettingsModel } from '../tokens';
59
62
  import { ProviderConfigDialog } from './provider-config-dialog';
60
63
 
61
64
  /**
@@ -1,3 +1,11 @@
1
+ import { getProviderModelInfo } from '@jupyternaut/agent';
2
+ import type {
3
+ IProviderConfig,
4
+ IProviderParameters,
5
+ IProviderRegistry,
6
+ IProviderToolCapabilities
7
+ } from '@jupyternaut/agent';
8
+ import type { TranslationBundle } from '@jupyterlab/translation';
1
9
  import ExpandMore from '@mui/icons-material/ExpandMore';
2
10
  import Delete from '@mui/icons-material/Delete';
3
11
  import Visibility from '@mui/icons-material/Visibility';
@@ -29,15 +37,7 @@ import {
29
37
  TextField,
30
38
  Typography
31
39
  } from '@mui/material';
32
- import type { TranslationBundle } from '@jupyterlab/translation';
33
40
  import React from 'react';
34
- import type {
35
- IProviderConfig,
36
- IProviderParameters,
37
- IProviderRegistry,
38
- IProviderToolCapabilities
39
- } from '../tokens';
40
- import { getProviderModelInfo } from '../providers/model-info';
41
41
 
42
42
  /**
43
43
  * Default parameter values for provider configuration
package/LICENSE DELETED
@@ -1,30 +0,0 @@
1
- BSD 3-Clause License
2
-
3
- Copyright (c) 2024, JupyterLite Contributors
4
- Copyright (c) 2024, Jeremy Tuloup
5
- All rights reserved.
6
-
7
- Redistribution and use in source and binary forms, with or without
8
- modification, are permitted provided that the following conditions are met:
9
-
10
- 1. Redistributions of source code must retain the above copyright notice, this
11
- list of conditions and the following disclaimer.
12
-
13
- 2. Redistributions in binary form must reproduce the above copyright notice,
14
- this list of conditions and the following disclaimer in the documentation
15
- and/or other materials provided with the distribution.
16
-
17
- 3. Neither the name of the copyright holder nor the names of its
18
- contributors may be used to endorse or promote products derived from
19
- this software without specific prior written permission.
20
-
21
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md DELETED
@@ -1,49 +0,0 @@
1
- # jupyterlite-ai
2
-
3
- [![Github Actions Status](https://github.com/jupyterlite/ai/workflows/Build/badge.svg)](https://github.com/jupyterlite/ai/actions/workflows/build.yml)
4
- [![Documentation Status](https://readthedocs.org/projects/jupyterlite-ai/badge/?version=latest)](https://jupyterlite-ai.readthedocs.io/en/latest/?badge=latest)
5
- [![lite-badge](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://jupyterlite.github.io/ai/lab/index.html)
6
-
7
- AI code completions and chat for JupyterLab, Notebook 7 and JupyterLite.
8
-
9
- [a screencast showing the Jupyterlite AI extension in JupyterLite](https://github.com/user-attachments/assets/e33d7d84-53ca-4835-a034-b6757476c98b)
10
-
11
- ## Requirements
12
-
13
- - JupyterLab >= 4.4.0 or Notebook >= 7.4.0
14
-
15
- ## Try it in your browser
16
-
17
- You can try the extension in your browser using JupyterLite:
18
-
19
- [![lite-badge](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://jupyterlite.github.io/ai/lab/index.html)
20
-
21
- ## Install
22
-
23
- To install the extension, execute:
24
-
25
- ```bash
26
- pip install jupyterlite-ai
27
- ```
28
-
29
- To install requirements (JupyterLab, JupyterLite and Notebook):
30
-
31
- ```bash
32
- pip install jupyterlite-ai[jupyter]
33
- ```
34
-
35
- ## Documentation
36
-
37
- For detailed usage instructions, including how to configure AI providers, see the [documentation](https://jupyterlite-ai.readthedocs.io/).
38
-
39
- ## Uninstall
40
-
41
- To remove the extension, execute:
42
-
43
- ```bash
44
- pip uninstall jupyterlite-ai
45
- ```
46
-
47
- ## Contributing
48
-
49
- See [CONTRIBUTING](CONTRIBUTING.md)
package/lib/agent.d.ts DELETED
@@ -1,280 +0,0 @@
1
- import { ISignal } from '@lumino/signaling';
2
- import { type ModelMessage, type UserContent } from 'ai';
3
- import { ISecretsManager } from 'jupyter-secrets-manager';
4
- import { type IAgentManager, type IAgentManagerFactory, type IAISettingsModel, type ISkillRegistry, type ITokenUsage, type ToolMap } from './tokens';
5
- /**
6
- * The agent manager factory namespace.
7
- */
8
- export declare namespace AgentManagerFactory {
9
- interface IOptions {
10
- /**
11
- * The settings model.
12
- */
13
- settingsModel: IAISettingsModel;
14
- /**
15
- * The skill registry for discovering skills.
16
- */
17
- skillRegistry?: ISkillRegistry;
18
- /**
19
- * The secrets manager.
20
- */
21
- secretsManager?: ISecretsManager;
22
- /**
23
- * The token used to request the secrets manager.
24
- */
25
- token: symbol | null;
26
- }
27
- }
28
- /**
29
- * The agent manager factory.
30
- */
31
- export declare class AgentManagerFactory implements IAgentManagerFactory {
32
- constructor(options: AgentManagerFactory.IOptions);
33
- /**
34
- * Create a new agent.
35
- */
36
- createAgent(options: IAgentManager.IOptions): IAgentManager;
37
- /**
38
- * Signal emitted when MCP connection status changes
39
- */
40
- get mcpConnectionChanged(): ISignal<this, boolean>;
41
- /**
42
- * Checks whether a specific MCP server is connected.
43
- * @param serverName The name of the MCP server to check
44
- * @returns True if the server is connected, false otherwise
45
- */
46
- isMCPServerConnected(serverName: string): boolean;
47
- /**
48
- * Gets the MCP tools from connected servers
49
- */
50
- getMCPTools(): Promise<ToolMap>;
51
- /**
52
- * Handles settings changes and reinitializes the agent.
53
- */
54
- private _onSettingsChanged;
55
- /**
56
- * Initializes MCP (Model Context Protocol) clients based on current settings.
57
- * Closes existing clients and connects to enabled servers from configuration.
58
- */
59
- private _initializeMCPClients;
60
- /**
61
- * Initializes the AI agent with current settings and tools.
62
- * Sets up the agent with model configuration, tools, and MCP servers.
63
- */
64
- private _initializeAgents;
65
- /**
66
- * Refresh skill snapshots across all agents.
67
- */
68
- refreshSkillSnapshots(): void;
69
- private _agentManagers;
70
- private _settingsModel;
71
- private _skillRegistry?;
72
- private _secretsManager?;
73
- private _mcpClients;
74
- private _mcpConnectionChanged;
75
- private _initQueue;
76
- }
77
- /**
78
- * Manages the AI agent lifecycle and execution loop.
79
- * Provides agent initialization, tool management, MCP server integration,
80
- * and handles the complete agent execution cycle.
81
- * Emits events for UI updates instead of directly manipulating the chat interface.
82
- */
83
- export declare class AgentManager implements IAgentManager {
84
- /**
85
- * Creates a new AgentManager instance.
86
- * @param options Configuration options for the agent manager
87
- */
88
- constructor(options: IAgentManager.IOptions);
89
- /**
90
- * Signal emitted when agent events occur
91
- */
92
- get agentEvent(): ISignal<this, IAgentManager.IAgentEvent>;
93
- /**
94
- * Signal emitted when the active provider has changed.
95
- */
96
- get activeProviderChanged(): ISignal<this, string | undefined>;
97
- /**
98
- * Gets the current token usage statistics.
99
- */
100
- get tokenUsage(): ITokenUsage;
101
- /**
102
- * Signal emitted when token usage statistics change.
103
- */
104
- get tokenUsageChanged(): ISignal<this, ITokenUsage>;
105
- /**
106
- * Refresh the skills snapshot and rebuild the agent if resources are ready.
107
- */
108
- refreshSkills(): void;
109
- /**
110
- * The active provider for this agent.
111
- */
112
- get activeProvider(): string;
113
- set activeProvider(value: string);
114
- /**
115
- * Sets the selected tools by name and reinitializes the agent.
116
- * @param toolNames Array of tool names to select
117
- */
118
- setSelectedTools(toolNames: string[]): void;
119
- /**
120
- * Gets the currently selected tools as a record.
121
- * @returns Record of selected tools
122
- */
123
- get selectedAgentTools(): ToolMap;
124
- /**
125
- * Checks if the current configuration is valid for agent operations.
126
- * Uses the provider registry to determine if an API key is required.
127
- * @returns True if the configuration is valid, false otherwise
128
- */
129
- hasValidConfig(): boolean;
130
- /**
131
- * Clears conversation history and resets agent state.
132
- */
133
- clearHistory(): Promise<void>;
134
- /**
135
- * Sets the history from already-processed model messages.
136
- * @param messages Pre-built model messages (may include binary content)
137
- */
138
- setHistory(messages: ModelMessage[]): void;
139
- /**
140
- * Stops the current streaming response by aborting the request.
141
- * Resolve any pending approval.
142
- */
143
- stopStreaming(reason?: string): void;
144
- /**
145
- * Approves a pending tool call.
146
- * @param toolCallId The tool call ID to approve
147
- * @param reason Optional reason for approval
148
- */
149
- approveToolCall(toolCallId: string, reason?: string): void;
150
- /**
151
- * Rejects a pending tool call.
152
- * @param toolCallId The tool call ID to reject
153
- * @param reason Optional reason for rejection
154
- */
155
- rejectToolCall(toolCallId: string, reason?: string): void;
156
- /**
157
- * Generates AI response to user message using the agent.
158
- * Handles the complete execution cycle including tool calls.
159
- * @param message The user message to respond to (may include processed attachment content)
160
- */
161
- generateResponse(message: UserContent): Promise<void>;
162
- /**
163
- * Create a transient language model to request a text response which won't be added to history.
164
- * @param messages - the messages sequence to send to the model.
165
- */
166
- textResponse(messages: ModelMessage[]): Promise<string>;
167
- /**
168
- * Updates cumulative token usage statistics from a completed model step.
169
- */
170
- private _updateTokenUsage;
171
- /**
172
- * Removes image and file parts from all user messages in the given list.
173
- */
174
- private _stripAttachments;
175
- /**
176
- * Gets the configured context window for the active provider.
177
- */
178
- private _getActiveContextWindow;
179
- /**
180
- * Initializes the AI agent with current settings and tools.
181
- * Sets up the agent with model configuration, tools, and MCP tools.
182
- */
183
- initializeAgent: (mcpTools?: ToolMap) => Promise<void>;
184
- /**
185
- * Refresh the in-memory skills snapshot from the skill registry.
186
- */
187
- private _refreshSkills;
188
- /**
189
- * Prepare model, tools, and settings needed to (re)build the agent.
190
- */
191
- private _prepareAgentConfig;
192
- /**
193
- * Build the runtime tool map used by the agent.
194
- */
195
- private _buildRuntimeTools;
196
- /**
197
- * Rebuild the agent using cached resources and the current skills snapshot.
198
- */
199
- private _rebuildAgent;
200
- /**
201
- * Processes the stream result from agent execution.
202
- * Handles message streaming, tool calls, and emits appropriate events.
203
- * @param result The stream result from agent execution
204
- * @returns Processing result including approval info if applicable
205
- */
206
- private _processStreamResult;
207
- /**
208
- * Emits a message_complete event.
209
- */
210
- private _emitMessageComplete;
211
- /**
212
- * Handles tool-result stream parts.
213
- */
214
- private _handleToolResult;
215
- /**
216
- * Handles tool-error stream parts.
217
- */
218
- private _handleToolError;
219
- /**
220
- * Handles tool-output-denied stream parts.
221
- */
222
- private _handleToolOutputDenied;
223
- /**
224
- * Handles tool-approval-request stream parts.
225
- */
226
- private _handleApprovalRequest;
227
- /**
228
- * Waits for user approval of a tool call.
229
- * @param toolCallId The tool call ID to wait for approval
230
- * @returns Promise that resolves to true if approved, false if rejected
231
- */
232
- private _waitForApproval;
233
- /**
234
- * Formats tool input for display by pretty-printing JSON strings.
235
- * @param input The tool input string to format
236
- * @returns Pretty-printed JSON string
237
- */
238
- private _formatToolInput;
239
- /**
240
- * Checks if the current provider supports tool calling.
241
- * @returns True if the provider supports tool calling, false otherwise
242
- */
243
- private _supportsToolCalling;
244
- /**
245
- * Creates a model instance based on current settings.
246
- * @returns The configured model instance for the agent
247
- */
248
- private _createModel;
249
- /**
250
- * Enhances the base system prompt with dynamic context like skills.
251
- * @param baseSystemPrompt The base system prompt from settings
252
- * @returns The enhanced system prompt with dynamic additions
253
- */
254
- private _getEnhancedSystemPrompt;
255
- /**
256
- * Build an instruction line describing MIME types supported by this session.
257
- */
258
- private _getSupportedMimeTypesInstruction;
259
- private _settingsModel;
260
- private _toolRegistry?;
261
- private _providerRegistry?;
262
- private _skillRegistry?;
263
- private _secretsManager?;
264
- private _selectedToolNames;
265
- private _agent;
266
- private _history;
267
- private _mcpTools;
268
- private _controller;
269
- private _agentEvent;
270
- private _tokenUsage;
271
- private _tokenUsageChanged;
272
- private _activeProvider;
273
- private _activeProviderChanged;
274
- private _skills;
275
- private _renderMimeRegistry?;
276
- private _initQueue;
277
- private _agentConfig;
278
- private _pendingApprovals;
279
- private _streaming;
280
- }