@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.
- package/lib/chat-commands/clear.d.ts +1 -0
- package/lib/chat-commands/index.d.ts +1 -0
- package/lib/chat-commands/skills.d.ts +2 -1
- package/lib/chat-model-handler.d.ts +4 -3
- package/lib/chat-model-handler.js +2 -1
- package/lib/chat-model.d.ts +148 -8
- package/lib/chat-model.js +368 -79
- package/lib/completion/completion-provider.d.ts +3 -1
- package/lib/completion/completion-provider.js +1 -2
- package/lib/completion/index.d.ts +1 -0
- package/lib/components/clear-button.d.ts +1 -0
- package/lib/components/clear-button.js +3 -4
- package/lib/components/completion-status.d.ts +1 -0
- package/lib/components/completion-status.js +5 -4
- package/lib/components/index.d.ts +1 -0
- package/lib/components/model-select.d.ts +1 -0
- package/lib/components/model-select.js +62 -67
- package/lib/components/save-button.d.ts +3 -2
- package/lib/components/save-button.js +4 -5
- package/lib/components/stop-button.d.ts +1 -0
- package/lib/components/stop-button.js +3 -4
- package/lib/components/tool-select.d.ts +3 -1
- package/lib/components/tool-select.js +47 -60
- package/lib/components/usage-display.d.ts +4 -2
- package/lib/components/usage-display.js +50 -61
- package/lib/diff-manager.d.ts +3 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.js +50 -59
- package/lib/models/settings-model.d.ts +3 -1
- package/lib/models/settings-model.js +1 -0
- package/lib/rendered-message-outputarea.d.ts +1 -0
- package/lib/tokens.d.ts +48 -597
- package/lib/tokens.js +2 -31
- package/lib/widgets/ai-settings.d.ts +3 -1
- package/lib/widgets/ai-settings.js +185 -344
- package/lib/widgets/main-area-chat.d.ts +3 -3
- package/lib/widgets/main-area-chat.js +2 -4
- package/lib/widgets/provider-config-dialog.d.ts +2 -1
- package/lib/widgets/provider-config-dialog.js +102 -167
- package/package.json +111 -258
- package/schema/settings-model.json +6 -0
- package/src/chat-commands/skills.ts +2 -2
- package/src/chat-model-handler.ts +10 -6
- package/src/chat-model.ts +488 -96
- package/src/completion/completion-provider.ts +6 -6
- package/src/components/clear-button.tsx +0 -2
- package/src/components/completion-status.tsx +2 -2
- package/src/components/model-select.tsx +1 -1
- package/src/components/save-button.tsx +3 -3
- package/src/components/stop-button.tsx +0 -2
- package/src/components/tool-select.tsx +10 -9
- package/src/components/usage-display.tsx +4 -2
- package/src/diff-manager.ts +4 -3
- package/src/index.ts +103 -107
- package/src/models/settings-model.ts +7 -6
- package/src/tokens.ts +54 -744
- package/src/widgets/ai-settings.tsx +40 -11
- package/src/widgets/main-area-chat.ts +5 -8
- package/src/widgets/provider-config-dialog.tsx +8 -8
- package/LICENSE +0 -30
- package/README.md +0 -49
- package/lib/agent.d.ts +0 -277
- package/lib/agent.js +0 -1116
- package/lib/icons.d.ts +0 -3
- package/lib/icons.js +0 -8
- package/lib/providers/built-in-providers.d.ts +0 -21
- package/lib/providers/built-in-providers.js +0 -233
- package/lib/providers/generated-context-windows.d.ts +0 -8
- package/lib/providers/generated-context-windows.js +0 -96
- package/lib/providers/model-info.d.ts +0 -3
- package/lib/providers/model-info.js +0 -58
- package/lib/providers/models.d.ts +0 -37
- package/lib/providers/models.js +0 -28
- package/lib/providers/provider-registry.d.ts +0 -49
- package/lib/providers/provider-registry.js +0 -72
- package/lib/providers/provider-tools.d.ts +0 -36
- package/lib/providers/provider-tools.js +0 -93
- package/lib/skills/index.d.ts +0 -4
- package/lib/skills/index.js +0 -7
- package/lib/skills/parse-skill.d.ts +0 -25
- package/lib/skills/parse-skill.js +0 -69
- package/lib/skills/skill-loader.d.ts +0 -25
- package/lib/skills/skill-loader.js +0 -133
- package/lib/skills/skill-registry.d.ts +0 -31
- package/lib/skills/skill-registry.js +0 -100
- package/lib/skills/types.d.ts +0 -29
- package/lib/skills/types.js +0 -5
- package/lib/tools/commands.d.ts +0 -11
- package/lib/tools/commands.js +0 -154
- package/lib/tools/skills.d.ts +0 -9
- package/lib/tools/skills.js +0 -73
- package/lib/tools/tool-registry.d.ts +0 -35
- package/lib/tools/tool-registry.js +0 -55
- package/lib/tools/web.d.ts +0 -8
- package/lib/tools/web.js +0 -196
- package/src/agent.ts +0 -1441
- package/src/icons.ts +0 -11
- package/src/providers/built-in-providers.ts +0 -241
- package/src/providers/generated-context-windows.ts +0 -102
- package/src/providers/model-info.ts +0 -88
- package/src/providers/models.ts +0 -76
- package/src/providers/provider-registry.ts +0 -88
- package/src/providers/provider-tools.ts +0 -179
- package/src/skills/index.ts +0 -14
- package/src/skills/parse-skill.ts +0 -91
- package/src/skills/skill-loader.ts +0 -175
- package/src/skills/skill-registry.ts +0 -137
- package/src/skills/types.ts +0 -37
- package/src/tools/commands.ts +0 -210
- package/src/tools/skills.ts +0 -84
- package/src/tools/tool-registry.ts +0 -63
- package/src/tools/web.ts +0 -238
- package/src/types.d.ts +0 -4
- 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
|
-
|
|
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
|
/**
|
|
@@ -925,6 +928,32 @@ const AISettingsComponent: React.FC<IAISettingsComponentProps> = ({
|
|
|
925
928
|
}
|
|
926
929
|
/>
|
|
927
930
|
|
|
931
|
+
<FormControlLabel
|
|
932
|
+
control={
|
|
933
|
+
<Switch
|
|
934
|
+
checked={config.autoTitle}
|
|
935
|
+
onChange={e =>
|
|
936
|
+
handleConfigUpdate({
|
|
937
|
+
autoTitle: e.target.checked
|
|
938
|
+
})
|
|
939
|
+
}
|
|
940
|
+
color="primary"
|
|
941
|
+
/>
|
|
942
|
+
}
|
|
943
|
+
label={
|
|
944
|
+
<Box>
|
|
945
|
+
<Typography variant="body1">
|
|
946
|
+
{trans.__('Auto Title')}
|
|
947
|
+
</Typography>
|
|
948
|
+
<Typography variant="caption" color="text.secondary">
|
|
949
|
+
{trans.__(
|
|
950
|
+
'Automatically generate a chat title from the model for every message until there are 5 messages'
|
|
951
|
+
)}
|
|
952
|
+
</Typography>
|
|
953
|
+
</Box>
|
|
954
|
+
}
|
|
955
|
+
/>
|
|
956
|
+
|
|
928
957
|
<FormControlLabel
|
|
929
958
|
control={
|
|
930
959
|
<Switch
|
|
@@ -4,11 +4,10 @@ import { launchIcon } from '@jupyterlab/ui-components';
|
|
|
4
4
|
import type { TranslationBundle } from '@jupyterlab/translation';
|
|
5
5
|
import { CommandRegistry } from '@lumino/commands';
|
|
6
6
|
|
|
7
|
-
import { AIChatModel } from '../chat-model';
|
|
8
7
|
import { SaveComponentWidget } from '../components/save-button';
|
|
9
8
|
import { UsageWidget } from '../components/usage-display';
|
|
10
9
|
import { RenderedMessageOutputAreaCompat } from '../rendered-message-outputarea';
|
|
11
|
-
import { CommandIds, type IAISettingsModel } from '../tokens';
|
|
10
|
+
import { CommandIds, IAIChatModel, type IAISettingsModel } from '../tokens';
|
|
12
11
|
|
|
13
12
|
export namespace MainAreaChat {
|
|
14
13
|
export interface IOptions extends MainAreaWidget.IOptions<ChatWidget> {
|
|
@@ -69,7 +68,7 @@ export class MainAreaChat extends MainAreaWidget<ChatWidget> {
|
|
|
69
68
|
chatPanel: this.content
|
|
70
69
|
});
|
|
71
70
|
|
|
72
|
-
this.model.writersChanged
|
|
71
|
+
this.model.writersChanged?.connect(this._writersChanged);
|
|
73
72
|
|
|
74
73
|
this.model.titleChanged.connect(this._titleChanged);
|
|
75
74
|
}
|
|
@@ -78,15 +77,15 @@ export class MainAreaChat extends MainAreaWidget<ChatWidget> {
|
|
|
78
77
|
super.dispose();
|
|
79
78
|
// Dispose of the approval buttons widget when the chat is disposed.
|
|
80
79
|
this._outputAreaCompat.dispose();
|
|
81
|
-
this.model.writersChanged
|
|
80
|
+
this.model.writersChanged?.disconnect(this._writersChanged);
|
|
82
81
|
this.model.titleChanged.disconnect(this._titleChanged);
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
/**
|
|
86
85
|
* Get the model of the chat.
|
|
87
86
|
*/
|
|
88
|
-
get model():
|
|
89
|
-
return this.content.model as
|
|
87
|
+
get model(): IAIChatModel {
|
|
88
|
+
return this.content.model as IAIChatModel;
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
/**
|
|
@@ -103,11 +102,9 @@ export class MainAreaChat extends MainAreaWidget<ChatWidget> {
|
|
|
103
102
|
);
|
|
104
103
|
|
|
105
104
|
if (aiWriting) {
|
|
106
|
-
this.content.inputToolbarRegistry?.hide('send');
|
|
107
105
|
this.content.inputToolbarRegistry?.show('stop');
|
|
108
106
|
} else {
|
|
109
107
|
this.content.inputToolbarRegistry?.hide('stop');
|
|
110
|
-
this.content.inputToolbarRegistry?.show('send');
|
|
111
108
|
}
|
|
112
109
|
};
|
|
113
110
|
|
|
@@ -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
|
-
[](https://github.com/jupyterlite/ai/actions/workflows/build.yml)
|
|
4
|
-
[](https://jupyterlite-ai.readthedocs.io/en/latest/?badge=latest)
|
|
5
|
-
[](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
|
-
[](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,277 +0,0 @@
|
|
|
1
|
-
import type { IMessageContent } from '@jupyter/chat';
|
|
2
|
-
import { ISignal } from '@lumino/signaling';
|
|
3
|
-
import { type ModelMessage, type UserContent } from 'ai';
|
|
4
|
-
import { ISecretsManager } from 'jupyter-secrets-manager';
|
|
5
|
-
import { type IAgentManager, type IAgentManagerFactory, type IAISettingsModel, type ISkillRegistry, type ITokenUsage, type ToolMap } from './tokens';
|
|
6
|
-
/**
|
|
7
|
-
* The agent manager factory namespace.
|
|
8
|
-
*/
|
|
9
|
-
export declare namespace AgentManagerFactory {
|
|
10
|
-
interface IOptions {
|
|
11
|
-
/**
|
|
12
|
-
* The settings model.
|
|
13
|
-
*/
|
|
14
|
-
settingsModel: IAISettingsModel;
|
|
15
|
-
/**
|
|
16
|
-
* The skill registry for discovering skills.
|
|
17
|
-
*/
|
|
18
|
-
skillRegistry?: ISkillRegistry;
|
|
19
|
-
/**
|
|
20
|
-
* The secrets manager.
|
|
21
|
-
*/
|
|
22
|
-
secretsManager?: ISecretsManager;
|
|
23
|
-
/**
|
|
24
|
-
* The token used to request the secrets manager.
|
|
25
|
-
*/
|
|
26
|
-
token: symbol | null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* The agent manager factory.
|
|
31
|
-
*/
|
|
32
|
-
export declare class AgentManagerFactory implements IAgentManagerFactory {
|
|
33
|
-
constructor(options: AgentManagerFactory.IOptions);
|
|
34
|
-
/**
|
|
35
|
-
* Create a new agent.
|
|
36
|
-
*/
|
|
37
|
-
createAgent(options: IAgentManager.IOptions): IAgentManager;
|
|
38
|
-
/**
|
|
39
|
-
* Signal emitted when MCP connection status changes
|
|
40
|
-
*/
|
|
41
|
-
get mcpConnectionChanged(): ISignal<this, boolean>;
|
|
42
|
-
/**
|
|
43
|
-
* Checks whether a specific MCP server is connected.
|
|
44
|
-
* @param serverName The name of the MCP server to check
|
|
45
|
-
* @returns True if the server is connected, false otherwise
|
|
46
|
-
*/
|
|
47
|
-
isMCPServerConnected(serverName: string): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Gets the MCP tools from connected servers
|
|
50
|
-
*/
|
|
51
|
-
getMCPTools(): Promise<ToolMap>;
|
|
52
|
-
/**
|
|
53
|
-
* Handles settings changes and reinitializes the agent.
|
|
54
|
-
*/
|
|
55
|
-
private _onSettingsChanged;
|
|
56
|
-
/**
|
|
57
|
-
* Initializes MCP (Model Context Protocol) clients based on current settings.
|
|
58
|
-
* Closes existing clients and connects to enabled servers from configuration.
|
|
59
|
-
*/
|
|
60
|
-
private _initializeMCPClients;
|
|
61
|
-
/**
|
|
62
|
-
* Initializes the AI agent with current settings and tools.
|
|
63
|
-
* Sets up the agent with model configuration, tools, and MCP servers.
|
|
64
|
-
*/
|
|
65
|
-
private _initializeAgents;
|
|
66
|
-
/**
|
|
67
|
-
* Refresh skill snapshots across all agents.
|
|
68
|
-
*/
|
|
69
|
-
refreshSkillSnapshots(): void;
|
|
70
|
-
private _agentManagers;
|
|
71
|
-
private _settingsModel;
|
|
72
|
-
private _skillRegistry?;
|
|
73
|
-
private _secretsManager?;
|
|
74
|
-
private _mcpClients;
|
|
75
|
-
private _mcpConnectionChanged;
|
|
76
|
-
private _initQueue;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Manages the AI agent lifecycle and execution loop.
|
|
80
|
-
* Provides agent initialization, tool management, MCP server integration,
|
|
81
|
-
* and handles the complete agent execution cycle.
|
|
82
|
-
* Emits events for UI updates instead of directly manipulating the chat interface.
|
|
83
|
-
*/
|
|
84
|
-
export declare class AgentManager implements IAgentManager {
|
|
85
|
-
/**
|
|
86
|
-
* Creates a new AgentManager instance.
|
|
87
|
-
* @param options Configuration options for the agent manager
|
|
88
|
-
*/
|
|
89
|
-
constructor(options: IAgentManager.IOptions);
|
|
90
|
-
/**
|
|
91
|
-
* Signal emitted when agent events occur
|
|
92
|
-
*/
|
|
93
|
-
get agentEvent(): ISignal<this, IAgentManager.IAgentEvent>;
|
|
94
|
-
/**
|
|
95
|
-
* Signal emitted when the active provider has changed.
|
|
96
|
-
*/
|
|
97
|
-
get activeProviderChanged(): ISignal<this, string | undefined>;
|
|
98
|
-
/**
|
|
99
|
-
* Gets the current token usage statistics.
|
|
100
|
-
*/
|
|
101
|
-
get tokenUsage(): ITokenUsage;
|
|
102
|
-
/**
|
|
103
|
-
* Signal emitted when token usage statistics change.
|
|
104
|
-
*/
|
|
105
|
-
get tokenUsageChanged(): ISignal<this, ITokenUsage>;
|
|
106
|
-
/**
|
|
107
|
-
* Refresh the skills snapshot and rebuild the agent if resources are ready.
|
|
108
|
-
*/
|
|
109
|
-
refreshSkills(): void;
|
|
110
|
-
/**
|
|
111
|
-
* The active provider for this agent.
|
|
112
|
-
*/
|
|
113
|
-
get activeProvider(): string;
|
|
114
|
-
set activeProvider(value: string);
|
|
115
|
-
/**
|
|
116
|
-
* Sets the selected tools by name and reinitializes the agent.
|
|
117
|
-
* @param toolNames Array of tool names to select
|
|
118
|
-
*/
|
|
119
|
-
setSelectedTools(toolNames: string[]): void;
|
|
120
|
-
/**
|
|
121
|
-
* Gets the currently selected tools as a record.
|
|
122
|
-
* @returns Record of selected tools
|
|
123
|
-
*/
|
|
124
|
-
get selectedAgentTools(): ToolMap;
|
|
125
|
-
/**
|
|
126
|
-
* Checks if the current configuration is valid for agent operations.
|
|
127
|
-
* Uses the provider registry to determine if an API key is required.
|
|
128
|
-
* @returns True if the configuration is valid, false otherwise
|
|
129
|
-
*/
|
|
130
|
-
hasValidConfig(): boolean;
|
|
131
|
-
/**
|
|
132
|
-
* Clears conversation history and resets agent state.
|
|
133
|
-
*/
|
|
134
|
-
clearHistory(): Promise<void>;
|
|
135
|
-
/**
|
|
136
|
-
* Sets the history with a list of messages from the chat.
|
|
137
|
-
* @param messages The chat messages to set as history
|
|
138
|
-
*/
|
|
139
|
-
setHistory(messages: IMessageContent[]): void;
|
|
140
|
-
/**
|
|
141
|
-
* Stops the current streaming response by aborting the request.
|
|
142
|
-
* Resolve any pending approval.
|
|
143
|
-
*/
|
|
144
|
-
stopStreaming(reason?: string): void;
|
|
145
|
-
/**
|
|
146
|
-
* Approves a pending tool call.
|
|
147
|
-
* @param approvalId The approval ID to approve
|
|
148
|
-
* @param reason Optional reason for approval
|
|
149
|
-
*/
|
|
150
|
-
approveToolCall(approvalId: string, reason?: string): void;
|
|
151
|
-
/**
|
|
152
|
-
* Rejects a pending tool call.
|
|
153
|
-
* @param approvalId The approval ID to reject
|
|
154
|
-
* @param reason Optional reason for rejection
|
|
155
|
-
*/
|
|
156
|
-
rejectToolCall(approvalId: string, reason?: string): void;
|
|
157
|
-
/**
|
|
158
|
-
* Generates AI response to user message using the agent.
|
|
159
|
-
* Handles the complete execution cycle including tool calls.
|
|
160
|
-
* @param message The user message to respond to (may include processed attachment content)
|
|
161
|
-
*/
|
|
162
|
-
generateResponse(message: UserContent): Promise<void>;
|
|
163
|
-
/**
|
|
164
|
-
* Create a transient language model to request a text response which won't be added to history.
|
|
165
|
-
* @param messages - the messages sequence to send to the model.
|
|
166
|
-
*/
|
|
167
|
-
textResponse(messages: ModelMessage[]): Promise<string>;
|
|
168
|
-
/**
|
|
169
|
-
* Updates cumulative token usage statistics from a completed model step.
|
|
170
|
-
*/
|
|
171
|
-
private _updateTokenUsage;
|
|
172
|
-
/**
|
|
173
|
-
* Gets the configured context window for the active provider.
|
|
174
|
-
*/
|
|
175
|
-
private _getActiveContextWindow;
|
|
176
|
-
/**
|
|
177
|
-
* Initializes the AI agent with current settings and tools.
|
|
178
|
-
* Sets up the agent with model configuration, tools, and MCP tools.
|
|
179
|
-
*/
|
|
180
|
-
initializeAgent: (mcpTools?: ToolMap) => Promise<void>;
|
|
181
|
-
/**
|
|
182
|
-
* Refresh the in-memory skills snapshot from the skill registry.
|
|
183
|
-
*/
|
|
184
|
-
private _refreshSkills;
|
|
185
|
-
/**
|
|
186
|
-
* Prepare model, tools, and settings needed to (re)build the agent.
|
|
187
|
-
*/
|
|
188
|
-
private _prepareAgentConfig;
|
|
189
|
-
/**
|
|
190
|
-
* Build the runtime tool map used by the agent.
|
|
191
|
-
*/
|
|
192
|
-
private _buildRuntimeTools;
|
|
193
|
-
/**
|
|
194
|
-
* Rebuild the agent using cached resources and the current skills snapshot.
|
|
195
|
-
*/
|
|
196
|
-
private _rebuildAgent;
|
|
197
|
-
/**
|
|
198
|
-
* Processes the stream result from agent execution.
|
|
199
|
-
* Handles message streaming, tool calls, and emits appropriate events.
|
|
200
|
-
* @param result The stream result from agent execution
|
|
201
|
-
* @returns Processing result including approval info if applicable
|
|
202
|
-
*/
|
|
203
|
-
private _processStreamResult;
|
|
204
|
-
/**
|
|
205
|
-
* Emits a message_complete event.
|
|
206
|
-
*/
|
|
207
|
-
private _emitMessageComplete;
|
|
208
|
-
/**
|
|
209
|
-
* Handles tool-result stream parts.
|
|
210
|
-
*/
|
|
211
|
-
private _handleToolResult;
|
|
212
|
-
/**
|
|
213
|
-
* Handles tool-error stream parts.
|
|
214
|
-
*/
|
|
215
|
-
private _handleToolError;
|
|
216
|
-
/**
|
|
217
|
-
* Handles tool-output-denied stream parts.
|
|
218
|
-
*/
|
|
219
|
-
private _handleToolOutputDenied;
|
|
220
|
-
/**
|
|
221
|
-
* Handles tool-approval-request stream parts.
|
|
222
|
-
*/
|
|
223
|
-
private _handleApprovalRequest;
|
|
224
|
-
/**
|
|
225
|
-
* Waits for user approval of a tool call.
|
|
226
|
-
* @param approvalId The approval ID to wait for
|
|
227
|
-
* @returns Promise that resolves to true if approved, false if rejected
|
|
228
|
-
*/
|
|
229
|
-
private _waitForApproval;
|
|
230
|
-
/**
|
|
231
|
-
* Formats tool input for display by pretty-printing JSON strings.
|
|
232
|
-
* @param input The tool input string to format
|
|
233
|
-
* @returns Pretty-printed JSON string
|
|
234
|
-
*/
|
|
235
|
-
private _formatToolInput;
|
|
236
|
-
/**
|
|
237
|
-
* Checks if the current provider supports tool calling.
|
|
238
|
-
* @returns True if the provider supports tool calling, false otherwise
|
|
239
|
-
*/
|
|
240
|
-
private _supportsToolCalling;
|
|
241
|
-
/**
|
|
242
|
-
* Creates a model instance based on current settings.
|
|
243
|
-
* @returns The configured model instance for the agent
|
|
244
|
-
*/
|
|
245
|
-
private _createModel;
|
|
246
|
-
/**
|
|
247
|
-
* Enhances the base system prompt with dynamic context like skills.
|
|
248
|
-
* @param baseSystemPrompt The base system prompt from settings
|
|
249
|
-
* @returns The enhanced system prompt with dynamic additions
|
|
250
|
-
*/
|
|
251
|
-
private _getEnhancedSystemPrompt;
|
|
252
|
-
/**
|
|
253
|
-
* Build an instruction line describing MIME types supported by this session.
|
|
254
|
-
*/
|
|
255
|
-
private _getSupportedMimeTypesInstruction;
|
|
256
|
-
private _settingsModel;
|
|
257
|
-
private _toolRegistry?;
|
|
258
|
-
private _providerRegistry?;
|
|
259
|
-
private _skillRegistry?;
|
|
260
|
-
private _secretsManager?;
|
|
261
|
-
private _selectedToolNames;
|
|
262
|
-
private _agent;
|
|
263
|
-
private _history;
|
|
264
|
-
private _mcpTools;
|
|
265
|
-
private _controller;
|
|
266
|
-
private _agentEvent;
|
|
267
|
-
private _tokenUsage;
|
|
268
|
-
private _tokenUsageChanged;
|
|
269
|
-
private _activeProvider;
|
|
270
|
-
private _activeProviderChanged;
|
|
271
|
-
private _skills;
|
|
272
|
-
private _renderMimeRegistry?;
|
|
273
|
-
private _initQueue;
|
|
274
|
-
private _agentConfig;
|
|
275
|
-
private _pendingApprovals;
|
|
276
|
-
private _streaming;
|
|
277
|
-
}
|