@jupyter-ai/acp-client 0.0.1
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/LICENSE +29 -0
- package/README.md +238 -0
- package/lib/index.d.ts +39 -0
- package/lib/index.js +101 -0
- package/lib/request.d.ts +14 -0
- package/lib/request.js +51 -0
- package/package.json +217 -0
- package/src/__tests__/jupyter_ai_acp_client.spec.ts +9 -0
- package/src/index.ts +127 -0
- package/src/request.ts +76 -0
- package/style/base.css +5 -0
- package/style/index.css +1 -0
- package/style/index.js +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Project Jupyter
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# jupyter_ai_acp_client
|
|
2
|
+
|
|
3
|
+
[](https://github.com/jupyter-ai-contrib/jupyter-ai-acp-client/actions/workflows/build.yml)
|
|
4
|
+
|
|
5
|
+
A proof-of-concept package providing a client implementation of the Agent Client
|
|
6
|
+
Protocol (ACP) in Jupyter AI v3, as well as helper classes for other developers
|
|
7
|
+
to use when custom AI personas wrapping ACP agents.
|
|
8
|
+
|
|
9
|
+
This package provides a default ACP client implementation as `JaiAcpClient`.
|
|
10
|
+
This client provides a `prompt_and_reply()` method which calls the ACP server
|
|
11
|
+
and streams the reply back to the chat. In addition, it provides file read, file
|
|
12
|
+
write, and terminal use capabilities.
|
|
13
|
+
|
|
14
|
+
This package also provides a default `BaseAcpPersona` class which can be easily
|
|
15
|
+
extended to add ACP agents as AI personas in JupyterLab. This base class takes
|
|
16
|
+
an additional `executable` argument which starts the ACP agent server. This
|
|
17
|
+
package also provides a default ACP client implementation as `JaiAcpClient`.
|
|
18
|
+
|
|
19
|
+
- `BaseAcpPersona` automatically creates new subprocesses for the ACP agent and
|
|
20
|
+
client when needed. These are stored as class attributes, so all instances of
|
|
21
|
+
the same ACP persona share a common ACP agent subprocess.
|
|
22
|
+
|
|
23
|
+
- Since `BaseAcpPersona` inherits from `BasePersona`, subclasses can be provided
|
|
24
|
+
simply as entry points to become available for use in Jupyter AI. (see
|
|
25
|
+
[documentation](https://jupyter-ai.readthedocs.io/en/v3/developers/entry_points_api/personas_group.html))
|
|
26
|
+
|
|
27
|
+
- Personas based on ACP now just need to derive from `BaseAcpPersona` and define
|
|
28
|
+
the persona name, the persona avatar, and the `executable` starting the ACP
|
|
29
|
+
agent server.
|
|
30
|
+
|
|
31
|
+
For example, the `@Claude-ACP` persona is defined in `claude.py` using less than
|
|
32
|
+
20 lines of code:
|
|
33
|
+
|
|
34
|
+
```py
|
|
35
|
+
class ClaudeAcpPersona(BaseAcpPersona):
|
|
36
|
+
def __init__(self, *args, **kwargs):
|
|
37
|
+
executable = ["claude-code-acp"]
|
|
38
|
+
super().__init__(*args, executable=executable, **kwargs)
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def defaults(self) -> PersonaDefaults:
|
|
42
|
+
avatar_path = str(os.path.abspath(
|
|
43
|
+
os.path.join(os.path.dirname(__file__), "..", "static", "claude.svg")
|
|
44
|
+
))
|
|
45
|
+
|
|
46
|
+
return PersonaDefaults(
|
|
47
|
+
name="Claude-ACP",
|
|
48
|
+
description="Claude Code as an ACP agent persona.",
|
|
49
|
+
avatar_path=avatar_path,
|
|
50
|
+
system_prompt="unused"
|
|
51
|
+
)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Currently, this package provides 2 personas: `@Test-ACP` and `@Claude-ACP`.
|
|
55
|
+
Note that `@Claude-ACP` requires the `claude-code-acp` executable to appear.
|
|
56
|
+
This can be installed via:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
npm install -g @zed-industries/claude-code-acp
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Requirements
|
|
63
|
+
|
|
64
|
+
- JupyterLab >= 4.0.0
|
|
65
|
+
- `jupyter-ai-persona-manager>=0.0.5`
|
|
66
|
+
- `agent_client_protocol`
|
|
67
|
+
- Optional: `claude-code-acp`
|
|
68
|
+
|
|
69
|
+
## Install
|
|
70
|
+
|
|
71
|
+
To install the extension, execute:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install jupyter_ai_acp_client
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Uninstall
|
|
78
|
+
|
|
79
|
+
To remove the extension, execute:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pip uninstall jupyter_ai_acp_client
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Troubleshoot
|
|
86
|
+
|
|
87
|
+
If you are seeing the frontend extension, but it is not working, check
|
|
88
|
+
that the server extension is enabled:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
jupyter server extension list
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
If the server extension is installed and enabled, but you are not seeing
|
|
95
|
+
the frontend extension, check the frontend extension is installed:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
jupyter labextension list
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Contributing
|
|
102
|
+
|
|
103
|
+
### Development install
|
|
104
|
+
|
|
105
|
+
Note: You will need NodeJS to build the extension package.
|
|
106
|
+
|
|
107
|
+
The `jlpm` command is JupyterLab's pinned version of
|
|
108
|
+
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
|
|
109
|
+
`yarn` or `npm` in lieu of `jlpm` below.
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Clone the repo to your local environment
|
|
113
|
+
# Change directory to the jupyter_ai_acp_client directory
|
|
114
|
+
|
|
115
|
+
# Set up a virtual environment and install package in development mode
|
|
116
|
+
python -m venv .venv
|
|
117
|
+
source .venv/bin/activate
|
|
118
|
+
pip install --editable ".[dev,test]"
|
|
119
|
+
|
|
120
|
+
# Link your development version of the extension with JupyterLab
|
|
121
|
+
jupyter labextension develop . --overwrite
|
|
122
|
+
# Server extension must be manually installed in develop mode
|
|
123
|
+
jupyter server extension enable jupyter_ai_acp_client
|
|
124
|
+
|
|
125
|
+
# Rebuild extension Typescript source after making changes
|
|
126
|
+
# IMPORTANT: Unlike the steps above which are performed only once, do this step
|
|
127
|
+
# every time you make a change.
|
|
128
|
+
jlpm build
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Watch the source directory in one terminal, automatically rebuilding when needed
|
|
135
|
+
jlpm watch
|
|
136
|
+
# Run JupyterLab in another terminal
|
|
137
|
+
jupyter lab
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).
|
|
141
|
+
|
|
142
|
+
By default, the `jlpm build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
jupyter lab build --minimize=False
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Development uninstall
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Server extension must be manually disabled in develop mode
|
|
152
|
+
jupyter server extension disable jupyter_ai_acp_client
|
|
153
|
+
pip uninstall jupyter_ai_acp_client
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
|
|
157
|
+
command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
|
|
158
|
+
folder is located. Then you can remove the symlink named `@jupyter-ai/acp-client` within that folder.
|
|
159
|
+
|
|
160
|
+
### Testing the extension
|
|
161
|
+
|
|
162
|
+
#### Server tests
|
|
163
|
+
|
|
164
|
+
This extension is using [Pytest](https://docs.pytest.org/) for Python code testing.
|
|
165
|
+
|
|
166
|
+
Install test dependencies (needed only once):
|
|
167
|
+
|
|
168
|
+
```sh
|
|
169
|
+
pip install -e ".[test]"
|
|
170
|
+
# Each time you install the Python package, you need to restore the front-end extension link
|
|
171
|
+
jupyter labextension develop . --overwrite
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
To execute them, run:
|
|
175
|
+
|
|
176
|
+
```sh
|
|
177
|
+
pytest -vv -r ap --cov jupyter_ai_acp_client
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### Frontend tests
|
|
181
|
+
|
|
182
|
+
This extension is using [Jest](https://jestjs.io/) for JavaScript code testing.
|
|
183
|
+
|
|
184
|
+
To execute them, execute:
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
jlpm
|
|
188
|
+
jlpm test
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### Integration tests
|
|
192
|
+
|
|
193
|
+
This extension uses [Playwright](https://playwright.dev/docs/intro) for the integration tests (aka user level tests).
|
|
194
|
+
More precisely, the JupyterLab helper [Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) is used to handle testing the extension in JupyterLab.
|
|
195
|
+
|
|
196
|
+
More information are provided within the [ui-tests](./ui-tests/README.md) README.
|
|
197
|
+
|
|
198
|
+
## AI Coding Assistant Support
|
|
199
|
+
|
|
200
|
+
This project includes an `AGENTS.md` file with coding standards and best practices for JupyterLab extension development. The file follows the [AGENTS.md standard](https://agents.md) for cross-tool compatibility.
|
|
201
|
+
|
|
202
|
+
### Compatible AI Tools
|
|
203
|
+
|
|
204
|
+
`AGENTS.md` works with AI coding assistants that support the standard, including Cursor, GitHub Copilot, Windsurf, Aider, and others. For a current list of compatible tools, see [the AGENTS.md standard](https://agents.md).
|
|
205
|
+
This project also includes symlinks for tool-specific compatibility:
|
|
206
|
+
|
|
207
|
+
- `CLAUDE.md` → `AGENTS.md` (for Claude Code)
|
|
208
|
+
|
|
209
|
+
- `GEMINI.md` → `AGENTS.md` (for Gemini Code Assist)
|
|
210
|
+
|
|
211
|
+
Other conventions you might encounter:
|
|
212
|
+
|
|
213
|
+
- `.cursorrules` - Cursor's YAML/JSON format (Cursor also supports AGENTS.md natively)
|
|
214
|
+
- `CONVENTIONS.md` / `CONTRIBUTING.md` - For CodeConventions.ai and GitHub bots
|
|
215
|
+
- Project-specific rules in JetBrains AI Assistant settings
|
|
216
|
+
|
|
217
|
+
All tool-specific files should be symlinks to `AGENTS.md` as the single source of truth.
|
|
218
|
+
|
|
219
|
+
### What's Included
|
|
220
|
+
|
|
221
|
+
The `AGENTS.md` file provides guidance on:
|
|
222
|
+
|
|
223
|
+
- Code quality rules and file-scoped validation commands
|
|
224
|
+
- Naming conventions for packages, plugins, and files
|
|
225
|
+
- Coding standards (TypeScript, Python)
|
|
226
|
+
- Development workflow and debugging
|
|
227
|
+
- Backend-frontend integration patterns (`APIHandler`, `requestAPI()`, routing)
|
|
228
|
+
- Common pitfalls and how to avoid them
|
|
229
|
+
|
|
230
|
+
### Customization
|
|
231
|
+
|
|
232
|
+
You can edit `AGENTS.md` to add project-specific conventions or adjust guidelines to match your team's practices. The file uses plain Markdown with Do/Don't patterns and references to actual project files.
|
|
233
|
+
|
|
234
|
+
**Note**: `AGENTS.md` is living documentation. Update it when you change conventions, add dependencies, or discover new patterns. Include `AGENTS.md` updates in commits that modify workflows or coding standards.
|
|
235
|
+
|
|
236
|
+
### Packaging the extension
|
|
237
|
+
|
|
238
|
+
See [RELEASE](RELEASE.md)
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
2
|
+
import { IChatCommandProvider, IInputModel, ChatCommand } from '@jupyter/chat';
|
|
3
|
+
/**
|
|
4
|
+
* A command provider that provides completions for slash commands and handles
|
|
5
|
+
* slash command calls.
|
|
6
|
+
*
|
|
7
|
+
* - Slash commands are intended for "chat-level" operations that aren't
|
|
8
|
+
* specific to any persona.
|
|
9
|
+
*
|
|
10
|
+
* - Slash commands may only appear one-at-a-time, and only do something if the
|
|
11
|
+
* first word of the input specifies a slash command `/{slash-command-id}`.
|
|
12
|
+
*
|
|
13
|
+
* - Note: In v2, slash commands were reserved for specific tasks like
|
|
14
|
+
* 'generate' or 'learn'. But because tasks are handled by AI personas via agent
|
|
15
|
+
* tools in v3, slash commands in v3 are reserved for "chat-level" operations
|
|
16
|
+
* that are not specific to an AI persona.
|
|
17
|
+
*/
|
|
18
|
+
export declare class SlashCommandProvider implements IChatCommandProvider {
|
|
19
|
+
id: string;
|
|
20
|
+
/**
|
|
21
|
+
* Regex that matches a potential slash command. The first capturing group
|
|
22
|
+
* captures the ID of the slash command. Slash command IDs may be any
|
|
23
|
+
* combination of: `\`, `-`.
|
|
24
|
+
*/
|
|
25
|
+
_regex: RegExp;
|
|
26
|
+
constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Returns slash command completions for the current input.
|
|
29
|
+
*/
|
|
30
|
+
listCommandCompletions(inputModel: IInputModel): Promise<ChatCommand[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the set of mention names that have already been @-mentioned in the
|
|
33
|
+
* input.
|
|
34
|
+
*/
|
|
35
|
+
_getExistingMentions(inputModel: IInputModel): Set<string>;
|
|
36
|
+
onSubmit(inputModel: IInputModel): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export declare const slashCommandPlugin: JupyterFrontEndPlugin<void>;
|
|
39
|
+
export default slashCommandPlugin;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { IChatCommandRegistry } from '@jupyter/chat';
|
|
2
|
+
import { getAcpSlashCommands } from './request';
|
|
3
|
+
const SLASH_COMMAND_PROVIDER_ID = '@jupyter-ai/acp-client:slash-command-provider';
|
|
4
|
+
/**
|
|
5
|
+
* A command provider that provides completions for slash commands and handles
|
|
6
|
+
* slash command calls.
|
|
7
|
+
*
|
|
8
|
+
* - Slash commands are intended for "chat-level" operations that aren't
|
|
9
|
+
* specific to any persona.
|
|
10
|
+
*
|
|
11
|
+
* - Slash commands may only appear one-at-a-time, and only do something if the
|
|
12
|
+
* first word of the input specifies a slash command `/{slash-command-id}`.
|
|
13
|
+
*
|
|
14
|
+
* - Note: In v2, slash commands were reserved for specific tasks like
|
|
15
|
+
* 'generate' or 'learn'. But because tasks are handled by AI personas via agent
|
|
16
|
+
* tools in v3, slash commands in v3 are reserved for "chat-level" operations
|
|
17
|
+
* that are not specific to an AI persona.
|
|
18
|
+
*/
|
|
19
|
+
export class SlashCommandProvider {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.id = SLASH_COMMAND_PROVIDER_ID;
|
|
22
|
+
/**
|
|
23
|
+
* Regex that matches a potential slash command. The first capturing group
|
|
24
|
+
* captures the ID of the slash command. Slash command IDs may be any
|
|
25
|
+
* combination of: `\`, `-`.
|
|
26
|
+
*/
|
|
27
|
+
this._regex = /\/([\w-]*)/g;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns slash command completions for the current input.
|
|
31
|
+
*/
|
|
32
|
+
async listCommandCompletions(inputModel) {
|
|
33
|
+
var _a;
|
|
34
|
+
const currentWord = inputModel.currentWord || '';
|
|
35
|
+
const chatPath = inputModel.chatContext.name;
|
|
36
|
+
const existingMentions = this._getExistingMentions(inputModel);
|
|
37
|
+
// return early if current word doesn't start with '/'.
|
|
38
|
+
if (!currentWord.startsWith('/')) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
// return early if >1 persona is mentioned in the input. we never show ACP
|
|
42
|
+
// slash command suggestions in this case.
|
|
43
|
+
if (existingMentions.size > 1) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
// otherwise, call the `/ai/acp/slash_commands` endpoint to get slash
|
|
47
|
+
// command suggestions
|
|
48
|
+
let personaMentionName = null;
|
|
49
|
+
if (existingMentions.size) {
|
|
50
|
+
personaMentionName = (_a = existingMentions.values().next().value) !== null && _a !== void 0 ? _a : null;
|
|
51
|
+
}
|
|
52
|
+
const response = await getAcpSlashCommands(chatPath, personaMentionName);
|
|
53
|
+
const commandSuggestions = [];
|
|
54
|
+
for (const cmd of response) {
|
|
55
|
+
// continue if command does not match current word
|
|
56
|
+
if (!cmd.name.startsWith(currentWord)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
// otherwise add it as a suggestion
|
|
60
|
+
commandSuggestions.push({
|
|
61
|
+
name: cmd.name,
|
|
62
|
+
providerId: this.id,
|
|
63
|
+
description: cmd.description,
|
|
64
|
+
spaceOnAccept: true
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return commandSuggestions;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Returns the set of mention names that have already been @-mentioned in the
|
|
71
|
+
* input.
|
|
72
|
+
*/
|
|
73
|
+
_getExistingMentions(inputModel) {
|
|
74
|
+
var _a;
|
|
75
|
+
const matches = (_a = inputModel.value) === null || _a === void 0 ? void 0 : _a.matchAll(/@([\w-]*)/g);
|
|
76
|
+
const existingMentions = new Set();
|
|
77
|
+
for (const match of matches) {
|
|
78
|
+
const mention = match === null || match === void 0 ? void 0 : match[1];
|
|
79
|
+
// ignore if 1st group capturing the mention name is an empty string
|
|
80
|
+
if (!mention) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
existingMentions.add(mention);
|
|
84
|
+
}
|
|
85
|
+
return existingMentions;
|
|
86
|
+
}
|
|
87
|
+
async onSubmit(inputModel) {
|
|
88
|
+
// no-op. ACP slash commands are handled by the ACP agent
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export const slashCommandPlugin = {
|
|
93
|
+
id: SLASH_COMMAND_PROVIDER_ID,
|
|
94
|
+
description: 'Adds support for slash commands in Jupyter AI.',
|
|
95
|
+
autoStart: true,
|
|
96
|
+
requires: [IChatCommandRegistry],
|
|
97
|
+
activate: (app, registry) => {
|
|
98
|
+
registry.addProvider(new SlashCommandProvider());
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
export default slashCommandPlugin;
|
package/lib/request.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call the server extension
|
|
3
|
+
*
|
|
4
|
+
* @param endPoint API REST end point for the extension
|
|
5
|
+
* @param init Initial values for the request
|
|
6
|
+
* @returns The response body interpreted as JSON
|
|
7
|
+
*/
|
|
8
|
+
export declare function requestAPI<T>(endPoint?: string, init?: RequestInit): Promise<T>;
|
|
9
|
+
type AcpSlashCommand = {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function getAcpSlashCommands(chatPath: string, personaMentionName?: string | null): Promise<AcpSlashCommand[]>;
|
|
14
|
+
export {};
|
package/lib/request.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { URLExt } from '@jupyterlab/coreutils';
|
|
2
|
+
import { ServerConnection } from '@jupyterlab/services';
|
|
3
|
+
/**
|
|
4
|
+
* Call the server extension
|
|
5
|
+
*
|
|
6
|
+
* @param endPoint API REST end point for the extension
|
|
7
|
+
* @param init Initial values for the request
|
|
8
|
+
* @returns The response body interpreted as JSON
|
|
9
|
+
*/
|
|
10
|
+
export async function requestAPI(endPoint = '', init = {}) {
|
|
11
|
+
// Make request to Jupyter API
|
|
12
|
+
const settings = ServerConnection.makeSettings();
|
|
13
|
+
const requestUrl = URLExt.join(settings.baseUrl, 'ai/acp', // our server extension's API namespace
|
|
14
|
+
endPoint);
|
|
15
|
+
let response;
|
|
16
|
+
try {
|
|
17
|
+
response = await ServerConnection.makeRequest(requestUrl, init, settings);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw new ServerConnection.NetworkError(error);
|
|
21
|
+
}
|
|
22
|
+
let data = await response.text();
|
|
23
|
+
if (data.length > 0) {
|
|
24
|
+
try {
|
|
25
|
+
data = JSON.parse(data);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.log('Not a JSON response body.', response);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new ServerConnection.ResponseError(response, data.message || data);
|
|
33
|
+
}
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
export async function getAcpSlashCommands(chatPath, personaMentionName = null) {
|
|
37
|
+
let response;
|
|
38
|
+
try {
|
|
39
|
+
if (personaMentionName === null) {
|
|
40
|
+
response = await requestAPI(`/slash_commands?chat_path=${chatPath}`);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
response = await requestAPI(`/slash_commands/${personaMentionName}?chat_path=${chatPath}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
console.warn('Error retrieving ACP slash commands: ', e);
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
return response.commands;
|
|
51
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jupyter-ai/acp-client",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "The ACP client for Jupyter AI, allowing for ACP agents to be used in JupyterLab",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"jupyter",
|
|
7
|
+
"jupyterlab",
|
|
8
|
+
"jupyterlab-extension"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/jupyter-ai-contrib/jupyter-ai-acp-client",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/jupyter-ai-contrib/jupyter-ai-acp-client/issues"
|
|
13
|
+
},
|
|
14
|
+
"license": "BSD-3-Clause",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Project Jupyter",
|
|
17
|
+
"email": "jupyter@googlegroups.com"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
|
|
21
|
+
"style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
|
|
22
|
+
"src/**/*.{ts,tsx}"
|
|
23
|
+
],
|
|
24
|
+
"main": "lib/index.js",
|
|
25
|
+
"types": "lib/index.d.ts",
|
|
26
|
+
"style": "style/index.css",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/jupyter-ai-contrib/jupyter-ai-acp-client.git"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "jlpm build:lib && jlpm build:labextension:dev",
|
|
33
|
+
"build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension",
|
|
34
|
+
"build:labextension": "jupyter labextension build .",
|
|
35
|
+
"build:labextension:dev": "jupyter labextension build --development True .",
|
|
36
|
+
"build:lib": "tsc --sourceMap",
|
|
37
|
+
"build:lib:prod": "tsc",
|
|
38
|
+
"clean": "jlpm clean:lib",
|
|
39
|
+
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
|
|
40
|
+
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
|
|
41
|
+
"clean:labextension": "rimraf jupyter_ai_acp_client/labextension jupyter_ai_acp_client/_version.py",
|
|
42
|
+
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
|
|
43
|
+
"eslint": "jlpm eslint:check --fix",
|
|
44
|
+
"eslint:check": "eslint . --cache --ext .ts,.tsx",
|
|
45
|
+
"install:extension": "jlpm build",
|
|
46
|
+
"lint": "jlpm stylelint && jlpm prettier && jlpm eslint",
|
|
47
|
+
"lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check",
|
|
48
|
+
"prettier": "jlpm prettier:base --write --list-different",
|
|
49
|
+
"prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
|
|
50
|
+
"prettier:check": "jlpm prettier:base --check",
|
|
51
|
+
"stylelint": "jlpm stylelint:check --fix",
|
|
52
|
+
"stylelint:check": "stylelint --cache \"style/**/*.css\"",
|
|
53
|
+
"test": "jest --coverage",
|
|
54
|
+
"watch": "run-p watch:src watch:labextension",
|
|
55
|
+
"watch:src": "tsc -w --sourceMap",
|
|
56
|
+
"watch:labextension": "jupyter labextension watch ."
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@jupyter/chat": "^0.17.0",
|
|
60
|
+
"@jupyterlab/application": "^4.0.0",
|
|
61
|
+
"@jupyterlab/coreutils": "^6.0.0",
|
|
62
|
+
"@jupyterlab/services": "^7.0.0"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@jupyterlab/builder": "^4.0.0",
|
|
66
|
+
"@jupyterlab/testutils": "^4.0.0",
|
|
67
|
+
"@types/jest": "^29.2.0",
|
|
68
|
+
"@types/json-schema": "^7.0.11",
|
|
69
|
+
"@types/react": "^18.0.26",
|
|
70
|
+
"@types/react-addons-linked-state-mixin": "^0.14.22",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
|
72
|
+
"@typescript-eslint/parser": "^6.1.0",
|
|
73
|
+
"css-loader": "^6.7.1",
|
|
74
|
+
"eslint": "^8.36.0",
|
|
75
|
+
"eslint-config-prettier": "^8.8.0",
|
|
76
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
77
|
+
"jest": "^29.2.0",
|
|
78
|
+
"mkdirp": "^1.0.3",
|
|
79
|
+
"npm-run-all2": "^7.0.1",
|
|
80
|
+
"prettier": "^3.0.0",
|
|
81
|
+
"rimraf": "^5.0.1",
|
|
82
|
+
"source-map-loader": "^1.0.2",
|
|
83
|
+
"style-loader": "^3.3.1",
|
|
84
|
+
"stylelint": "^15.10.1",
|
|
85
|
+
"stylelint-config-recommended": "^13.0.0",
|
|
86
|
+
"stylelint-config-standard": "^34.0.0",
|
|
87
|
+
"stylelint-csstree-validator": "^3.0.0",
|
|
88
|
+
"stylelint-prettier": "^4.0.0",
|
|
89
|
+
"typescript": "~5.5.4",
|
|
90
|
+
"yjs": "^13.5.0"
|
|
91
|
+
},
|
|
92
|
+
"resolutions": {
|
|
93
|
+
"lib0": "0.2.111"
|
|
94
|
+
},
|
|
95
|
+
"sideEffects": [
|
|
96
|
+
"style/*.css",
|
|
97
|
+
"style/index.js"
|
|
98
|
+
],
|
|
99
|
+
"styleModule": "style/index.js",
|
|
100
|
+
"publishConfig": {
|
|
101
|
+
"access": "public"
|
|
102
|
+
},
|
|
103
|
+
"jupyterlab": {
|
|
104
|
+
"discovery": {
|
|
105
|
+
"server": {
|
|
106
|
+
"managers": [
|
|
107
|
+
"pip"
|
|
108
|
+
],
|
|
109
|
+
"base": {
|
|
110
|
+
"name": "jupyter_ai_acp_client"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"extension": true,
|
|
115
|
+
"outputDir": "jupyter_ai_acp_client/labextension",
|
|
116
|
+
"sharedPackages": {
|
|
117
|
+
"@jupyter/chat": {
|
|
118
|
+
"bundled": false,
|
|
119
|
+
"singleton": true
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"eslintIgnore": [
|
|
124
|
+
"node_modules",
|
|
125
|
+
"dist",
|
|
126
|
+
"coverage",
|
|
127
|
+
"**/*.d.ts",
|
|
128
|
+
"tests",
|
|
129
|
+
"**/__tests__",
|
|
130
|
+
"ui-tests"
|
|
131
|
+
],
|
|
132
|
+
"eslintConfig": {
|
|
133
|
+
"extends": [
|
|
134
|
+
"eslint:recommended",
|
|
135
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
136
|
+
"plugin:@typescript-eslint/recommended",
|
|
137
|
+
"plugin:prettier/recommended"
|
|
138
|
+
],
|
|
139
|
+
"parser": "@typescript-eslint/parser",
|
|
140
|
+
"parserOptions": {
|
|
141
|
+
"project": "tsconfig.json",
|
|
142
|
+
"sourceType": "module"
|
|
143
|
+
},
|
|
144
|
+
"plugins": [
|
|
145
|
+
"@typescript-eslint"
|
|
146
|
+
],
|
|
147
|
+
"rules": {
|
|
148
|
+
"@typescript-eslint/naming-convention": [
|
|
149
|
+
"error",
|
|
150
|
+
{
|
|
151
|
+
"selector": "interface",
|
|
152
|
+
"format": [
|
|
153
|
+
"PascalCase"
|
|
154
|
+
],
|
|
155
|
+
"custom": {
|
|
156
|
+
"regex": "^I[A-Z]",
|
|
157
|
+
"match": true
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"@typescript-eslint/no-unused-vars": [
|
|
162
|
+
"warn",
|
|
163
|
+
{
|
|
164
|
+
"args": "none"
|
|
165
|
+
}
|
|
166
|
+
],
|
|
167
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
168
|
+
"@typescript-eslint/no-namespace": "off",
|
|
169
|
+
"@typescript-eslint/no-use-before-define": "off",
|
|
170
|
+
"@typescript-eslint/quotes": [
|
|
171
|
+
"error",
|
|
172
|
+
"single",
|
|
173
|
+
{
|
|
174
|
+
"avoidEscape": true,
|
|
175
|
+
"allowTemplateLiterals": false
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
"curly": [
|
|
179
|
+
"error",
|
|
180
|
+
"all"
|
|
181
|
+
],
|
|
182
|
+
"eqeqeq": "error",
|
|
183
|
+
"prefer-arrow-callback": "error"
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"prettier": {
|
|
187
|
+
"singleQuote": true,
|
|
188
|
+
"trailingComma": "none",
|
|
189
|
+
"arrowParens": "avoid",
|
|
190
|
+
"endOfLine": "auto",
|
|
191
|
+
"overrides": [
|
|
192
|
+
{
|
|
193
|
+
"files": "package.json",
|
|
194
|
+
"options": {
|
|
195
|
+
"tabWidth": 4
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
"stylelint": {
|
|
201
|
+
"extends": [
|
|
202
|
+
"stylelint-config-recommended",
|
|
203
|
+
"stylelint-config-standard",
|
|
204
|
+
"stylelint-prettier/recommended"
|
|
205
|
+
],
|
|
206
|
+
"plugins": [
|
|
207
|
+
"stylelint-csstree-validator"
|
|
208
|
+
],
|
|
209
|
+
"rules": {
|
|
210
|
+
"csstree/validator": true,
|
|
211
|
+
"property-no-vendor-prefix": null,
|
|
212
|
+
"selector-class-pattern": "^([a-z][A-z\\d]*)(-[A-z\\d]+)*$",
|
|
213
|
+
"selector-no-vendor-prefix": null,
|
|
214
|
+
"value-no-vendor-prefix": null
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
// JupyterFrontEnd,
|
|
3
|
+
JupyterFrontEndPlugin
|
|
4
|
+
} from '@jupyterlab/application';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
IChatCommandProvider,
|
|
8
|
+
IChatCommandRegistry,
|
|
9
|
+
IInputModel,
|
|
10
|
+
ChatCommand
|
|
11
|
+
} from '@jupyter/chat';
|
|
12
|
+
|
|
13
|
+
import { getAcpSlashCommands } from './request';
|
|
14
|
+
|
|
15
|
+
const SLASH_COMMAND_PROVIDER_ID =
|
|
16
|
+
'@jupyter-ai/acp-client:slash-command-provider';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A command provider that provides completions for slash commands and handles
|
|
20
|
+
* slash command calls.
|
|
21
|
+
*
|
|
22
|
+
* - Slash commands are intended for "chat-level" operations that aren't
|
|
23
|
+
* specific to any persona.
|
|
24
|
+
*
|
|
25
|
+
* - Slash commands may only appear one-at-a-time, and only do something if the
|
|
26
|
+
* first word of the input specifies a slash command `/{slash-command-id}`.
|
|
27
|
+
*
|
|
28
|
+
* - Note: In v2, slash commands were reserved for specific tasks like
|
|
29
|
+
* 'generate' or 'learn'. But because tasks are handled by AI personas via agent
|
|
30
|
+
* tools in v3, slash commands in v3 are reserved for "chat-level" operations
|
|
31
|
+
* that are not specific to an AI persona.
|
|
32
|
+
*/
|
|
33
|
+
export class SlashCommandProvider implements IChatCommandProvider {
|
|
34
|
+
public id: string = SLASH_COMMAND_PROVIDER_ID;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Regex that matches a potential slash command. The first capturing group
|
|
38
|
+
* captures the ID of the slash command. Slash command IDs may be any
|
|
39
|
+
* combination of: `\`, `-`.
|
|
40
|
+
*/
|
|
41
|
+
_regex: RegExp = /\/([\w-]*)/g;
|
|
42
|
+
|
|
43
|
+
constructor() {}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns slash command completions for the current input.
|
|
47
|
+
*/
|
|
48
|
+
async listCommandCompletions(
|
|
49
|
+
inputModel: IInputModel
|
|
50
|
+
): Promise<ChatCommand[]> {
|
|
51
|
+
const currentWord = inputModel.currentWord || '';
|
|
52
|
+
const chatPath = inputModel.chatContext.name;
|
|
53
|
+
const existingMentions = this._getExistingMentions(inputModel);
|
|
54
|
+
|
|
55
|
+
// return early if current word doesn't start with '/'.
|
|
56
|
+
if (!currentWord.startsWith('/')) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// return early if >1 persona is mentioned in the input. we never show ACP
|
|
61
|
+
// slash command suggestions in this case.
|
|
62
|
+
if (existingMentions.size > 1) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// otherwise, call the `/ai/acp/slash_commands` endpoint to get slash
|
|
67
|
+
// command suggestions
|
|
68
|
+
let personaMentionName: string | null = null;
|
|
69
|
+
if (existingMentions.size) {
|
|
70
|
+
personaMentionName = existingMentions.values().next().value ?? null;
|
|
71
|
+
}
|
|
72
|
+
const response = await getAcpSlashCommands(chatPath, personaMentionName);
|
|
73
|
+
const commandSuggestions: ChatCommand[] = [];
|
|
74
|
+
for (const cmd of response) {
|
|
75
|
+
// continue if command does not match current word
|
|
76
|
+
if (!cmd.name.startsWith(currentWord)) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// otherwise add it as a suggestion
|
|
81
|
+
commandSuggestions.push({
|
|
82
|
+
name: cmd.name,
|
|
83
|
+
providerId: this.id,
|
|
84
|
+
description: cmd.description,
|
|
85
|
+
spaceOnAccept: true
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return commandSuggestions;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Returns the set of mention names that have already been @-mentioned in the
|
|
94
|
+
* input.
|
|
95
|
+
*/
|
|
96
|
+
_getExistingMentions(inputModel: IInputModel): Set<string> {
|
|
97
|
+
const matches = inputModel.value?.matchAll(/@([\w-]*)/g);
|
|
98
|
+
const existingMentions = new Set<string>();
|
|
99
|
+
for (const match of matches) {
|
|
100
|
+
const mention = match?.[1];
|
|
101
|
+
// ignore if 1st group capturing the mention name is an empty string
|
|
102
|
+
if (!mention) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
existingMentions.add(mention);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return existingMentions;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async onSubmit(inputModel: IInputModel): Promise<void> {
|
|
112
|
+
// no-op. ACP slash commands are handled by the ACP agent
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const slashCommandPlugin: JupyterFrontEndPlugin<void> = {
|
|
118
|
+
id: SLASH_COMMAND_PROVIDER_ID,
|
|
119
|
+
description: 'Adds support for slash commands in Jupyter AI.',
|
|
120
|
+
autoStart: true,
|
|
121
|
+
requires: [IChatCommandRegistry],
|
|
122
|
+
activate: (app, registry: IChatCommandRegistry) => {
|
|
123
|
+
registry.addProvider(new SlashCommandProvider());
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export default slashCommandPlugin;
|
package/src/request.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { URLExt } from '@jupyterlab/coreutils';
|
|
2
|
+
|
|
3
|
+
import { ServerConnection } from '@jupyterlab/services';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Call the server extension
|
|
7
|
+
*
|
|
8
|
+
* @param endPoint API REST end point for the extension
|
|
9
|
+
* @param init Initial values for the request
|
|
10
|
+
* @returns The response body interpreted as JSON
|
|
11
|
+
*/
|
|
12
|
+
export async function requestAPI<T>(
|
|
13
|
+
endPoint = '',
|
|
14
|
+
init: RequestInit = {}
|
|
15
|
+
): Promise<T> {
|
|
16
|
+
// Make request to Jupyter API
|
|
17
|
+
const settings = ServerConnection.makeSettings();
|
|
18
|
+
const requestUrl = URLExt.join(
|
|
19
|
+
settings.baseUrl,
|
|
20
|
+
'ai/acp', // our server extension's API namespace
|
|
21
|
+
endPoint
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
let response: Response;
|
|
25
|
+
try {
|
|
26
|
+
response = await ServerConnection.makeRequest(requestUrl, init, settings);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw new ServerConnection.NetworkError(error as any);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let data: any = await response.text();
|
|
32
|
+
|
|
33
|
+
if (data.length > 0) {
|
|
34
|
+
try {
|
|
35
|
+
data = JSON.parse(data);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.log('Not a JSON response body.', response);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!response.ok) {
|
|
42
|
+
throw new ServerConnection.ResponseError(response, data.message || data);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type AcpSlashCommand = {
|
|
49
|
+
name: string;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type AcpSlashCommandsResponse = {
|
|
54
|
+
commands: AcpSlashCommand[];
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export async function getAcpSlashCommands(
|
|
58
|
+
chatPath: string,
|
|
59
|
+
personaMentionName: string | null = null
|
|
60
|
+
): Promise<AcpSlashCommand[]> {
|
|
61
|
+
let response: AcpSlashCommandsResponse;
|
|
62
|
+
try {
|
|
63
|
+
if (personaMentionName === null) {
|
|
64
|
+
response = await requestAPI(`/slash_commands?chat_path=${chatPath}`);
|
|
65
|
+
} else {
|
|
66
|
+
response = await requestAPI(
|
|
67
|
+
`/slash_commands/${personaMentionName}?chat_path=${chatPath}`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
} catch (e) {
|
|
71
|
+
console.warn('Error retrieving ACP slash commands: ', e);
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return response.commands;
|
|
76
|
+
}
|
package/style/base.css
ADDED
package/style/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import url('base.css');
|
package/style/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './base.css';
|