@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
package/src/tokens.ts CHANGED
@@ -1,26 +1,11 @@
1
+ import type {
2
+ IAISettingsModel as IBaseAISettingsModel,
3
+ IAgentManager,
4
+ ITokenUsage
5
+ } from '@jupyternaut/agent';
1
6
  import { ActiveCellManager, IChatModel, IMessage } from '@jupyter/chat';
2
- import { VDomRenderer } from '@jupyterlab/apputils';
3
- import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
4
7
  import { Token } from '@lumino/coreutils';
5
- import type { IDisposable } from '@lumino/disposable';
6
8
  import { ISignal } from '@lumino/signaling';
7
- import type { Tool, LanguageModel, UserContent, ModelMessage } from 'ai';
8
- import { ISecretsManager } from 'jupyter-secrets-manager';
9
-
10
- import type { IModelOptions } from './providers/models';
11
- import type {
12
- ISkillDefinition,
13
- ISkillRegistration,
14
- ISkillResourceResult,
15
- ISkillSummary
16
- } from './skills/types';
17
-
18
- export type {
19
- ISkillDefinition,
20
- ISkillRegistration,
21
- ISkillResourceResult,
22
- ISkillSummary
23
- } from './skills/types';
24
9
 
25
10
  /**
26
11
  * Command IDs namespace
@@ -36,646 +21,6 @@ export namespace CommandIds {
36
21
  export const restoreChat = '@jupyterlite/ai:restore-chat';
37
22
  }
38
23
 
39
- /* THE TOOL REGISTRY */
40
- /**
41
- * Type definition for a tool
42
- */
43
- export type ITool = Tool;
44
-
45
- /**
46
- * A map containing tools.
47
- */
48
- export type ToolMap = Record<string, ITool>;
49
-
50
- /**
51
- * Interface for a named tool (tool with a name identifier)
52
- */
53
- export interface INamedTool {
54
- /**
55
- * The unique name of the tool
56
- */
57
- name: string;
58
- /**
59
- * The tool instance
60
- */
61
- tool: ITool;
62
- }
63
-
64
- /**
65
- * The tool registry interface for managing AI tools
66
- */
67
- export interface IToolRegistry {
68
- /**
69
- * The registered tools as a record (name -> tool mapping).
70
- */
71
- readonly tools: Record<string, ITool>;
72
-
73
- /**
74
- * The registered named tools array.
75
- */
76
- readonly namedTools: INamedTool[];
77
-
78
- /**
79
- * A signal triggered when the tools have changed.
80
- */
81
- readonly toolsChanged: ISignal<IToolRegistry, void>;
82
-
83
- /**
84
- * Add a new tool to the registry.
85
- */
86
- add(name: string, tool: ITool): void;
87
-
88
- /**
89
- * Get a tool for a given name.
90
- * Return null if the name is not provided or if there is no registered tool with the
91
- * given name.
92
- */
93
- get(name: string | null): ITool | null;
94
-
95
- /**
96
- * Remove a tool from the registry by name.
97
- */
98
- remove(name: string): boolean;
99
- }
100
-
101
- /**
102
- * The tool registry token.
103
- */
104
- export const IToolRegistry = new Token<IToolRegistry>(
105
- '@jupyterlite/ai:IToolRegistry',
106
- 'Tool registry for AI agent functionality'
107
- );
108
-
109
- /* THE SKILL REGISTRY */
110
-
111
- /**
112
- * Registry for skills available to the AI agent.
113
- */
114
- export interface ISkillRegistry {
115
- /**
116
- * Signal emitted when skills change.
117
- */
118
- readonly skillsChanged: ISignal<ISkillRegistry, void>;
119
-
120
- /**
121
- * Register a single skill.
122
- */
123
- registerSkill(skill: ISkillRegistration): IDisposable;
124
-
125
- /**
126
- * List all skills with summary info, optionally filtered by a search query.
127
- */
128
- listSkills(query?: string): ISkillSummary[];
129
-
130
- /**
131
- * Get a full skill definition by name.
132
- */
133
- getSkill(name: string): ISkillDefinition | null;
134
-
135
- /**
136
- * Load a resource for a skill.
137
- */
138
- getSkillResource(
139
- name: string,
140
- resource: string
141
- ): Promise<ISkillResourceResult>;
142
- }
143
-
144
- /**
145
- * The skill registry token.
146
- */
147
- export const ISkillRegistry = new Token<ISkillRegistry>(
148
- '@jupyterlite/ai:ISkillRegistry',
149
- 'Skill registry for AI agent functionality'
150
- );
151
-
152
- /* THE LLM PROVIDER REGISTRY */
153
-
154
- /**
155
- * Interface for a provider factory function that creates language models
156
- */
157
- export interface IProviderFactory {
158
- (options: IModelOptions): LanguageModel;
159
- }
160
-
161
- /**
162
- * Built-in web search integration families supported by provider tools.
163
- */
164
- export type IProviderWebSearchImplementation = 'openai' | 'anthropic';
165
-
166
- /**
167
- * Built-in web fetch integration families supported by provider tools.
168
- */
169
- export type IProviderWebFetchImplementation = 'anthropic';
170
-
171
- /**
172
- * Capability descriptor for provider-hosted web search.
173
- */
174
- export interface IProviderWebSearchCapability {
175
- /**
176
- * Which built-in integration family to use.
177
- */
178
- implementation: IProviderWebSearchImplementation;
179
-
180
- /**
181
- * If true, skip provider-hosted web search when function tools are enabled.
182
- */
183
- requiresNoFunctionTools?: boolean;
184
- }
185
-
186
- /**
187
- * Capability descriptor for provider-hosted web fetch.
188
- */
189
- export interface IProviderWebFetchCapability {
190
- /**
191
- * Which built-in integration family to use.
192
- */
193
- implementation: IProviderWebFetchImplementation;
194
- }
195
-
196
- /**
197
- * Provider-hosted tool capabilities exposed by a provider.
198
- */
199
- export interface IProviderToolCapabilities {
200
- webSearch?: IProviderWebSearchCapability;
201
- webFetch?: IProviderWebFetchCapability;
202
- }
203
-
204
- /**
205
- * Provider information
206
- */
207
- export interface IProviderModelInfo {
208
- /**
209
- * Default context window for the model in tokens.
210
- */
211
- contextWindow?: number;
212
- /**
213
- * Whether the model supports image inputs.
214
- */
215
- supportsImages?: boolean;
216
- /**
217
- * Whether the model supports PDF inputs.
218
- */
219
- supportsPdf?: boolean;
220
- /**
221
- * Whether the model supports audio inputs.
222
- */
223
- supportsAudio?: boolean;
224
- }
225
-
226
- export interface IProviderInfo {
227
- /**
228
- * Unique identifier for the provider
229
- */
230
- id: string;
231
-
232
- /**
233
- * Display name for the provider
234
- */
235
- name: string;
236
-
237
- /**
238
- * API key requirement policy for this provider
239
- * - 'required': API key is mandatory
240
- * - 'optional': API key is optional
241
- * - 'none': API key is not needed and field will be hidden
242
- */
243
- apiKeyRequirement: 'required' | 'optional' | 'none';
244
-
245
- /**
246
- * Default model names for this provider
247
- */
248
- defaultModels: string[];
249
-
250
- /**
251
- * Optional per-model metadata keyed by model ID.
252
- */
253
- modelInfo?: Record<string, IProviderModelInfo>;
254
-
255
- /**
256
- * Whether this provider supports custom base URLs
257
- */
258
- supportsBaseURL?: boolean;
259
-
260
- /**
261
- * Whether this provider supports custom headers
262
- */
263
- supportsHeaders?: boolean;
264
-
265
- /**
266
- * Whether this provider supports tool calling
267
- */
268
- supportsToolCalling?: boolean;
269
-
270
- /**
271
- * Optional description shown in the UI
272
- */
273
- description?: string;
274
-
275
- /**
276
- * Optional URL suggestions
277
- */
278
- baseUrls?: { url: string; description?: string }[];
279
-
280
- /**
281
- * Optional provider-hosted tool capabilities for web retrieval.
282
- */
283
- providerToolCapabilities?: IProviderToolCapabilities;
284
-
285
- /**
286
- * Factory function for creating language models
287
- */
288
- factory: IProviderFactory;
289
- }
290
-
291
- /**
292
- * Registry for AI providers
293
- */
294
- export interface IProviderRegistry {
295
- /**
296
- * The registered providers as a record (id -> info mapping).
297
- */
298
- readonly providers: Record<string, IProviderInfo>;
299
-
300
- /**
301
- * A signal triggered when providers have changed.
302
- */
303
- readonly providersChanged: ISignal<IProviderRegistry, void>;
304
-
305
- /**
306
- * Register a new provider.
307
- */
308
- registerProvider(info: IProviderInfo): void;
309
-
310
- /**
311
- * Get provider info by id.
312
- */
313
- getProviderInfo(id: string): IProviderInfo | null;
314
-
315
- /**
316
- * Create a chat model instance for the given provider.
317
- */
318
- createChatModel(id: string, options: IModelOptions): LanguageModel | null;
319
-
320
- /**
321
- * Create a completion model instance for the given provider.
322
- */
323
- createCompletionModel(
324
- id: string,
325
- options: IModelOptions
326
- ): LanguageModel | null;
327
-
328
- /**
329
- * Get all available provider IDs.
330
- */
331
- getAvailableProviders(): string[];
332
- }
333
-
334
- /**
335
- * Token for the provider registry.
336
- */
337
- export const IProviderRegistry = new Token<IProviderRegistry>(
338
- '@jupyterlite/ai:IProviderRegistry',
339
- 'Registry for AI providers'
340
- );
341
-
342
- /* THE SETTINGS MODEL */
343
-
344
- export interface IProviderParameters {
345
- temperature?: number;
346
- maxOutputTokens?: number;
347
- maxTurns?: number;
348
- contextWindow?: number;
349
- supportsFillInMiddle?: boolean;
350
- useFilterText?: boolean;
351
- }
352
-
353
- export interface IProviderConfig {
354
- id: string;
355
- name: string;
356
- provider: string;
357
- model: string;
358
- apiKey?: string;
359
- baseURL?: string;
360
- headers?: Record<string, string>;
361
- parameters?: IProviderParameters;
362
- customSettings?: Record<string, any>;
363
- [key: string]: any; // Index signature for JupyterLab settings compatibility
364
- }
365
-
366
- export interface IMCPServerConfig {
367
- id: string;
368
- name: string;
369
- url: string;
370
- enabled: boolean;
371
- [key: string]: any; // Index signature for JupyterLab settings compatibility
372
- }
373
-
374
- export interface IAIConfig {
375
- // Whether to use the secrets manager
376
- useSecretsManager: boolean;
377
- // List of configured providers
378
- providers: IProviderConfig[];
379
- // Active provider IDs for different use cases
380
- defaultProvider: string; // Default provider for chat
381
- activeCompleterProvider?: string; // Provider for completions (if different)
382
- // When true, use the same provider for chat and completions
383
- useSameProviderForChatAndCompleter: boolean;
384
- // MCP servers configuration
385
- mcpServers: IMCPServerConfig[];
386
- // Global settings
387
- contextAwareness: boolean;
388
- codeExecution: boolean;
389
- systemPrompt: string;
390
- completionSystemPrompt: string;
391
- toolsEnabled: boolean;
392
- // Chat behavior settings
393
- sendWithShiftEnter: boolean;
394
- // Token usage display setting
395
- showTokenUsage: boolean;
396
- // Context usage display setting
397
- showContextUsage: boolean;
398
- // Commands that require approval before execution
399
- commandsRequiringApproval: string[];
400
- // Commands whose execute_command outputs may auto-render MIME bundles in chat
401
- commandsAutoRenderMimeBundles: string[];
402
- // MIME types that are trusted when auto-rendering execute_command outputs
403
- trustedMimeTypesForAutoRender: string[];
404
- // Diff display settings
405
- showCellDiff: boolean;
406
- showFileDiff: boolean;
407
- diffDisplayMode: 'split' | 'unified';
408
- // Paths to directories containing agent skills
409
- skillsPaths: string[];
410
- // Directory where chat backups are saved
411
- chatBackupDirectory: string;
412
- // Automatically request a title from the model for every message until there are 5 messages
413
- autoTitle: boolean;
414
- }
415
-
416
- export interface IAISettingsModel extends VDomRenderer.IModel {
417
- readonly config: IAIConfig;
418
- updateConfig(updates: Partial<IAIConfig>): Promise<void>;
419
- readonly providers: IProviderConfig[];
420
- getProvider(id: string): IProviderConfig | undefined;
421
- getDefaultProvider(): IProviderConfig | undefined;
422
- getCompleterProvider(): IProviderConfig | undefined;
423
- addProvider(providerConfig: Omit<IProviderConfig, 'id'>): Promise<string>;
424
- removeProvider(id: string): Promise<void>;
425
- updateProvider(id: string, updates: Partial<IProviderConfig>): Promise<void>;
426
- setActiveProvider(id: string): Promise<void>;
427
- setActiveCompleterProvider(id: string | undefined): Promise<void>;
428
- readonly mcpServers: IMCPServerConfig[];
429
- getMCPServer(id: string): IMCPServerConfig | undefined;
430
- addMCPServer(serverConfig: Omit<IMCPServerConfig, 'id'>): Promise<string>;
431
- removeMCPServer(id: string): Promise<void>;
432
- updateMCPServer(
433
- id: string,
434
- updates: Partial<IMCPServerConfig>
435
- ): Promise<void>;
436
- /**
437
- * Get the API key saved in the settings file for a given provider.
438
- *
439
- * @param id - the id of the provider.
440
- */
441
- getApiKey(id: string): string;
442
- }
443
-
444
- /**
445
- * Token for the AI settings model.
446
- */
447
- export const IAISettingsModel = new Token<IAISettingsModel>(
448
- '@jupyterlite/ai:IAISettingsModel'
449
- );
450
-
451
- /* THE AGENT MANAGER */
452
-
453
- /**
454
- * A namespace for agent manager.
455
- */
456
- export namespace IAgentManager {
457
- /**
458
- * Configuration options for the AgentManager
459
- */
460
- export interface IOptions {
461
- /**
462
- * AI settings model for configuration
463
- */
464
- settingsModel: IAISettingsModel;
465
-
466
- /**
467
- * Optional tool registry for managing available tools
468
- */
469
- toolRegistry?: IToolRegistry;
470
-
471
- /**
472
- * Optional provider registry for model creation
473
- */
474
- providerRegistry?: IProviderRegistry;
475
-
476
- /**
477
- * The skill registry for discovering skills.
478
- */
479
- skillRegistry?: ISkillRegistry;
480
-
481
- /**
482
- * The secrets manager.
483
- */
484
- secretsManager?: ISecretsManager;
485
-
486
- /**
487
- * The active provider to use with this agent.
488
- */
489
- activeProvider?: string;
490
-
491
- /**
492
- * Initial token usage.
493
- */
494
- tokenUsage?: ITokenUsage;
495
-
496
- /**
497
- * JupyterLab render mime registry for discovering supported MIME types.
498
- */
499
- renderMimeRegistry?: IRenderMimeRegistry;
500
- }
501
-
502
- /**
503
- * Event type mapping for type safety with inlined interface definitions
504
- */
505
- export interface IAgentEventTypeMap {
506
- message_start: {
507
- messageId: string;
508
- };
509
- message_chunk: {
510
- messageId: string;
511
- chunk: string;
512
- fullContent: string;
513
- };
514
- message_complete: {
515
- messageId: string;
516
- content: string;
517
- };
518
- tool_call_start: {
519
- callId: string;
520
- toolName: string;
521
- input: string;
522
- };
523
- tool_call_complete: {
524
- callId: string;
525
- toolName: string;
526
- outputData: unknown;
527
- isError: boolean;
528
- };
529
- tool_approval_request: {
530
- toolCallId: string;
531
- toolName: string;
532
- args: unknown;
533
- };
534
- tool_approval_resolved: {
535
- toolCallId: string;
536
- approved: boolean;
537
- };
538
- error: {
539
- error: Error;
540
- };
541
- }
542
-
543
- /**
544
- * Events emitted by the AgentManager
545
- */
546
- export type IAgentEvent<
547
- T extends keyof IAgentEventTypeMap = keyof IAgentEventTypeMap
548
- > = T extends keyof IAgentEventTypeMap
549
- ? {
550
- type: T;
551
- data: IAgentEventTypeMap[T];
552
- }
553
- : never;
554
- }
555
-
556
- export interface IAgentManager {
557
- /**
558
- * The active provider for this agent.
559
- */
560
- activeProvider: string;
561
- /**
562
- * Signal emitted when agent events occur
563
- */
564
- readonly agentEvent: ISignal<IAgentManager, IAgentManager.IAgentEvent>;
565
- /**
566
- * Signal emitted when the active provider has changed.
567
- */
568
- readonly activeProviderChanged: ISignal<IAgentManager, string | undefined>;
569
- /**
570
- * Gets the current token usage statistics.
571
- */
572
- readonly tokenUsage: ITokenUsage;
573
- /**
574
- * Signal emitted when token usage statistics change.
575
- */
576
- readonly tokenUsageChanged: ISignal<IAgentManager, ITokenUsage>;
577
- /**
578
- * Refresh the skills snapshot and rebuild the agent if resources are ready.
579
- */
580
- refreshSkills(): void;
581
- /**
582
- * Sets the selected tools by name and reinitializes the agent.
583
- * @param toolNames Array of tool names to select
584
- */
585
- setSelectedTools(toolNames: string[]): void;
586
- /**
587
- * Gets the currently selected tools as a record.
588
- * @returns Record of selected tools
589
- */
590
- readonly selectedAgentTools: ToolMap;
591
- /**
592
- * Checks if the current configuration is valid for agent operations.
593
- * Uses the provider registry to determine if an API key is required.
594
- * @returns True if the configuration is valid, false otherwise
595
- */
596
- hasValidConfig(): boolean;
597
- /**
598
- * Clears conversation history and resets agent state.
599
- */
600
- clearHistory(): Promise<void>;
601
- /**
602
- * Sets the history from already-processed model messages.
603
- * @param messages Pre-built model messages (may include binary content)
604
- */
605
- setHistory(messages: ModelMessage[]): void;
606
- /**
607
- * Stops the current streaming response by aborting the request.
608
- */
609
- stopStreaming(): void;
610
- /**
611
- * Approves a pending tool call.
612
- * @param toolCallId The tool call ID to approve
613
- * @param reason Optional reason for approval
614
- */
615
- approveToolCall(toolCallId: string, reason?: string): void;
616
- /**
617
- * Rejects a pending tool call.
618
- * @param toolCallId The tool call ID to reject
619
- * @param reason Optional reason for rejection
620
- */
621
- rejectToolCall(toolCallId: string, reason?: string): void;
622
- /**
623
- * Generates AI response to user message using the agent.
624
- * Handles the complete execution cycle including tool calls.
625
- * @param message The user message to respond to (may include processed attachment content)
626
- */
627
- generateResponse(message: UserContent): Promise<void>;
628
- /**
629
- * Create a transient language model to request a text response, which won't be added to history.
630
- * @param messages - the messages sequence to send to the model.
631
- */
632
- textResponse(messages: ModelMessage[]): Promise<string>;
633
- /**
634
- * Initializes the AI agent with current settings and tools.
635
- * Sets up the agent with model configuration, tools, and MCP tools.
636
- */
637
- initializeAgent(mcpTools?: ToolMap): Promise<void>;
638
- }
639
-
640
- /**
641
- * Token for the agent manager.
642
- */
643
- export const IAgentManager = new Token<IAgentManager>(
644
- '@jupyterlite/ai:IAgentManager'
645
- );
646
-
647
- /* The AGENT MANAGER FACTORY */
648
- /**
649
- * The interface for a agent manager factory.
650
- */
651
- export interface IAgentManagerFactory {
652
- /**
653
- * Create a new agent.
654
- */
655
- createAgent(options: IAgentManager.IOptions): IAgentManager;
656
- /**
657
- * Signal emitted when MCP connection status changes
658
- */
659
- readonly mcpConnectionChanged: ISignal<IAgentManagerFactory, boolean>;
660
- /**
661
- * Checks whether a specific MCP server is connected.
662
- * @param serverName The name of the MCP server to check
663
- * @returns True if the server is connected, false otherwise
664
- */
665
- isMCPServerConnected(serverName: string): boolean;
666
- /**
667
- * Gets the MCP tools from connected servers
668
- */
669
- getMCPTools(): Promise<ToolMap>;
670
- }
671
-
672
- /*
673
- * Token for the agent manager factory.
674
- */
675
- export const IAgentManagerFactory = new Token<IAgentManagerFactory>(
676
- '@jupyterlite/ai:IAgentManagerFactory'
677
- );
678
-
679
24
  /* THE CHAT MODELS HANDLER */
680
25
 
681
26
  export interface IAIChatModel extends IChatModel {
@@ -731,6 +76,17 @@ export interface IAIChatModel extends IChatModel {
731
76
  * @param messageId The ID of the queued message to remove
732
77
  */
733
78
  removeQueuedMessage(messageId: string): void;
79
+ /**
80
+ * Reorders queued messages by their IDs.
81
+ * @param messageIds Array of message IDs in the desired order
82
+ */
83
+ reorderQueuedMessages(messageIds: string[]): void;
84
+ /**
85
+ * Edits a queued message by its ID.
86
+ * @param messageId The ID of the queued message to edit
87
+ * @param newBody The new body of the message
88
+ */
89
+ editQueuedMessage(messageId: string, newBody: string): void;
734
90
  /**
735
91
  * The current message queue
736
92
  */
@@ -788,138 +144,17 @@ export const IChatModelHandler = new Token<IChatModelHandler>(
788
144
  '@jupyterlite/ai:IChatModelHandler'
789
145
  );
790
146
 
791
- /* THE DIFF MANAGER */
792
-
793
- /**
794
- * Parameters for showing cell diff
795
- */
796
- export interface IShowCellDiffParams {
797
- /**
798
- * Original cell content
799
- */
800
- original: string;
801
- /**
802
- * Modified cell content
803
- */
804
- modified: string;
805
- /**
806
- * Optional cell ID
807
- */
808
- cellId?: string;
809
- /**
810
- * Whether to show action buttons in the diff view
811
- */
812
- showActionButtons?: boolean;
813
- /**
814
- * Whether to open the diff view
815
- */
816
- openDiff?: boolean;
817
- /**
818
- * Optional path to the notebook
819
- */
820
- notebookPath?: string;
821
- }
822
-
823
147
  /**
824
- * Parameters for showing file diff
148
+ * Interface for the AI settings model with JupyterLab-specific features.
149
+ * Extends the base IAISettingsModel from @jupyternaut/agent which already includes VDomRenderer.IModel.
825
150
  */
826
- export interface IShowFileDiffParams {
827
- /**
828
- * Original file content
829
- */
830
- original: string;
831
- /**
832
- * Modified file content
833
- */
834
- modified: string;
835
- /**
836
- * Optional file path
837
- */
838
- filePath?: string;
839
- /**
840
- * Whether to show action buttons in the diff view
841
- */
842
- showActionButtons?: boolean;
151
+ export interface IAISettingsModel extends IBaseAISettingsModel {
152
+ // Extends the base IAISettingsModel with JupyterLab-specific features
843
153
  }
844
154
 
845
155
  /**
846
- * Interface for managing diff operations
847
- */
848
- export interface IDiffManager {
849
- /**
850
- * Show diff between original and modified cell content
851
- */
852
- showCellDiff(params: IShowCellDiffParams): Promise<void>;
853
- /**
854
- * Show diff between original and modified file content
855
- */
856
- showFileDiff(params: IShowFileDiffParams): Promise<void>;
857
- }
858
-
859
- /**
860
- * Token for the diff manager.
156
+ * Token for the AI settings model.
861
157
  */
862
- export const IDiffManager = new Token<IDiffManager>(
863
- '@jupyterlite/ai:IDiffManager'
158
+ export const IAISettingsModel = new Token<IAISettingsModel>(
159
+ '@jupyterlite/ai:IAISettingsModel'
864
160
  );
865
-
866
- /**
867
- * Interface for token usage statistics from AI model interactions
868
- */
869
- export interface ITokenUsage {
870
- /**
871
- * Number of input tokens consumed (prompt tokens)
872
- */
873
- inputTokens: number;
874
-
875
- /**
876
- * Number of output tokens generated (completion tokens)
877
- */
878
- outputTokens: number;
879
-
880
- /**
881
- * Estimated prompt tokens used by the most recent model request.
882
- * This is based on the final step of the latest request.
883
- */
884
- lastRequestInputTokens?: number;
885
-
886
- /**
887
- * Configured context window size for the active provider/model.
888
- */
889
- contextWindow?: number;
890
- }
891
-
892
- /**
893
- * The string that replaces a secret key in settings.
894
- */
895
- export const SECRETS_NAMESPACE = '@jupyterlite/ai:providers';
896
- export const SECRETS_REPLACEMENT = '***';
897
-
898
- /**
899
- * Internal interface for AI provider secret access within the shared namespace.
900
- */
901
- export interface IAISecretsAccess {
902
- /**
903
- * Whether secrets access is currently available.
904
- */
905
- readonly isAvailable: boolean;
906
-
907
- /**
908
- * Get a secret value by ID.
909
- */
910
- get(id: string): Promise<string | undefined>;
911
-
912
- /**
913
- * Set a secret value by ID.
914
- */
915
- set(id: string, value: string): Promise<void>;
916
-
917
- /**
918
- * Attach an input field to a secret ID.
919
- */
920
- attach(
921
- id: string,
922
- input: HTMLInputElement,
923
- callback?: (value: string) => void
924
- ): Promise<void>;
925
- }