@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/package.json CHANGED
@@ -1,261 +1,114 @@
1
1
  {
2
- "name": "@jupyterlite/ai",
3
- "version": "0.18.0",
4
- "description": "AI code completions and chat for JupyterLite",
5
- "keywords": [
6
- "jupyter",
7
- "jupyterlab",
8
- "jupyterlab-extension"
9
- ],
10
- "homepage": "https://github.com/jupyterlite/ai",
11
- "bugs": {
12
- "url": "https://github.com/jupyterlite/ai/issues"
13
- },
14
- "license": "BSD-3-Clause",
15
- "author": "JupyterLite Contributors",
16
- "files": [
17
- "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf,md}",
18
- "style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
19
- "src/**/*.{ts,tsx}",
20
- "schema/*.json"
21
- ],
22
- "main": "lib/index.js",
23
- "types": "lib/index.d.ts",
24
- "style": "style/index.css",
25
- "repository": {
26
- "type": "git",
27
- "url": "https://github.com/jupyterlite/ai.git"
28
- },
29
- "scripts": {
30
- "build": "jlpm build:lib && jlpm build:labextension:dev",
31
- "build:dev": "jlpm build:lib && jlpm build:labextension:dev",
32
- "build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension",
33
- "build:labextension": "jupyter labextension build .",
34
- "build:labextension:dev": "jupyter labextension build --development True .",
35
- "build:lib": "tsc --sourceMap",
36
- "build:lib:prod": "tsc",
37
- "clean": "jlpm clean:lib",
38
- "clean:lib": "rimraf lib tsconfig.tsbuildinfo",
39
- "clean:lintcache": "rimraf .eslintcache .stylelintcache",
40
- "clean:labextension": "rimraf jupyterlite_ai/labextension jupyterlite_ai/_version.py",
41
- "clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
42
- "eslint": "jlpm eslint:check --fix",
43
- "eslint:check": "eslint . --cache --ext .ts,.tsx",
44
- "install:extension": "jlpm build",
45
- "lint": "jlpm stylelint && jlpm prettier && jlpm eslint",
46
- "lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check",
47
- "prettier": "jlpm prettier:base --write --list-different",
48
- "prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
49
- "prettier:check": "jlpm prettier:base --check",
50
- "stylelint": "jlpm stylelint:check --fix",
51
- "stylelint:check": "stylelint --cache \"style/**/*.css\"",
52
- "watch": "run-p watch:src watch:labextension",
53
- "watch:src": "tsc -w --sourceMap",
54
- "watch:labextension": "jupyter labextension watch .",
55
- "docs": "jupyter book start",
56
- "docs:build": "sed -e 's/\\[@/[/g' -e 's/@/\\@/g' CHANGELOG.md > docs/_changelog_content.md && jupyter book build --html",
57
- "sync:model-info": "node scripts/sync-model-info.mjs && prettier --write src/providers/generated-model-info.ts && eslint --fix src/providers/generated-model-info.ts"
58
- },
59
- "dependencies": {
60
- "@ai-sdk/anthropic": "^3.0.58",
61
- "@ai-sdk/google": "^3.0.43",
62
- "@ai-sdk/mcp": "^1.0.25",
63
- "@ai-sdk/mistral": "^3.0.24",
64
- "@ai-sdk/openai": "^3.0.41",
65
- "@ai-sdk/openai-compatible": "^2.0.35",
66
- "@jupyter/chat": "^0.21.1",
67
- "@jupyterlab/application": "^4.0.0",
68
- "@jupyterlab/apputils": "^4.5.6",
69
- "@jupyterlab/cells": "^4.4.6",
70
- "@jupyterlab/completer": "^4.0.0",
71
- "@jupyterlab/coreutils": "^6.4.6",
72
- "@jupyterlab/docmanager": "^4.4.6",
73
- "@jupyterlab/docregistry": "^4.4.6",
74
- "@jupyterlab/filebrowser": "^4.5.6",
75
- "@jupyterlab/fileeditor": "^4.4.6",
76
- "@jupyterlab/notebook": "^4.4.6",
77
- "@jupyterlab/rendermime": "^4.4.6",
78
- "@jupyterlab/services": "^7.4.6",
79
- "@jupyterlab/settingregistry": "^4.0.0",
80
- "@jupyterlab/statusbar": "^4.4.6",
81
- "@jupyterlab/ui-components": "^4.4.6",
82
- "@lumino/commands": "^2.3.2",
83
- "@lumino/coreutils": "^2.2.1",
84
- "@lumino/disposable": "^2.1.4",
85
- "@lumino/messaging": "^2.0.3",
86
- "@lumino/polling": "^2.1.4",
87
- "@lumino/signaling": "^2.1.4",
88
- "@lumino/widgets": "^2.7.1",
89
- "@mui/icons-material": "^7",
90
- "@mui/material": "^7",
91
- "ai": "^6.0.116",
92
- "jupyter-chat-components": "^0.5.0",
93
- "jupyter-secrets-manager": "^0.5.0",
94
- "yaml": "^2.8.1",
95
- "zod": "^4.3.6"
96
- },
97
- "devDependencies": {
98
- "@jupyterlab/builder": "^4.0.0",
99
- "@jupyterlab/testutils": "^4.0.0",
100
- "@types/json-schema": "^7.0.11",
101
- "@types/node": "^24.3.0",
102
- "@types/react": "^18.0.26",
103
- "@types/react-addons-linked-state-mixin": "^0.14.22",
104
- "@typescript-eslint/eslint-plugin": "^6.1.0",
105
- "@typescript-eslint/parser": "^6.1.0",
106
- "css-loader": "^6.7.1",
107
- "eslint": "^8.36.0",
108
- "eslint-config-prettier": "^8.8.0",
109
- "eslint-plugin-prettier": "^5.0.0",
110
- "npm-run-all2": "^7.0.1",
111
- "prettier": "^3.0.0",
112
- "rimraf": "^5.0.1",
113
- "source-map-loader": "^1.0.2",
114
- "style-loader": "^3.3.1",
115
- "stylelint": "^15.10.1",
116
- "stylelint-config-recommended": "^13.0.0",
117
- "stylelint-config-standard": "^34.0.0",
118
- "stylelint-csstree-validator": "^3.0.0",
119
- "stylelint-prettier": "^4.0.0",
120
- "typescript": "~5.8.0",
121
- "yjs": "^13.5.0"
122
- },
123
- "sideEffects": [
124
- "style/*.css",
125
- "style/index.js"
126
- ],
127
- "styleModule": "style/index.js",
128
- "publishConfig": {
129
- "access": "public"
130
- },
131
- "jupyterlab": {
132
- "extension": true,
133
- "outputDir": "jupyterlite_ai/labextension",
134
- "schemaDir": "schema",
135
- "sharedPackages": {
136
- "@jupyter/chat": {
137
- "bundled": true,
138
- "singleton": true
139
- },
140
- "jupyter-chat-components": {
141
- "bundled": false,
142
- "singleton": true
143
- }
144
- }
145
- },
146
- "eslintIgnore": [
147
- "node_modules",
148
- "dist",
149
- "coverage",
150
- "**/*.d.ts",
151
- "tests",
152
- "**/__tests__",
153
- "ui-tests",
154
- ".venv",
155
- "webpack.config.js"
156
- ],
157
- "eslintConfig": {
158
- "extends": [
159
- "eslint:recommended",
160
- "plugin:@typescript-eslint/eslint-recommended",
161
- "plugin:@typescript-eslint/recommended",
162
- "plugin:prettier/recommended"
163
- ],
164
- "parser": "@typescript-eslint/parser",
165
- "parserOptions": {
166
- "project": "tsconfig.json",
167
- "sourceType": "module"
168
- },
169
- "plugins": [
170
- "@typescript-eslint"
171
- ],
172
- "rules": {
173
- "@typescript-eslint/naming-convention": [
174
- "error",
175
- {
176
- "selector": "interface",
177
- "format": [
178
- "PascalCase"
179
- ],
180
- "custom": {
181
- "regex": "^I[A-Z]",
182
- "match": true
183
- }
184
- }
185
- ],
186
- "@typescript-eslint/no-unused-vars": [
187
- "warn",
188
- {
189
- "args": "none"
190
- }
191
- ],
192
- "@typescript-eslint/no-explicit-any": "off",
193
- "@typescript-eslint/no-namespace": "off",
194
- "@typescript-eslint/no-use-before-define": "off",
195
- "@typescript-eslint/quotes": [
196
- "error",
197
- "single",
198
- {
199
- "avoidEscape": true,
200
- "allowTemplateLiterals": false
201
- }
202
- ],
203
- "curly": [
204
- "error",
205
- "all"
206
- ],
207
- "eqeqeq": "error",
208
- "prefer-arrow-callback": "error",
209
- "no-restricted-imports": [
210
- "error",
211
- {
212
- "paths": [
213
- {
214
- "name": "@mui/icons-material",
215
- "message": "Please import icons using path imports, e.g. `import AddIcon from '@mui/icons-material/Add'`"
216
- }
217
- ],
218
- "patterns": [
219
- {
220
- "group": [
221
- "@mui/*/*/*"
222
- ],
223
- "message": "3rd level imports in mui are considered private"
224
- }
225
- ]
226
- }
227
- ]
228
- }
229
- },
230
- "prettier": {
231
- "singleQuote": true,
232
- "trailingComma": "none",
233
- "arrowParens": "avoid",
234
- "endOfLine": "auto",
235
- "overrides": [
236
- {
237
- "files": "package.json",
238
- "options": {
239
- "tabWidth": 4
240
- }
241
- }
242
- ]
243
- },
244
- "stylelint": {
245
- "extends": [
246
- "stylelint-config-recommended",
247
- "stylelint-config-standard",
248
- "stylelint-prettier/recommended"
249
- ],
250
- "plugins": [
251
- "stylelint-csstree-validator"
252
- ],
253
- "rules": {
254
- "csstree/validator": true,
255
- "property-no-vendor-prefix": null,
256
- "selector-class-pattern": "^([a-z][A-z\\d]*)(-[A-z\\d]+)*$|^Mui[A-Z]",
257
- "selector-no-vendor-prefix": null,
258
- "value-no-vendor-prefix": null
259
- }
2
+ "name": "@jupyterlite/ai",
3
+ "version": "0.19.0",
4
+ "description": "AI code completions and chat for JupyterLite",
5
+ "keywords": [
6
+ "jupyter",
7
+ "jupyterlab",
8
+ "jupyterlab-extension"
9
+ ],
10
+ "homepage": "https://github.com/jupyterlite/ai",
11
+ "bugs": {
12
+ "url": "https://github.com/jupyterlite/ai/issues"
13
+ },
14
+ "license": "BSD-3-Clause",
15
+ "author": "JupyterLite Contributors",
16
+ "files": [
17
+ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf,md}",
18
+ "style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
19
+ "src/**/*.{ts,tsx}",
20
+ "schema/*.json"
21
+ ],
22
+ "main": "lib/index.js",
23
+ "types": "lib/index.d.ts",
24
+ "style": "style/index.css",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/jupyterlite/ai.git",
28
+ "directory": "packages/ai"
29
+ },
30
+ "scripts": {
31
+ "build": "echo 'Building @jupyterlite/ai' && jlpm build:lib && jlpm build:labextension:dev",
32
+ "build:dev": "echo 'Building @jupyterlite/ai' && jlpm build:lib && jlpm build:labextension:dev",
33
+ "build:prod": "echo 'Building @jupyterlite/ai' && 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
+ "install:extension": "jlpm build",
41
+ "watch": "run-p watch:src watch:labextension",
42
+ "watch:src": "tsc -w --sourceMap",
43
+ "watch:labextension": "jupyter labextension watch ."
44
+ },
45
+ "dependencies": {
46
+ "@jupyter/chat": "^0.21.1",
47
+ "@jupyter/ydoc": "^3.1.0",
48
+ "@jupyterlab/application": "^4.5.8",
49
+ "@jupyterlab/apputils": "^4.6.8",
50
+ "@jupyterlab/completer": "^4.5.8",
51
+ "@jupyterlab/coreutils": "^6.5.8",
52
+ "@jupyterlab/docmanager": "^4.5.8",
53
+ "@jupyterlab/docregistry": "^4.5.8",
54
+ "@jupyterlab/filebrowser": "^4.5.8",
55
+ "@jupyterlab/nbformat": "^4.5.8",
56
+ "@jupyterlab/notebook": "^4.5.8",
57
+ "@jupyterlab/rendermime": "^4.5.8",
58
+ "@jupyterlab/services": "^7.5.8",
59
+ "@jupyterlab/settingregistry": "^4.5.8",
60
+ "@jupyterlab/statusbar": "^4.5.8",
61
+ "@jupyterlab/translation": "^4.5.8",
62
+ "@jupyterlab/ui-components": "^4.5.8",
63
+ "@jupyternaut/agent": "^0.19.0",
64
+ "@lumino/commands": "^2.3.2",
65
+ "@lumino/coreutils": "^2.2.1",
66
+ "@lumino/disposable": "^2.1.4",
67
+ "@lumino/polling": "^2.1.4",
68
+ "@lumino/signaling": "^2.1.4",
69
+ "@lumino/widgets": "^2.7.1",
70
+ "@mui/icons-material": "^7",
71
+ "@mui/material": "^7",
72
+ "ai": "^6.0.116",
73
+ "jupyter-chat-components": "^0.6.0",
74
+ "jupyter-secrets-manager": "^0.5.0",
75
+ "react": "^18.3.1",
76
+ "yaml": "^2.8.1"
77
+ },
78
+ "devDependencies": {
79
+ "@jupyterlab/builder": "^4.0.0",
80
+ "@jupyterlab/testutils": "^4.0.0",
81
+ "@types/json-schema": "^7.0.11",
82
+ "@types/node": "^24.3.0",
83
+ "@types/react": "^18.0.26",
84
+ "@types/react-addons-linked-state-mixin": "^0.14.22",
85
+ "css-loader": "^6.7.1",
86
+ "npm-run-all2": "^7.0.1",
87
+ "rimraf": "^5.0.1",
88
+ "source-map-loader": "^1.0.2",
89
+ "typescript": "~5.8.0"
90
+ },
91
+ "sideEffects": [
92
+ "style/*.css",
93
+ "style/index.js"
94
+ ],
95
+ "styleModule": "style/index.js",
96
+ "publishConfig": {
97
+ "access": "public"
98
+ },
99
+ "jupyterlab": {
100
+ "extension": true,
101
+ "outputDir": "../../jupyterlite_ai/labextension",
102
+ "schemaDir": "schema",
103
+ "sharedPackages": {
104
+ "@jupyter/chat": {
105
+ "bundled": true,
106
+ "singleton": true
107
+ },
108
+ "jupyter-chat-components": {
109
+ "bundled": false,
110
+ "singleton": true
111
+ }
260
112
  }
113
+ }
261
114
  }
@@ -1,9 +1,9 @@
1
+ import type { ISkillRegistry } from '@jupyternaut/agent';
1
2
  import { ChatCommand, IChatCommandProvider, IInputModel } from '@jupyter/chat';
2
-
3
3
  import { CommandRegistry } from '@lumino/commands';
4
4
 
5
5
  import { AIChatModel } from '../chat-model';
6
- import { CommandIds, ISkillRegistry } from '../tokens';
6
+ import { CommandIds } from '../tokens';
7
7
 
8
8
  export class SkillsCommandProvider implements IChatCommandProvider {
9
9
  constructor(options: SkillsCommandProvider.IOptions) {
@@ -1,3 +1,8 @@
1
+ import type {
2
+ IAgentManagerFactory,
3
+ IProviderRegistry,
4
+ IToolRegistry
5
+ } from '@jupyternaut/agent';
1
6
  import { ActiveCellManager } from '@jupyter/chat';
2
7
  import { IDocumentManager } from '@jupyterlab/docmanager';
3
8
  import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
@@ -5,13 +10,10 @@ import { Contents } from '@jupyterlab/services';
5
10
 
6
11
  import { AIChatModel } from './chat-model';
7
12
  import type {
8
- IAgentManagerFactory,
9
13
  IAIChatModel,
10
14
  IAISettingsModel,
11
15
  IChatModelHandler,
12
- ICreateChatOptions,
13
- IProviderRegistry,
14
- IToolRegistry
16
+ ICreateChatOptions
15
17
  } from './tokens';
16
18
 
17
19
  /**
package/src/chat-model.ts CHANGED
@@ -26,6 +26,14 @@ import { IRenderMime } from '@jupyterlab/rendermime';
26
26
 
27
27
  import { Contents } from '@jupyterlab/services';
28
28
 
29
+ import { AI_AVATAR } from '@jupyternaut/agent';
30
+
31
+ import type {
32
+ IAgentManager,
33
+ IProviderRegistry,
34
+ ITokenUsage
35
+ } from '@jupyternaut/agent';
36
+
29
37
  import { UUID } from '@lumino/coreutils';
30
38
 
31
39
  import { Debouncer } from '@lumino/polling';
@@ -34,21 +42,13 @@ import { ISignal, Signal } from '@lumino/signaling';
34
42
 
35
43
  import type { UserContent, ImagePart, FilePart, ModelMessage } from 'ai';
36
44
 
37
- import { AI_AVATAR } from './icons';
38
-
39
- import type {
40
- IAgentManager,
41
- IAIChatModel,
42
- IAISettingsModel,
43
- IProviderRegistry,
44
- ITokenUsage
45
- } from './tokens';
45
+ import type { IAIChatModel, IAISettingsModel } from './tokens';
46
46
 
47
47
  import {
48
48
  modelSupportsAudio,
49
49
  modelSupportsImages,
50
50
  modelSupportsPdf
51
- } from './providers/model-info';
51
+ } from '@jupyternaut/agent';
52
52
 
53
53
  /**
54
54
  * Tool call status types.
@@ -273,7 +273,11 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
273
273
  stopStreaming: () => this.stopStreaming(),
274
274
  clearMessages: () => this.clearMessages(),
275
275
  agentManager: this._agentManager,
276
- addSystemMessage: (body: string) => this._addSystemMessage(body)
276
+ addSystemMessage: (body: string) => this._addSystemMessage(body),
277
+ removeQueuedMessage: (id: string) => this.removeQueuedMessage(id),
278
+ reorderQueuedMessages: (ids: string[]) => this.reorderQueuedMessages(ids),
279
+ editQueuedMessage: (id: string, body: string) =>
280
+ this.editQueuedMessage(id, body)
277
281
  };
278
282
  }
279
283
 
@@ -438,7 +442,9 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
438
442
 
439
443
  if (
440
444
  this._settingsModel.config.autoTitle &&
441
- (this.messages.length <= 5 || this.title === null)
445
+ (this.messages.filter(msg => msg.sender.username !== 'ai-assistant')
446
+ .length <= 5 ||
447
+ this.title === null)
442
448
  ) {
443
449
  try {
444
450
  this.title = await this.requestTitle();
@@ -528,8 +534,32 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
528
534
  * @param messageId The ID of the queued message to remove
529
535
  */
530
536
  removeQueuedMessage(messageId: string): void {
531
- this._messageQueue = this._messageQueue.filter(msg => msg.id !== messageId);
532
- this._updateQueueUI();
537
+ this.messageQueue = this._messageQueue.filter(msg => msg.id !== messageId);
538
+ }
539
+
540
+ /**
541
+ * Reorders queued messages by their IDs.
542
+ * @param messageIds Array of message IDs in the desired order
543
+ */
544
+ reorderQueuedMessages(messageIds: string[]): void {
545
+ const byId = new Map(this._messageQueue.map(m => [m.id, m]));
546
+ this.messageQueue = messageIds
547
+ .map(id => byId.get(id))
548
+ .filter((m): m is Private.IQueuedItem => m !== undefined);
549
+ }
550
+
551
+ /**
552
+ * Edits a queued message by its ID.
553
+ * @param messageId The ID of the queued message to edit
554
+ * @param newBody The new body of the message
555
+ */
556
+ editQueuedMessage(messageId: string, newBody: string): void {
557
+ const queue = [...this._messageQueue];
558
+ const index = queue.findIndex(m => m.id === messageId);
559
+ if (index !== -1) {
560
+ queue[index] = { ...queue[index], body: newBody };
561
+ this.messageQueue = queue;
562
+ }
533
563
  }
534
564
 
535
565
  /**
@@ -600,7 +630,7 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
600
630
  );
601
631
  }
602
632
  } else if (!silent) {
603
- console.log(`Provider not providing when restoring ${filepath}.`);
633
+ console.log(`Provider not provided when restoring ${filepath}.`);
604
634
  }
605
635
 
606
636
  const messages: IMessageContent[] = content.messages.map(message => {
@@ -855,6 +885,7 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
855
885
  this.messageAdded(aiMessage);
856
886
  this._currentStreamingMessage =
857
887
  this.messages.find(message => message.id === aiMessage.id) ?? null;
888
+ this._updateQueueUI();
858
889
  }
859
890
 
860
891
  /**
@@ -1023,6 +1054,7 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
1023
1054
  };
1024
1055
 
1025
1056
  this.messageAdded(toolCallMessage);
1057
+ this._updateQueueUI();
1026
1058
  }
1027
1059
 
1028
1060
  /**
@@ -1099,6 +1131,7 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
1099
1131
  type: 'msg',
1100
1132
  raw_time: false
1101
1133
  });
1134
+ this._updateQueueUI();
1102
1135
  }
1103
1136
 
1104
1137
  /**
@@ -1241,11 +1274,13 @@ namespace Private {
1241
1274
  | nbformat.IDisplayUpdate
1242
1275
  | nbformat.IExecuteResult;
1243
1276
 
1244
- const isPlainObject = (value: unknown): value is Record<string, unknown> => {
1277
+ export const isPlainObject = (
1278
+ value: unknown
1279
+ ): value is Record<string, unknown> => {
1245
1280
  return typeof value === 'object' && value !== null && !Array.isArray(value);
1246
1281
  };
1247
1282
 
1248
- const isDisplayOutput = (value: unknown): value is IDisplayOutput => {
1283
+ export const isDisplayOutput = (value: unknown): value is IDisplayOutput => {
1249
1284
  if (!isPlainObject(value)) {
1250
1285
  return false;
1251
1286
  }
@@ -1258,7 +1293,7 @@ namespace Private {
1258
1293
  );
1259
1294
  };
1260
1295
 
1261
- const toMimeBundle = (
1296
+ export const toMimeBundle = (
1262
1297
  value: IDisplayOutput,
1263
1298
  trustedMimeTypes: ReadonlySet<string>
1264
1299
  ): IMimeModelBody | null => {
@@ -1286,7 +1321,7 @@ namespace Private {
1286
1321
  * Tool outputs are not guaranteed to be raw Jupyter IOPub messages; they are
1287
1322
  * often wrapped objects (for example `{ success, result: { outputs: [...] } }`).
1288
1323
  */
1289
- const toDisplayOutputs = (value: unknown): IDisplayOutput[] => {
1324
+ export const toDisplayOutputs = (value: unknown): IDisplayOutput[] => {
1290
1325
  if (isDisplayOutput(value)) {
1291
1326
  return [value];
1292
1327
  }
@@ -1833,6 +1868,18 @@ export namespace AIChatModel {
1833
1868
  * The agent manager of the chat.
1834
1869
  */
1835
1870
  agentManager: IAgentManager;
1871
+ /**
1872
+ * Removes a queued message by its ID.
1873
+ */
1874
+ removeQueuedMessage: (id: string) => void;
1875
+ /**
1876
+ * Reorders queued messages by their IDs.
1877
+ */
1878
+ reorderQueuedMessages: (ids: string[]) => void;
1879
+ /**
1880
+ * Edits a queued message by its ID.
1881
+ */
1882
+ editQueuedMessage: (id: string, body: string) => void;
1836
1883
  }
1837
1884
 
1838
1885
  /**
@@ -1,3 +1,8 @@
1
+ import {
2
+ createCompletionModel,
3
+ IProviderRegistry,
4
+ SECRETS_NAMESPACE
5
+ } from '@jupyternaut/agent';
1
6
  import {
2
7
  CompletionHandler,
3
8
  IInlineCompletionContext,
@@ -8,12 +13,7 @@ import { NotebookPanel } from '@jupyterlab/notebook';
8
13
  import { generateText, type LanguageModel } from 'ai';
9
14
  import { ISecretsManager } from 'jupyter-secrets-manager';
10
15
 
11
- import { createCompletionModel } from '../providers/models';
12
- import {
13
- type IAISettingsModel,
14
- SECRETS_NAMESPACE,
15
- type IProviderRegistry
16
- } from '../tokens';
16
+ import type { IAISettingsModel } from '../tokens';
17
17
 
18
18
  /**
19
19
  * Configuration interface for provider-specific completion behavior
@@ -4,8 +4,6 @@ import type { TranslationBundle } from '@jupyterlab/translation';
4
4
 
5
5
  import ClearIcon from '@mui/icons-material/Clear';
6
6
 
7
- import React from 'react';
8
-
9
7
  import { AIChatModel } from '../chat-model';
10
8
 
11
9
  /**
@@ -1,7 +1,7 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
  import { ReactWidget } from '@jupyterlab/ui-components';
3
3
  import type { TranslationBundle } from '@jupyterlab/translation';
4
- import { jupyternautIcon } from '../icons';
4
+ import { jupyternautIcon } from '@jupyternaut/agent';
5
5
  import type { IAISettingsModel } from '../tokens';
6
6
 
7
7
  const COMPLETION_STATUS_CLASS = 'jp-ai-completion-status';
@@ -2,7 +2,7 @@ import { InputToolbarRegistry, TooltippedButton } from '@jupyter/chat';
2
2
  import type { TranslationBundle } from '@jupyterlab/translation';
3
3
  import CheckIcon from '@mui/icons-material/Check';
4
4
  import { Menu, MenuItem, Typography } from '@mui/material';
5
- import React, { useCallback, useEffect, useState } from 'react';
5
+ import { useCallback, useEffect, useState } from 'react';
6
6
  import { AIChatModel } from '../chat-model';
7
7
  import type { IAISettingsModel } from '../tokens';
8
8
 
@@ -4,8 +4,6 @@ import type { TranslationBundle } from '@jupyterlab/translation';
4
4
 
5
5
  import StopIcon from '@mui/icons-material/Stop';
6
6
 
7
- import React from 'react';
8
-
9
7
  import { AIChatModel } from '../chat-model';
10
8
 
11
9
  /**