jupyterlab_ai_code_assistants_extension 0.6.15
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 +44 -0
- package/lib/core/colour.d.ts +57 -0
- package/lib/core/colour.js +190 -0
- package/lib/core/icons.d.ts +12 -0
- package/lib/core/icons.js +99 -0
- package/lib/core/modes.d.ts +13 -0
- package/lib/core/modes.js +36 -0
- package/lib/core/panel.d.ts +233 -0
- package/lib/core/panel.js +1673 -0
- package/lib/core/popup.d.ts +40 -0
- package/lib/core/popup.js +404 -0
- package/lib/core/registry.d.ts +24 -0
- package/lib/core/registry.js +48 -0
- package/lib/core/request.d.ts +25 -0
- package/lib/core/request.js +64 -0
- package/lib/core/terminals.d.ts +129 -0
- package/lib/core/terminals.js +344 -0
- package/lib/core/types.d.ts +269 -0
- package/lib/core/types.js +6 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +277 -0
- package/lib/providers/claude.d.ts +3 -0
- package/lib/providers/claude.js +88 -0
- package/lib/providers/codex.d.ts +3 -0
- package/lib/providers/codex.js +79 -0
- package/lib/providers/gemini.d.ts +2 -0
- package/lib/providers/gemini.js +73 -0
- package/lib/providers/index.d.ts +3 -0
- package/lib/providers/index.js +16 -0
- package/lib/providers/kimi.d.ts +23 -0
- package/lib/providers/kimi.js +139 -0
- package/package.json +169 -0
- package/schema/plugin.json +93 -0
- package/src/__tests__/colour.spec.ts +153 -0
- package/src/__tests__/core-neutrality.spec.ts +86 -0
- package/src/__tests__/labels.spec.ts +89 -0
- package/src/__tests__/launch-mode.spec.ts +53 -0
- package/src/__tests__/registry.spec.ts +178 -0
- package/src/core/colour.ts +224 -0
- package/src/core/icons.ts +121 -0
- package/src/core/modes.ts +45 -0
- package/src/core/panel.ts +2020 -0
- package/src/core/popup.ts +475 -0
- package/src/core/registry.ts +60 -0
- package/src/core/request.ts +96 -0
- package/src/core/terminals.ts +446 -0
- package/src/core/types.ts +305 -0
- package/src/index.ts +356 -0
- package/src/providers/claude.ts +102 -0
- package/src/providers/codex.ts +89 -0
- package/src/providers/gemini.ts +80 -0
- package/src/providers/index.ts +21 -0
- package/src/providers/kimi.ts +155 -0
- package/style/base.css +888 -0
- package/style/index.css +1 -0
- package/style/index.js +1 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { JupyterFrontEnd } from '@jupyterlab/application';
|
|
2
|
+
import { IDefaultFileBrowser } from '@jupyterlab/filebrowser';
|
|
3
|
+
import { ITerminalTracker } from '@jupyterlab/terminal';
|
|
4
|
+
import { IColourfulTabs } from 'jupyterlab_colourful_tab_extension';
|
|
5
|
+
import { Message } from '@lumino/messaging';
|
|
6
|
+
import { Widget } from '@lumino/widgets';
|
|
7
|
+
import { IProviderDescriptor, IProviderHooks } from './types';
|
|
8
|
+
export type PresentationMode = 'name' | 'path';
|
|
9
|
+
/** Widget id for one provider's panel - what the layout restorer keys on. */
|
|
10
|
+
export declare function panelWidgetId(providerId: string): string;
|
|
11
|
+
/** Command id for one provider's action. Namespaced per provider, so two
|
|
12
|
+
* panels never collide in a shared registry. */
|
|
13
|
+
export declare function commandId(providerId: string, action: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* One assistant's sessions panel.
|
|
16
|
+
*
|
|
17
|
+
* Layout, filtering, polling, menus, the popup and the launch flow are shared
|
|
18
|
+
* by every provider. Everything that differs enters through the descriptor's
|
|
19
|
+
* capability flags or through the provider's hooks - this class never asks
|
|
20
|
+
* which assistant it is rendering.
|
|
21
|
+
*/
|
|
22
|
+
export declare class AssistantSessionsPanel extends Widget {
|
|
23
|
+
constructor(options: AssistantSessionsPanel.IOptions);
|
|
24
|
+
get descriptor(): IProviderDescriptor;
|
|
25
|
+
dispose(): void;
|
|
26
|
+
refresh(): void;
|
|
27
|
+
/** Label rows by name (the session name the assistant records) or by path. */
|
|
28
|
+
setPresentationMode(mode: PresentationMode): void;
|
|
29
|
+
/** How many rows the Recent section displays. */
|
|
30
|
+
setRecentLimit(n: number): void;
|
|
31
|
+
/** Current values of this provider's launch modes, read from settings. Each
|
|
32
|
+
* key is an `ILaunchMode.id` in the assistant's own terminology. */
|
|
33
|
+
setModes(modes: Record<string, boolean | string>): void;
|
|
34
|
+
setColouredTabs(on: boolean): void;
|
|
35
|
+
protected onAfterShow(_msg: Message): void;
|
|
36
|
+
protected onBeforeHide(_msg: Message): void;
|
|
37
|
+
protected onCloseRequest(msg: Message): void;
|
|
38
|
+
private _buildShell;
|
|
39
|
+
/** Show / hide the filter input. Hiding also clears the active filter, so
|
|
40
|
+
* the user never returns to an "invisible" filter narrowing the rows. */
|
|
41
|
+
private _toggleFilterBar;
|
|
42
|
+
/** Show the clear button only while the field has text - an "x" over an
|
|
43
|
+
* empty box is noise, and there is nothing to clear. */
|
|
44
|
+
private _syncSearchClear;
|
|
45
|
+
/** Normalise for filter comparison: NFD-decompose, strip combining marks,
|
|
46
|
+
* lowercase, and collapse separators entirely - so "foo-bar", "foo_bar",
|
|
47
|
+
* "foo bar" and "Foo Bar" all compare equal as "foobar". */
|
|
48
|
+
private _normalize;
|
|
49
|
+
/** Fuzzy match at a 95% threshold: substring on normalised strings, with up
|
|
50
|
+
* to 5% Levenshtein tolerance. For short queries the budget rounds to zero,
|
|
51
|
+
* so behaviour is substring-only there; the relaxation only reaches a full
|
|
52
|
+
* edit at 10+ characters. */
|
|
53
|
+
private _fuzzyMatch;
|
|
54
|
+
private _levenshtein;
|
|
55
|
+
private _matchesFilter;
|
|
56
|
+
/** Raise or clear the full-panel refresh veil. Only the explicit refresh
|
|
57
|
+
* path calls this; the background poll fetches silently so the panel never
|
|
58
|
+
* flashes a spinner on its own. */
|
|
59
|
+
private _setLoading;
|
|
60
|
+
/** Inline, per-panel error. One provider's unreachable server must leave the
|
|
61
|
+
* other panels alone, so nothing here is modal. */
|
|
62
|
+
private _setInlineError;
|
|
63
|
+
private _showError;
|
|
64
|
+
/** A one-shot action failed. Nothing retries it, so the copy names what did
|
|
65
|
+
* not happen instead of promising a retry the poll loop alone performs. */
|
|
66
|
+
private _showActionError;
|
|
67
|
+
private _logError;
|
|
68
|
+
private _fetch;
|
|
69
|
+
private _toggleFavourite;
|
|
70
|
+
private get _disposalVerb();
|
|
71
|
+
private _removeProject;
|
|
72
|
+
private _cleanupParallel;
|
|
73
|
+
/** This provider's launch-mode token for one action - see
|
|
74
|
+
* `resolveLaunchMode` for the precedence rule. */
|
|
75
|
+
private _launchMode;
|
|
76
|
+
private _openSession;
|
|
77
|
+
/** Absolute path of the file browser's current folder; the server root when
|
|
78
|
+
* no file browser is available. */
|
|
79
|
+
private _currentFolder;
|
|
80
|
+
/** Start a brand-new conversation in the file browser's current folder. */
|
|
81
|
+
private _newSession;
|
|
82
|
+
/**
|
|
83
|
+
* Branch the active row's current conversation, by the descriptor's
|
|
84
|
+
* `forkStrategy`.
|
|
85
|
+
*
|
|
86
|
+
* The three strategies differ only in who mints the new id and when it
|
|
87
|
+
* becomes knowable - so the shared part (ask for a name, launch a terminal
|
|
88
|
+
* on the fork, inherit the parent's tint, surface the branch) lives here
|
|
89
|
+
* once, and the strategy decides the payload and the discovery.
|
|
90
|
+
*/
|
|
91
|
+
private _branchSession;
|
|
92
|
+
/** The CLI forks from a flag pair and takes the new id from us, so the fork
|
|
93
|
+
* is known before it exists. Its store entry is written lazily, on the first
|
|
94
|
+
* turn, so the branch is watched for rather than expected at once. */
|
|
95
|
+
private _branchByNativeFlag;
|
|
96
|
+
/** The CLI owns both the fork verb and the id, so the id has to be
|
|
97
|
+
* discovered: snapshot the branch ids first, then diff after launch. */
|
|
98
|
+
private _branchByNativeCommand;
|
|
99
|
+
/** The assistant has no fork at all: the server copies the store entry and
|
|
100
|
+
* answers with the new id, so the branch exists before the terminal opens
|
|
101
|
+
* and one refresh surfaces it - no watcher needed. */
|
|
102
|
+
private _branchByServerCopy;
|
|
103
|
+
/** Copy the parent's tint onto a fresh branch, unless the assistant owns
|
|
104
|
+
* conversation colours itself: that store refuses every write (the server
|
|
105
|
+
* answers 400), so the call would be one guaranteed-failing request per fork
|
|
106
|
+
* plus a tint that shows until the next reconcile drops it again. */
|
|
107
|
+
private _inheritColour;
|
|
108
|
+
/** Poll fast for a fork whose id we already know, then refresh once. The
|
|
109
|
+
* panel is never updated before the branch genuinely exists - it cannot list
|
|
110
|
+
* a store entry that has not been written. */
|
|
111
|
+
private _watchForBranch;
|
|
112
|
+
/** Poll fast for a fork whose id the CLI minted: whichever conversation the
|
|
113
|
+
* snapshot did not hold is the fork. It is then pinned as current (recency
|
|
114
|
+
* alone would not - the actively written parent overtakes it) and inherits
|
|
115
|
+
* the parent's tint. */
|
|
116
|
+
private _watchForNewBranch;
|
|
117
|
+
/** Make another conversation the row's current one. */
|
|
118
|
+
private _switchBranch;
|
|
119
|
+
/** Delete conversations of the active row's project. Resolves with the
|
|
120
|
+
* removed count, or null on a failure already reported to the user. */
|
|
121
|
+
private _deleteBranches;
|
|
122
|
+
private _fetchBranches;
|
|
123
|
+
/** Apply the presentation-mode setting. Basename collisions in name mode are
|
|
124
|
+
* resolved separately in `_disambiguate`. */
|
|
125
|
+
private _displayName;
|
|
126
|
+
private _basename;
|
|
127
|
+
/** Walk path tails until every name in a colliding group is unique. Name-mode
|
|
128
|
+
* labels are folder basenames, so two different projects can carry the same
|
|
129
|
+
* label; each colliding label is extended with as much of its parent path as
|
|
130
|
+
* it takes to tell them apart. */
|
|
131
|
+
private _disambiguate;
|
|
132
|
+
private _render;
|
|
133
|
+
private _renderSection;
|
|
134
|
+
private _renderRow;
|
|
135
|
+
/** Leading status dot, or a placeholder that reserves its column. Which
|
|
136
|
+
* states exist is a descriptor question, never an assistant question. */
|
|
137
|
+
private _renderIndicator;
|
|
138
|
+
private _lookupName;
|
|
139
|
+
private _buildRowTooltip;
|
|
140
|
+
private _displayPath;
|
|
141
|
+
/** Path relative to the JupyterLab server root (`''` for the root itself),
|
|
142
|
+
* or null when the folder lies outside it - in which case the file browser
|
|
143
|
+
* has no way to address it. */
|
|
144
|
+
private _pathUnderRoot;
|
|
145
|
+
private _formatRelativeTime;
|
|
146
|
+
/** Local `YYYY-MM-DD HH:MM` - the absolute reference the relative label
|
|
147
|
+
* cannot give. */
|
|
148
|
+
private _formatAbsoluteTime;
|
|
149
|
+
/** Branch entry display: conversation name plus short session id. Branches
|
|
150
|
+
* share a project path, so the name and id are all that tell them apart. The
|
|
151
|
+
* suffix is dropped when the label already IS the short id. */
|
|
152
|
+
private _branchDisplayName;
|
|
153
|
+
/** Menu-item label for a branch: display name, relative time, and a trailing
|
|
154
|
+
* marker when a live worker owns the conversation. The marker lives in the
|
|
155
|
+
* label rather than the icon, because both branch submenus need their icon
|
|
156
|
+
* slot for their own intent, and words are what assistive tech reads. */
|
|
157
|
+
private _branchMenuLabel;
|
|
158
|
+
private _setRefreshSpinning;
|
|
159
|
+
private _setActiveRow;
|
|
160
|
+
private _cmd;
|
|
161
|
+
/** Boolean launch modes that produce a menu variant - the assistant's own
|
|
162
|
+
* skip-approval switch, under the assistant's own name. */
|
|
163
|
+
private get _variantModes();
|
|
164
|
+
private _setupCommands;
|
|
165
|
+
private _buildMenus;
|
|
166
|
+
private _menu;
|
|
167
|
+
/** Rebuild the context menu's items. Lumino submenu items have no
|
|
168
|
+
* `isVisible` hook, so the menu is rebuilt per open and a branch submenu is
|
|
169
|
+
* inserted only when the row actually has branches - a capability the
|
|
170
|
+
* provider lacks is absent, not shown and disabled. */
|
|
171
|
+
private _rebuildContextMenu;
|
|
172
|
+
/** Open the row context menu, populating the branch submenus first when the
|
|
173
|
+
* project holds more than one conversation. A fetch failure opens the menu
|
|
174
|
+
* without them rather than not at all. */
|
|
175
|
+
private _openContextMenu;
|
|
176
|
+
private _openManagePopup;
|
|
177
|
+
/** The live-worker chip for a branch row, when the provider has workers at
|
|
178
|
+
* all. Returning null lets the popup fall back to its fork marker. */
|
|
179
|
+
private _bgBadgeFor;
|
|
180
|
+
private _startPolling;
|
|
181
|
+
private _stopPolling;
|
|
182
|
+
private readonly _app;
|
|
183
|
+
private readonly _descriptor;
|
|
184
|
+
private readonly _hooks;
|
|
185
|
+
private readonly _serverSettings;
|
|
186
|
+
private readonly _rootDir;
|
|
187
|
+
private readonly _deleteToTrash;
|
|
188
|
+
private readonly _fileBrowser;
|
|
189
|
+
private readonly _colours;
|
|
190
|
+
private readonly _terminals;
|
|
191
|
+
private readonly _expandedKey;
|
|
192
|
+
private readonly _removingPaths;
|
|
193
|
+
private _bodyEl;
|
|
194
|
+
private _loadingEl;
|
|
195
|
+
private _errorEl;
|
|
196
|
+
private _refreshBtn;
|
|
197
|
+
private _filterBtn;
|
|
198
|
+
private _searchEl;
|
|
199
|
+
private _searchWrapEl;
|
|
200
|
+
private _searchClearEl;
|
|
201
|
+
private _sessions;
|
|
202
|
+
private _expanded;
|
|
203
|
+
private _commands;
|
|
204
|
+
private _contextMenu;
|
|
205
|
+
private _switchSubmenu;
|
|
206
|
+
private _openBranchSubmenu;
|
|
207
|
+
private _branchSessionMenu;
|
|
208
|
+
private _newSessionMenu;
|
|
209
|
+
private _lastBranches;
|
|
210
|
+
private _lastBranchesCurrent;
|
|
211
|
+
private _activeSession;
|
|
212
|
+
private _activeRowEl;
|
|
213
|
+
private _pollHandle;
|
|
214
|
+
private _presentationMode;
|
|
215
|
+
private _recentLimit;
|
|
216
|
+
private _modes;
|
|
217
|
+
private _displayNames;
|
|
218
|
+
private _filter;
|
|
219
|
+
}
|
|
220
|
+
export declare namespace AssistantSessionsPanel {
|
|
221
|
+
interface IOptions {
|
|
222
|
+
app: JupyterFrontEnd;
|
|
223
|
+
descriptor: IProviderDescriptor;
|
|
224
|
+
hooks?: IProviderHooks;
|
|
225
|
+
/** JupyterLab's server root, for path display and file-browser hand-offs. */
|
|
226
|
+
rootDir: string;
|
|
227
|
+
/** JupyterLab's move-to-trash setting, so dialogs name the right outcome. */
|
|
228
|
+
deleteToTrash?: boolean;
|
|
229
|
+
terminalTracker?: ITerminalTracker | null;
|
|
230
|
+
fileBrowser?: IDefaultFileBrowser | null;
|
|
231
|
+
colourfulTabs?: IColourfulTabs | null;
|
|
232
|
+
}
|
|
233
|
+
}
|