@notebook-intelligence/notebook-intelligence 2.4.2 → 2.6.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.
package/lib/tokens.d.ts CHANGED
@@ -26,7 +26,8 @@ export declare enum BackendMessageType {
26
26
  StreamMessage = "stream-message",
27
27
  StreamEnd = "stream-end",
28
28
  RunUICommand = "run-ui-command",
29
- GitHubCopilotLoginStatusChange = "github-copilot-login-status-change"
29
+ GitHubCopilotLoginStatusChange = "github-copilot-login-status-change",
30
+ MCPServerStatusChange = "mcp-server-status-change"
30
31
  }
31
32
  export declare enum ResponseStreamDataType {
32
33
  LLMRaw = "llm-raw",
@@ -43,6 +44,17 @@ export declare enum ContextType {
43
44
  Custom = "custom",
44
45
  CurrentFile = "current-file"
45
46
  }
47
+ export declare enum MCPServerStatus {
48
+ NotConnected = "not-connected",
49
+ Connecting = "connecting",
50
+ Disconnecting = "disconnecting",
51
+ FailedToConnect = "failed-to-connect",
52
+ Connected = "connected",
53
+ UpdatingToolList = "updating-tool-list",
54
+ UpdatedToolList = "updated-tool-list",
55
+ UpdatingPromptList = "updating-prompt-list",
56
+ UpdatedPromptList = "updated-prompt-list"
57
+ }
46
58
  export interface IContextItem {
47
59
  type: ContextType;
48
60
  content: string;
package/lib/tokens.js CHANGED
@@ -17,6 +17,7 @@ export var BackendMessageType;
17
17
  BackendMessageType["StreamEnd"] = "stream-end";
18
18
  BackendMessageType["RunUICommand"] = "run-ui-command";
19
19
  BackendMessageType["GitHubCopilotLoginStatusChange"] = "github-copilot-login-status-change";
20
+ BackendMessageType["MCPServerStatusChange"] = "mcp-server-status-change";
20
21
  })(BackendMessageType || (BackendMessageType = {}));
21
22
  export var ResponseStreamDataType;
22
23
  (function (ResponseStreamDataType) {
@@ -35,6 +36,18 @@ export var ContextType;
35
36
  ContextType["Custom"] = "custom";
36
37
  ContextType["CurrentFile"] = "current-file";
37
38
  })(ContextType || (ContextType = {}));
39
+ export var MCPServerStatus;
40
+ (function (MCPServerStatus) {
41
+ MCPServerStatus["NotConnected"] = "not-connected";
42
+ MCPServerStatus["Connecting"] = "connecting";
43
+ MCPServerStatus["Disconnecting"] = "disconnecting";
44
+ MCPServerStatus["FailedToConnect"] = "failed-to-connect";
45
+ MCPServerStatus["Connected"] = "connected";
46
+ MCPServerStatus["UpdatingToolList"] = "updating-tool-list";
47
+ MCPServerStatus["UpdatedToolList"] = "updated-tool-list";
48
+ MCPServerStatus["UpdatingPromptList"] = "updating-prompt-list";
49
+ MCPServerStatus["UpdatedPromptList"] = "updated-prompt-list";
50
+ })(MCPServerStatus || (MCPServerStatus = {}));
38
51
  export var BuiltinToolsetType;
39
52
  (function (BuiltinToolsetType) {
40
53
  BuiltinToolsetType["NotebookEdit"] = "nbi-notebook-edit";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notebook-intelligence/notebook-intelligence",
3
- "version": "2.4.2",
3
+ "version": "2.6.0",
4
4
  "description": "AI coding assistant for JupyterLab",
5
5
  "keywords": [
6
6
  "AI",
package/src/api.ts CHANGED
@@ -76,6 +76,28 @@ export class NBIConfig {
76
76
  return this.capabilities.tool_config;
77
77
  }
78
78
 
79
+ get mcpServers(): any {
80
+ return this.toolConfig.mcpServers;
81
+ }
82
+
83
+ getMCPServer(serverId: string): any {
84
+ return this.toolConfig.mcpServers.find(
85
+ (server: any) => server.id === serverId
86
+ );
87
+ }
88
+
89
+ getMCPServerPrompt(serverId: string, promptName: string): any {
90
+ const server = this.getMCPServer(serverId);
91
+ if (server) {
92
+ return server.prompts.find((prompt: any) => prompt.name === promptName);
93
+ }
94
+ return null;
95
+ }
96
+
97
+ get mcpServerSettings(): any {
98
+ return this.capabilities.mcp_server_settings;
99
+ }
100
+
79
101
  capabilities: any = {};
80
102
  chatParticipants: IChatParticipant[] = [];
81
103
 
@@ -102,7 +124,11 @@ export class NBIAPI {
102
124
 
103
125
  this._messageReceived.connect((_, msg) => {
104
126
  msg = JSON.parse(msg);
105
- if (msg.type === BackendMessageType.GitHubCopilotLoginStatusChange) {
127
+ if (msg.type === BackendMessageType.MCPServerStatusChange) {
128
+ this.fetchCapabilities();
129
+ } else if (
130
+ msg.type === BackendMessageType.GitHubCopilotLoginStatusChange
131
+ ) {
106
132
  this.updateGitHubLoginStatus().then(() => {
107
133
  this.githubLoginStatusChanged.emit();
108
134
  });
@@ -144,6 +170,30 @@ export class NBIAPI {
144
170
  return this._deviceVerificationInfo;
145
171
  }
146
172
 
173
+ static getGHLoginRequired() {
174
+ return (
175
+ this.config.usingGitHubCopilotModel &&
176
+ NBIAPI.getLoginStatus() === GitHubCopilotLoginStatus.NotLoggedIn
177
+ );
178
+ }
179
+
180
+ static getChatEnabled() {
181
+ return this.config.chatModel.provider === GITHUB_COPILOT_PROVIDER_ID
182
+ ? !this.getGHLoginRequired()
183
+ : this.config.llmProviders.find(
184
+ provider => provider.id === this.config.chatModel.provider
185
+ );
186
+ }
187
+
188
+ static getInlineCompletionEnabled() {
189
+ return this.config.inlineCompletionModel.provider ===
190
+ GITHUB_COPILOT_PROVIDER_ID
191
+ ? !this.getGHLoginRequired()
192
+ : this.config.llmProviders.find(
193
+ provider => provider.id === this.config.inlineCompletionModel.provider
194
+ );
195
+ }
196
+
147
197
  static async loginToGitHub() {
148
198
  this._loginStatus = GitHubCopilotLoginStatus.ActivatingDevice;
149
199
  return new Promise((resolve, reject) => {
@@ -201,11 +251,21 @@ export class NBIAPI {
201
251
  return new Promise<void>((resolve, reject) => {
202
252
  requestAPI<any>('capabilities', { method: 'GET' })
203
253
  .then(data => {
254
+ const oldConfig = {
255
+ capabilities: structuredClone(this.config.capabilities),
256
+ chatParticipants: structuredClone(this.config.chatParticipants)
257
+ };
204
258
  this.config.capabilities = structuredClone(data);
205
259
  this.config.chatParticipants = structuredClone(
206
260
  data.chat_participants
207
261
  );
208
- this.configChanged.emit();
262
+ const newConfig = {
263
+ capabilities: structuredClone(this.config.capabilities),
264
+ chatParticipants: structuredClone(this.config.chatParticipants)
265
+ };
266
+ if (JSON.stringify(newConfig) !== JSON.stringify(oldConfig)) {
267
+ this.configChanged.emit();
268
+ }
209
269
  resolve();
210
270
  })
211
271
  .catch(reason => {
@@ -245,20 +305,6 @@ export class NBIAPI {
245
305
  });
246
306
  }
247
307
 
248
- static async reloadMCPServerList(): Promise<any> {
249
- return new Promise<any>((resolve, reject) => {
250
- requestAPI<any>('reload-mcp-servers', { method: 'POST' })
251
- .then(async data => {
252
- await NBIAPI.fetchCapabilities();
253
- resolve(data);
254
- })
255
- .catch(reason => {
256
- console.error(`Failed to reload MCP server list.\n${reason}`);
257
- reject(reason);
258
- });
259
- });
260
- }
261
-
262
308
  static async getMCPConfigFile(): Promise<any> {
263
309
  return new Promise<any>((resolve, reject) => {
264
310
  requestAPI<any>('mcp-config-file', { method: 'GET' })
@@ -322,6 +368,20 @@ export class NBIAPI {
322
368
  );
323
369
  }
324
370
 
371
+ static async reloadMCPServers(): Promise<any> {
372
+ return new Promise<any>((resolve, reject) => {
373
+ requestAPI<any>('reload-mcp-servers', { method: 'POST' })
374
+ .then(async data => {
375
+ await NBIAPI.fetchCapabilities();
376
+ resolve(data);
377
+ })
378
+ .catch(reason => {
379
+ console.error(`Failed to reload MCP servers.\n${reason}`);
380
+ reject(reason);
381
+ });
382
+ });
383
+ }
384
+
325
385
  static async generateCode(
326
386
  chatId: string,
327
387
  prompt: string,