@marimo-team/islands 0.25.1-dev26 → 0.25.1-dev28

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 (170) hide show
  1. package/dist/{ErrorBoundary-pWWhtr0s.js → ErrorBoundary-CE6-1WC1.js} +1 -1
  2. package/dist/{code-visibility-Ba_KMLhg.js → code-visibility--u2Q2Zfx.js} +1 -1
  3. package/dist/{common-Cqwp2VSj.js → common-hHL7iKzA.js} +1 -1
  4. package/dist/{data-grid-overlay-editor-CpH8-A59.js → data-grid-overlay-editor-v7VZO5up.js} +1 -1
  5. package/dist/{feedback-button-CJxD9fy8.js → feedback-button-C3Ya1IXo.js} +2 -2
  6. package/dist/{glide-data-editor-cm-NQofk.js → glide-data-editor-BKOLh2Tv.js} +3 -3
  7. package/dist/{globals-BquX8N9R.js → globals-DOJr_y24.js} +1 -1
  8. package/dist/main.js +6 -6
  9. package/dist/{number-overlay-editor-3AkAzj7F.js → number-overlay-editor-DkEFJYK7.js} +1 -1
  10. package/dist/{reveal-component-rC5k5pu3.js → reveal-component-rbEv9ppg.js} +2 -2
  11. package/dist/style.css +1 -1
  12. package/package.json +1 -1
  13. package/src/__mocks__/common.ts +3 -3
  14. package/src/__tests__/CellStatus.test.tsx +1 -1
  15. package/src/__tests__/setup.ts +7 -7
  16. package/src/components/app-config/ai-config.tsx +2 -0
  17. package/src/components/chat/chat-panel.tsx +19 -8
  18. package/src/components/data-table/column-summary/chart-spec-model.tsx +4 -4
  19. package/src/components/dependency-graph/elements.ts +2 -2
  20. package/src/components/editor/actions/__tests__/pair-with-agent.test.tsx +107 -0
  21. package/src/components/editor/actions/pair-with-agent.tsx +119 -0
  22. package/src/components/editor/actions/useNotebookActions.tsx +2 -1
  23. package/src/components/editor/ai/add-cell-with-ai.tsx +2 -0
  24. package/src/components/editor/ai/staged-cell-submission.ts +2 -2
  25. package/src/components/editor/ai/transport/chat-transport.tsx +1 -1
  26. package/src/components/editor/connections/database/as-code.ts +44 -44
  27. package/src/components/editor/connections/storage/as-code.ts +3 -3
  28. package/src/components/editor/file-tree/requesting-tree.tsx +16 -13
  29. package/src/components/editor/navigation/clipboard.ts +2 -2
  30. package/src/components/editor/output/ansi-reduce.ts +13 -13
  31. package/src/components/slides/__tests__/minimap-actions.test.tsx +7 -7
  32. package/src/components/slides/__tests__/minimap.test.ts +12 -12
  33. package/src/components/slides/__tests__/slide-scroll-hint.test.tsx +8 -8
  34. package/src/core/ai/context/__tests__/registry.test.ts +31 -28
  35. package/src/core/ai/context/providers/cell-output.ts +8 -8
  36. package/src/core/ai/context/providers/datasource.ts +10 -7
  37. package/src/core/ai/context/providers/error.ts +7 -7
  38. package/src/core/ai/context/providers/file.ts +8 -8
  39. package/src/core/ai/context/providers/tables.ts +7 -7
  40. package/src/core/ai/context/providers/variable.ts +7 -7
  41. package/src/core/ai/context/registry.ts +18 -18
  42. package/src/core/ai/ids/ids.ts +5 -5
  43. package/src/core/ai/model-registry.ts +12 -9
  44. package/src/core/ai/staged-cells.ts +6 -6
  45. package/src/core/ai/tools/base.ts +6 -6
  46. package/src/core/ai/tools/edit-notebook-tool.ts +6 -6
  47. package/src/core/ai/tools/registry.ts +4 -4
  48. package/src/core/ai/tools/run-cells-tool.ts +7 -7
  49. package/src/core/ai/tools/sample-tool.ts +6 -6
  50. package/src/core/codemirror/cells/debugger-decorations.ts +13 -7
  51. package/src/core/codemirror/cells/line-timing-decorations.ts +9 -9
  52. package/src/core/codemirror/cells/traceback-decorations.ts +7 -4
  53. package/src/core/codemirror/code-lens/extension.ts +13 -13
  54. package/src/core/codemirror/copilot/__tests__/language-server.test.ts +6 -6
  55. package/src/core/codemirror/copilot/__tests__/transport.test.ts +12 -12
  56. package/src/core/codemirror/copilot/language-server.ts +13 -13
  57. package/src/core/codemirror/copilot/transport.ts +1 -1
  58. package/src/core/codemirror/find-replace/search-highlight.ts +5 -5
  59. package/src/core/codemirror/go-to-definition/underline.ts +3 -3
  60. package/src/core/codemirror/keymaps/vim.ts +3 -3
  61. package/src/core/codemirror/language/languages/markdown.ts +8 -8
  62. package/src/core/codemirror/language/languages/python.ts +7 -7
  63. package/src/core/codemirror/language/languages/sql/completion-builder.ts +5 -5
  64. package/src/core/codemirror/language/languages/sql/completion-store.ts +4 -4
  65. package/src/core/codemirror/language/languages/sql/sql.ts +21 -21
  66. package/src/core/codemirror/lsp/__tests__/transports.test.ts +10 -10
  67. package/src/core/codemirror/lsp/federated-lsp.ts +29 -27
  68. package/src/core/codemirror/lsp/notebook-lsp.ts +21 -21
  69. package/src/core/codemirror/misc/__tests__/dnd.test.ts +10 -10
  70. package/src/core/codemirror/misc/__tests__/paste.test.ts +7 -4
  71. package/src/core/codemirror/reactive-references/extension.ts +3 -3
  72. package/src/core/codemirror/rtc/loro/awareness.ts +12 -12
  73. package/src/core/codemirror/rtc/loro/sync.ts +5 -5
  74. package/src/core/codemirror/vim/cursor-visibility.ts +3 -3
  75. package/src/core/dom/ui-element.ts +5 -5
  76. package/src/core/dom/uiregistry.ts +10 -10
  77. package/src/core/hotkeys/hotkeys.ts +9 -9
  78. package/src/core/islands/__tests__/bridge.test.ts +4 -4
  79. package/src/core/islands/__tests__/test-utils.tsx +4 -4
  80. package/src/core/islands/bridge.ts +85 -82
  81. package/src/core/islands/components/web-components.tsx +7 -7
  82. package/src/core/islands/worker/__tests__/controller.test.ts +1 -1
  83. package/src/core/islands/worker/controller.ts +6 -3
  84. package/src/core/islands/worker-factory.ts +2 -2
  85. package/src/core/kernel/RuntimeState.ts +4 -4
  86. package/src/core/lsp/__tests__/transport.test.ts +19 -19
  87. package/src/core/lsp/transport.ts +5 -5
  88. package/src/core/network/CachingRequestRegistry.ts +2 -2
  89. package/src/core/network/DeferredRequestRegistry.ts +4 -4
  90. package/src/core/runtime/runtime.ts +25 -20
  91. package/src/core/static/virtual-file-tracker.ts +5 -5
  92. package/src/core/wasm/__tests__/bridge.test.ts +2 -2
  93. package/src/core/wasm/bridge.ts +130 -126
  94. package/src/core/wasm/router.ts +5 -5
  95. package/src/core/wasm/store.ts +4 -4
  96. package/src/core/wasm/worker/bootstrap.ts +8 -5
  97. package/src/core/wasm/worker/message-buffer.ts +3 -3
  98. package/src/core/websocket/transports/__tests__/ws.test.ts +8 -8
  99. package/src/core/websocket/transports/basic.ts +15 -8
  100. package/src/core/websocket/transports/sse.ts +7 -7
  101. package/src/core/websocket/transports/transport.ts +3 -3
  102. package/src/core/websocket/transports/ws.ts +9 -7
  103. package/src/hooks/__tests__/useOverflowDetection.test.tsx +5 -5
  104. package/src/hooks/__tests__/useResizeObserver.test.tsx +12 -12
  105. package/src/plugins/core/registerReactComponent.tsx +5 -5
  106. package/src/plugins/core/sidebar-element.tsx +2 -2
  107. package/src/plugins/impl/ButtonPlugin.tsx +3 -3
  108. package/src/plugins/impl/CheckboxPlugin.tsx +3 -3
  109. package/src/plugins/impl/CodeEditorPlugin.tsx +3 -3
  110. package/src/plugins/impl/DatePickerPlugin.tsx +3 -3
  111. package/src/plugins/impl/DateRangePlugin.tsx +3 -3
  112. package/src/plugins/impl/DateTimePickerPlugin.tsx +3 -3
  113. package/src/plugins/impl/DictPlugin.tsx +3 -3
  114. package/src/plugins/impl/DropdownPlugin.tsx +3 -3
  115. package/src/plugins/impl/FileUploadPlugin.tsx +3 -3
  116. package/src/plugins/impl/MatrixPlugin.tsx +4 -4
  117. package/src/plugins/impl/MicrophonePlugin.tsx +3 -3
  118. package/src/plugins/impl/MultiselectPlugin.tsx +3 -3
  119. package/src/plugins/impl/NumberPlugin.tsx +3 -3
  120. package/src/plugins/impl/RadioPlugin.tsx +3 -3
  121. package/src/plugins/impl/RangeSliderPlugin.tsx +3 -3
  122. package/src/plugins/impl/RefreshPlugin.tsx +3 -3
  123. package/src/plugins/impl/SliderPlugin.tsx +3 -3
  124. package/src/plugins/impl/SwitchPlugin.tsx +3 -3
  125. package/src/plugins/impl/TabsPlugin.tsx +3 -3
  126. package/src/plugins/impl/TextAreaPlugin.tsx +3 -3
  127. package/src/plugins/impl/TextInputPlugin.tsx +3 -3
  128. package/src/plugins/impl/__tests__/MatrixPlugin.test.tsx +2 -2
  129. package/src/plugins/impl/anywidget/model.ts +10 -10
  130. package/src/plugins/impl/anywidget/registry.ts +12 -9
  131. package/src/plugins/impl/anywidget/runtime.ts +11 -9
  132. package/src/plugins/impl/anywidget/widget-binding.ts +6 -6
  133. package/src/plugins/impl/matplotlib/MatplotlibPlugin.tsx +3 -3
  134. package/src/plugins/impl/matplotlib/__tests__/matplotlib-renderer.test.ts +2 -2
  135. package/src/plugins/impl/matplotlib/matplotlib-renderer.ts +2 -2
  136. package/src/plugins/impl/mpl-interactive/mpl-websocket-shim.ts +10 -10
  137. package/src/plugins/impl/panel/utils.ts +5 -5
  138. package/src/plugins/impl/plotly/PlotlyPlugin.tsx +3 -3
  139. package/src/plugins/impl/vega/VegaPlugin.tsx +3 -3
  140. package/src/plugins/impl/vega/__tests__/use-vega-container-remeasure.test.ts +7 -7
  141. package/src/plugins/layout/AccordionPlugin.tsx +3 -3
  142. package/src/plugins/layout/CalloutPlugin.tsx +3 -3
  143. package/src/plugins/layout/ImageComparisonPlugin.tsx +5 -3
  144. package/src/plugins/layout/JsonOutputPlugin.tsx +3 -3
  145. package/src/plugins/layout/MimeRenderPlugin.tsx +3 -3
  146. package/src/plugins/layout/NavigationMenuPlugin.tsx +3 -3
  147. package/src/plugins/layout/OutlinePlugin.tsx +3 -3
  148. package/src/plugins/layout/ProgressPlugin.tsx +3 -3
  149. package/src/plugins/layout/RoutesPlugin.tsx +3 -3
  150. package/src/plugins/layout/StatPlugin.tsx +3 -3
  151. package/src/plugins/layout/TexPlugin.tsx +3 -3
  152. package/src/plugins/layout/carousel/CarouselPlugin.tsx +4 -4
  153. package/src/plugins/layout/mermaid/MermaidPlugin.tsx +3 -3
  154. package/src/utils/Deferred.ts +6 -6
  155. package/src/utils/async-capture-tracker.ts +10 -7
  156. package/src/utils/errors.ts +5 -5
  157. package/src/utils/id-tree.tsx +83 -80
  158. package/src/utils/lru.ts +1 -1
  159. package/src/utils/multi-map.ts +14 -12
  160. package/src/utils/paths.ts +6 -6
  161. package/src/utils/pluralize.ts +3 -3
  162. package/src/utils/progress.ts +6 -6
  163. package/src/utils/python-poet/poet.ts +14 -14
  164. package/src/utils/routes.ts +4 -2
  165. package/src/utils/semaphore.ts +6 -6
  166. package/src/utils/storage/storage.ts +6 -6
  167. package/src/utils/storage/typed.ts +16 -12
  168. package/src/utils/time.ts +9 -9
  169. package/src/utils/timed-cache.ts +4 -4
  170. package/src/utils/tracer.ts +9 -6
@@ -76,12 +76,12 @@ describe("SlideScrollContainer", () => {
76
76
  vi.stubGlobal(
77
77
  "ResizeObserver",
78
78
  class MockResizeObserver {
79
- callback: ResizeObserverCallback;
80
- observe = vi.fn();
81
- unobserve = vi.fn();
82
- disconnect = vi.fn();
79
+ public callback: ResizeObserverCallback;
80
+ public observe = vi.fn();
81
+ public unobserve = vi.fn();
82
+ public disconnect = vi.fn();
83
83
 
84
- constructor(callback: ResizeObserverCallback) {
84
+ public constructor(callback: ResizeObserverCallback) {
85
85
  this.callback = callback;
86
86
  resizeObservers.push(this);
87
87
  }
@@ -90,9 +90,9 @@ describe("SlideScrollContainer", () => {
90
90
  vi.stubGlobal(
91
91
  "MutationObserver",
92
92
  class MockMutationObserver {
93
- observe = vi.fn();
94
- disconnect = vi.fn();
95
- takeRecords = vi.fn(() => []);
93
+ public observe = vi.fn();
94
+ public disconnect = vi.fn();
95
+ public takeRecords = vi.fn(() => []);
96
96
  },
97
97
  );
98
98
  });
@@ -44,9 +44,9 @@ const mockAttachment2: FileUIPart = {
44
44
 
45
45
  // Concrete implementation of AIContextProvider for testing
46
46
  class MockContextProvider extends AIContextProvider<MockContextItem> {
47
- readonly title = "Mock Items";
48
- readonly mentionPrefix = "@";
49
- readonly contextType = "mock";
47
+ public readonly title = "Mock Items";
48
+ public readonly mentionPrefix = "@";
49
+ public readonly contextType = "mock";
50
50
 
51
51
  private items: MockContextItem[] = [
52
52
  {
@@ -72,57 +72,60 @@ class MockContextProvider extends AIContextProvider<MockContextItem> {
72
72
  },
73
73
  ];
74
74
 
75
- getItems(): MockContextItem[] {
75
+ public getItems(): MockContextItem[] {
76
76
  return this.items;
77
77
  }
78
78
 
79
- formatContext(item: MockContextItem): string {
79
+ public formatContext(item: MockContextItem): string {
80
80
  return `Mock: ${item.name} (${item.data.value})`;
81
81
  }
82
82
 
83
- formatCompletion(item: MockContextItem): Completion {
83
+ public formatCompletion(item: MockContextItem): Completion {
84
84
  return this.createBasicCompletion(item);
85
85
  }
86
86
 
87
87
  // Method to add items for testing
88
- addItem(item: MockContextItem): void {
88
+ public addItem(item: MockContextItem): void {
89
89
  this.items.push(item);
90
90
  }
91
91
 
92
92
  // Method to clear items for testing
93
- clearItems(): void {
93
+ public clearItems(): void {
94
94
  this.items = [];
95
95
  }
96
96
  }
97
97
 
98
98
  // Test provider that supports attachments
99
99
  class AttachmentContextProvider extends AIContextProvider<MockContextItem> {
100
- readonly title = "Attachment Items";
101
- readonly mentionPrefix = "@";
102
- readonly contextType = "attachment";
100
+ public readonly title = "Attachment Items";
101
+ public readonly mentionPrefix = "@";
102
+ public readonly contextType = "attachment";
103
103
 
104
104
  private items: MockContextItem[];
105
105
  private attachments: FileUIPart[];
106
106
 
107
- constructor(items: MockContextItem[] = [], attachments: FileUIPart[] = []) {
107
+ public constructor(
108
+ items: MockContextItem[] = [],
109
+ attachments: FileUIPart[] = [],
110
+ ) {
108
111
  super();
109
112
  this.items = items;
110
113
  this.attachments = attachments;
111
114
  }
112
115
 
113
- getItems(): MockContextItem[] {
116
+ public getItems(): MockContextItem[] {
114
117
  return this.items;
115
118
  }
116
119
 
117
- formatContext(item: MockContextItem): string {
120
+ public formatContext(item: MockContextItem): string {
118
121
  return `Attachment: ${item.name} (${item.data.value})`;
119
122
  }
120
123
 
121
- formatCompletion(item: MockContextItem): Completion {
124
+ public formatCompletion(item: MockContextItem): Completion {
122
125
  return this.createBasicCompletion(item);
123
126
  }
124
127
 
125
- override async getAttachments(
128
+ public override async getAttachments(
126
129
  items: MockContextItem[],
127
130
  ): Promise<FileUIPart[]> {
128
131
  // Return attachments for items that need them
@@ -142,9 +145,9 @@ interface FileContextItem extends AIContextItem {
142
145
 
143
146
  // Another mock provider with different prefix and type
144
147
  class FileContextProvider extends AIContextProvider<FileContextItem> {
145
- readonly title = "Files";
146
- readonly mentionPrefix = "@";
147
- readonly contextType = "file";
148
+ public readonly title = "Files";
149
+ public readonly mentionPrefix = "@";
150
+ public readonly contextType = "file";
148
151
 
149
152
  private items: FileContextItem[] = [
150
153
  {
@@ -163,26 +166,26 @@ class FileContextProvider extends AIContextProvider<FileContextItem> {
163
166
  },
164
167
  ];
165
168
 
166
- getItems(): FileContextItem[] {
169
+ public getItems(): FileContextItem[] {
167
170
  return this.items;
168
171
  }
169
172
 
170
- formatCompletion(item: FileContextItem): Completion {
173
+ public formatCompletion(item: FileContextItem): Completion {
171
174
  return this.createBasicCompletion(item);
172
175
  }
173
176
 
174
- formatContext(item: FileContextItem): string {
177
+ public formatContext(item: FileContextItem): string {
175
178
  return `File: ${item.uri}\nDescription: ${item.description}`;
176
179
  }
177
180
  }
178
181
 
179
182
  // Second mock provider with the same context type as MockContextProvider
180
183
  class SecondaryMockProvider extends AIContextProvider<MockContextItem> {
181
- readonly title = "Secondary Mock Items";
182
- readonly mentionPrefix = "@";
183
- readonly contextType = "mock";
184
+ public readonly title = "Secondary Mock Items";
185
+ public readonly mentionPrefix = "@";
186
+ public readonly contextType = "mock";
184
187
 
185
- getItems(): MockContextItem[] {
188
+ public getItems(): MockContextItem[] {
186
189
  return [
187
190
  {
188
191
  type: "mock",
@@ -194,11 +197,11 @@ class SecondaryMockProvider extends AIContextProvider<MockContextItem> {
194
197
  ];
195
198
  }
196
199
 
197
- formatContext(item: MockContextItem): string {
200
+ public formatContext(item: MockContextItem): string {
198
201
  return `Secondary: ${item.name}`;
199
202
  }
200
203
 
201
- formatCompletion(item: MockContextItem): Completion {
204
+ public formatCompletion(item: MockContextItem): Completion {
202
205
  return this.createBasicCompletion(item);
203
206
  }
204
207
  }
@@ -80,16 +80,16 @@ function isMediaMimetype(
80
80
  }
81
81
 
82
82
  export class CellOutputContextProvider extends AIContextProvider<CellOutputContextItem> {
83
- readonly title = "Cell Outputs";
84
- readonly mentionPrefix = "@";
85
- readonly contextType = "cell-output";
83
+ public readonly title = "Cell Outputs";
84
+ public readonly mentionPrefix = "@";
85
+ public readonly contextType = "cell-output";
86
86
  private store: JotaiStore;
87
- constructor(store: JotaiStore) {
87
+ public constructor(store: JotaiStore) {
88
88
  super();
89
89
  this.store = store;
90
90
  }
91
91
 
92
- getItems(): CellOutputContextItem[] {
92
+ public getItems(): CellOutputContextItem[] {
93
93
  const notebook = this.store.get(notebookAtom);
94
94
  const items: CellOutputContextItem[] = [];
95
95
 
@@ -116,7 +116,7 @@ export class CellOutputContextProvider extends AIContextProvider<CellOutputConte
116
116
  return items;
117
117
  }
118
118
 
119
- formatCompletion(item: CellOutputContextItem): Completion {
119
+ public formatCompletion(item: CellOutputContextItem): Completion {
120
120
  const { cellOutput: data, cellName, cellCode } = item.data;
121
121
 
122
122
  return {
@@ -224,7 +224,7 @@ export class CellOutputContextProvider extends AIContextProvider<CellOutputConte
224
224
  };
225
225
  }
226
226
 
227
- formatContext(item: CellOutputContextItem): string {
227
+ public formatContext(item: CellOutputContextItem): string {
228
228
  const { cellOutput: data, cellName, cellId, cellCode } = item.data;
229
229
 
230
230
  const contextData = {
@@ -253,7 +253,7 @@ export class CellOutputContextProvider extends AIContextProvider<CellOutputConte
253
253
  }
254
254
 
255
255
  /** Get attachments for cell output items that have shouldDownloadImage=true */
256
- override async getAttachments(
256
+ public override async getAttachments(
257
257
  items: CellOutputContextItem[],
258
258
  ): Promise<FileUIPart[]> {
259
259
  const cellId = items[0].data.cellId;
@@ -46,13 +46,16 @@ export interface DatasourceContextItem extends AIContextItem {
46
46
  const CONTEXT_TYPE = "datasource";
47
47
 
48
48
  export class DatasourceContextProvider extends AIContextProvider<DatasourceContextItem> {
49
- readonly title = "Datasource";
50
- readonly mentionPrefix = "@";
51
- readonly contextType = CONTEXT_TYPE;
49
+ public readonly title = "Datasource";
50
+ public readonly mentionPrefix = "@";
51
+ public readonly contextType = CONTEXT_TYPE;
52
52
  private connectionsMap: ConnectionsMap;
53
53
  private dataframes: DataTable[];
54
54
 
55
- constructor(connectionsMap: ConnectionsMap, tablesMap: DatasetTablesMap) {
55
+ public constructor(
56
+ connectionsMap: ConnectionsMap,
57
+ tablesMap: DatasetTablesMap,
58
+ ) {
56
59
  super();
57
60
  this.connectionsMap = connectionsMap;
58
61
  this.dataframes = [...tablesMap.values()].filter(
@@ -60,7 +63,7 @@ export class DatasourceContextProvider extends AIContextProvider<DatasourceConte
60
63
  );
61
64
  }
62
65
 
63
- getItems(): DatasourceContextItem[] {
66
+ public getItems(): DatasourceContextItem[] {
64
67
  return [...this.connectionsMap.values()]
65
68
  .map((connection): DatasourceContextItem | null => {
66
69
  let description = "Database schema.";
@@ -92,7 +95,7 @@ export class DatasourceContextProvider extends AIContextProvider<DatasourceConte
92
95
  .filter(Boolean);
93
96
  }
94
97
 
95
- formatContext(item: DatasourceContextItem): string {
98
+ public formatContext(item: DatasourceContextItem): string {
96
99
  const data = item.data;
97
100
  // Remove certain fields that are not needed in the context
98
101
  const { name, display_name, source, ...filteredDatasource } =
@@ -117,7 +120,7 @@ export class DatasourceContextProvider extends AIContextProvider<DatasourceConte
117
120
  });
118
121
  }
119
122
 
120
- formatCompletion(item: DatasourceContextItem): Completion {
123
+ public formatCompletion(item: DatasourceContextItem): Completion {
121
124
  const datasource = item.data;
122
125
 
123
126
  const dataConnection = datasource.connection;
@@ -95,17 +95,17 @@ function errorContextName(entry: CellErrorEntry): string {
95
95
 
96
96
  const errorsTxt = new PluralWord("error", "errors");
97
97
  export class ErrorContextProvider extends AIContextProvider<ErrorContextItem> {
98
- readonly title = "Errors";
99
- readonly mentionPrefix = "@";
100
- readonly contextType = "error";
98
+ public readonly title = "Errors";
99
+ public readonly mentionPrefix = "@";
100
+ public readonly contextType = "error";
101
101
  private store: JotaiStore;
102
102
 
103
- constructor(store: JotaiStore) {
103
+ public constructor(store: JotaiStore) {
104
104
  super();
105
105
  this.store = store;
106
106
  }
107
107
 
108
- getItems(): ErrorContextItem[] {
108
+ public getItems(): ErrorContextItem[] {
109
109
  const errors = getCellErrorEntries(this.store);
110
110
 
111
111
  if (errors.length === 0) {
@@ -141,7 +141,7 @@ export class ErrorContextProvider extends AIContextProvider<ErrorContextItem> {
141
141
  return items;
142
142
  }
143
143
 
144
- formatCompletion(item: ErrorContextItem): Completion {
144
+ public formatCompletion(item: ErrorContextItem): Completion {
145
145
  if (item.data.type === "all-errors") {
146
146
  const errorCount = item.data.errors.length;
147
147
  return {
@@ -201,7 +201,7 @@ export class ErrorContextProvider extends AIContextProvider<ErrorContextItem> {
201
201
  };
202
202
  }
203
203
 
204
- formatContext(item: ErrorContextItem): string {
204
+ public formatContext(item: ErrorContextItem): string {
205
205
  const entries =
206
206
  item.data.type === "all-errors" ? item.data.errors : [item.data.error];
207
207
 
@@ -38,14 +38,14 @@ const DEFAULT_FILE_SEARCH_CONFIG: FileSearchConfig = {
38
38
  };
39
39
 
40
40
  export class FileContextProvider extends AIContextProvider<FileContextItem> {
41
- readonly title = "Files";
42
- readonly mentionPrefix = "#";
43
- readonly contextType = "file";
41
+ public readonly title = "Files";
42
+ public readonly mentionPrefix = "#";
43
+ public readonly contextType = "file";
44
44
 
45
45
  private apiRequests: EditRequests & RunRequests;
46
46
  private config: FileSearchConfig;
47
47
 
48
- constructor(
48
+ public constructor(
49
49
  apiRequests: EditRequests & RunRequests,
50
50
  config: FileSearchConfig = DEFAULT_FILE_SEARCH_CONFIG,
51
51
  ) {
@@ -58,7 +58,7 @@ export class FileContextProvider extends AIContextProvider<FileContextItem> {
58
58
  * Create a dynamic completion source for file mentions
59
59
  * This bypasses the standard registry system to enable dynamic searching
60
60
  */
61
- createCompletionSource(): CompletionSource {
61
+ public createCompletionSource(): CompletionSource {
62
62
  return async (
63
63
  context: CompletionContext,
64
64
  ): Promise<CompletionResult | null> => {
@@ -176,13 +176,13 @@ export class FileContextProvider extends AIContextProvider<FileContextItem> {
176
176
  }
177
177
  }
178
178
 
179
- getItems(): FileContextItem[] {
179
+ public getItems(): FileContextItem[] {
180
180
  // Files are fetched dynamically, so return empty array
181
181
  // This provider relies on dynamic fetching via createCompletionSource()
182
182
  return [];
183
183
  }
184
184
 
185
- formatCompletion(item: FileContextItem): Completion {
185
+ public formatCompletion(item: FileContextItem): Completion {
186
186
  const { data, name } = item;
187
187
  const icon = data.isDirectory ? "📁" : "📄";
188
188
 
@@ -254,7 +254,7 @@ export class FileContextProvider extends AIContextProvider<FileContextItem> {
254
254
  };
255
255
  }
256
256
 
257
- formatContext(item: FileContextItem): string {
257
+ public formatContext(item: FileContextItem): string {
258
258
  const { data, name } = item;
259
259
  return contextToXml({
260
260
  type: this.contextType,
@@ -17,16 +17,16 @@ export interface TableContextItem extends AIContextItem {
17
17
  }
18
18
 
19
19
  export class TableContextProvider extends AIContextProvider<TableContextItem> {
20
- readonly title = "Tables";
21
- readonly mentionPrefix = "@";
22
- readonly contextType = "data";
20
+ public readonly title = "Tables";
21
+ public readonly mentionPrefix = "@";
22
+ public readonly contextType = "data";
23
23
  private tablesMap: DatasetTablesMap;
24
- constructor(tablesMap: DatasetTablesMap) {
24
+ public constructor(tablesMap: DatasetTablesMap) {
25
25
  super();
26
26
  this.tablesMap = tablesMap;
27
27
  }
28
28
 
29
- getItems(): TableContextItem[] {
29
+ public getItems(): TableContextItem[] {
30
30
  return [...this.tablesMap.entries()].map(([tableName, table]) => ({
31
31
  uri: this.asURI(tableName),
32
32
  name: tableName,
@@ -36,7 +36,7 @@ export class TableContextProvider extends AIContextProvider<TableContextItem> {
36
36
  }));
37
37
  }
38
38
 
39
- formatContext(item: TableContextItem): string {
39
+ public formatContext(item: TableContextItem): string {
40
40
  const { data } = item;
41
41
  const { columns, source, num_rows, num_columns, name, variable_name } =
42
42
  data;
@@ -90,7 +90,7 @@ export class TableContextProvider extends AIContextProvider<TableContextItem> {
90
90
  });
91
91
  }
92
92
 
93
- formatCompletion(item: TableContextItem): Completion {
93
+ public formatCompletion(item: TableContextItem): Completion {
94
94
  const tableName = item.data.name;
95
95
  const table = item.data;
96
96
  return {
@@ -16,20 +16,20 @@ export interface VariableContextItem extends AIContextItem {
16
16
  }
17
17
 
18
18
  export class VariableContextProvider extends AIContextProvider<VariableContextItem> {
19
- readonly title = "Variables";
20
- readonly mentionPrefix = "@";
21
- readonly contextType = "variable";
19
+ public readonly title = "Variables";
20
+ public readonly mentionPrefix = "@";
21
+ public readonly contextType = "variable";
22
22
 
23
23
  private variables: Variables;
24
24
  private tablesMap: DatasetTablesMap;
25
25
 
26
- constructor(variables: Variables, tablesMap: DatasetTablesMap) {
26
+ public constructor(variables: Variables, tablesMap: DatasetTablesMap) {
27
27
  super();
28
28
  this.variables = variables;
29
29
  this.tablesMap = tablesMap;
30
30
  }
31
31
 
32
- getItems(): VariableContextItem[] {
32
+ public getItems(): VariableContextItem[] {
33
33
  const ignore = new Set(this.tablesMap.keys());
34
34
 
35
35
  return Object.entries(this.variables).flatMap(([name, variable]) => {
@@ -51,7 +51,7 @@ export class VariableContextProvider extends AIContextProvider<VariableContextIt
51
51
  });
52
52
  }
53
53
 
54
- formatCompletion(item: VariableContextItem): Completion {
54
+ public formatCompletion(item: VariableContextItem): Completion {
55
55
  const { data } = item;
56
56
  const { variable } = data;
57
57
  return {
@@ -66,7 +66,7 @@ export class VariableContextProvider extends AIContextProvider<VariableContextIt
66
66
  };
67
67
  }
68
68
 
69
- formatContext(item: VariableContextItem): string {
69
+ public formatContext(item: VariableContextItem): string {
70
70
  const { data } = item;
71
71
  const { variable } = data;
72
72
  return contextToXml({
@@ -36,35 +36,35 @@ export abstract class AIContextProvider<
36
36
  T extends AIContextItem = AIContextItem,
37
37
  > {
38
38
  /** Human-readable title for this context type */
39
- abstract readonly title: string;
39
+ public abstract readonly title: string;
40
40
 
41
41
  /** Prefix used for mentions (e.g., "@" for variables, "#" for files) */
42
- abstract readonly mentionPrefix: "@" | "#";
42
+ public abstract readonly mentionPrefix: "@" | "#";
43
43
 
44
44
  /** Context type identifier used in ContextLocatorId */
45
- abstract readonly contextType: string;
45
+ public abstract readonly contextType: string;
46
46
 
47
47
  /** Get all available items of this context type */
48
- abstract getItems(): T[];
48
+ public abstract getItems(): T[];
49
49
 
50
50
  /** Format the context for inclusion in AI prompt */
51
- abstract formatContext(item: T): string;
51
+ public abstract formatContext(item: T): string;
52
52
 
53
53
  /** Format completion */
54
- abstract formatCompletion(item: T): Completion;
54
+ public abstract formatCompletion(item: T): Completion;
55
55
 
56
56
  /** Get attachments for context items (optional, async) */
57
- async getAttachments(_items: T[]): Promise<FileUIPart[]> {
57
+ public async getAttachments(_items: T[]): Promise<FileUIPart[]> {
58
58
  // Default implementation returns no attachments
59
59
  return [];
60
60
  }
61
61
 
62
- asURI(id: string): ContextLocatorId {
62
+ public asURI(id: string): ContextLocatorId {
63
63
  return `${this.contextType}://${id}` as ContextLocatorId;
64
64
  }
65
65
 
66
66
  /** Parse context IDs from input text using the provider's mention prefix */
67
- parseContextIds(input: string): ContextLocatorId[] {
67
+ public parseContextIds(input: string): ContextLocatorId[] {
68
68
  // Match @type://id, e.g., @data://users
69
69
  const regex = new RegExp(
70
70
  `${this.mentionPrefix}([\\w-]+):\\/\\/([\\w./-]+)`,
@@ -112,7 +112,7 @@ export class AIContextRegistry<T extends AIContextItem> {
112
112
  /**
113
113
  * Register a new context provider
114
114
  */
115
- register<U extends AIContextItem>(
115
+ public register<U extends AIContextItem>(
116
116
  provider: AIContextProvider<U>,
117
117
  // oxlint-disable-next-line typescript/prefer-return-this-type
118
118
  ): AIContextRegistry<U | T> {
@@ -123,28 +123,28 @@ export class AIContextRegistry<T extends AIContextItem> {
123
123
  /**
124
124
  * Get all registered providers
125
125
  */
126
- getProviders(): Set<AIContextProvider<T>> {
126
+ public getProviders(): Set<AIContextProvider<T>> {
127
127
  return this.providers;
128
128
  }
129
129
 
130
130
  /**
131
131
  * Get a specific provider by type
132
132
  */
133
- getProvider(type: string): AIContextProvider | undefined {
133
+ public getProvider(type: string): AIContextProvider | undefined {
134
134
  return [...this.providers].find(
135
135
  (provider) => provider.contextType === type,
136
136
  );
137
137
  }
138
138
 
139
139
  @Memoize()
140
- getAllItems(): T[] {
140
+ public getAllItems(): T[] {
141
141
  return [...this.providers].flatMap((provider) => provider.getItems());
142
142
  }
143
143
 
144
144
  /**
145
145
  * Parse context IDs from input across all providers
146
146
  */
147
- parseAllContextIds(input: string): ContextLocatorId[] {
147
+ public parseAllContextIds(input: string): ContextLocatorId[] {
148
148
  return [...this.providers].flatMap((provider) =>
149
149
  provider.parseContextIds(input),
150
150
  );
@@ -167,7 +167,7 @@ export class AIContextRegistry<T extends AIContextItem> {
167
167
  /**
168
168
  * Resolve only the requested context items, querying each matching provider
169
169
  */
170
- resolveItems(contextIds: ContextLocatorId[]): T[] {
170
+ public resolveItems(contextIds: ContextLocatorId[]): T[] {
171
171
  if (contextIds.length === 0) {
172
172
  return [];
173
173
  }
@@ -215,14 +215,14 @@ export class AIContextRegistry<T extends AIContextItem> {
215
215
  /**
216
216
  * Get context information for mentioned items
217
217
  */
218
- getContextInfo(contextIds: ContextLocatorId[]): T[] {
218
+ public getContextInfo(contextIds: ContextLocatorId[]): T[] {
219
219
  return this.resolveItems(contextIds);
220
220
  }
221
221
 
222
222
  /**
223
223
  * Format context for AI prompt inclusion
224
224
  */
225
- formatContextForAI(contextIds: ContextLocatorId[]): string {
225
+ public formatContextForAI(contextIds: ContextLocatorId[]): string {
226
226
  const contextInfo = this.resolveItems(contextIds);
227
227
 
228
228
  if (contextInfo.length === 0) {
@@ -240,7 +240,7 @@ export class AIContextRegistry<T extends AIContextItem> {
240
240
  /**
241
241
  * Get attachments for mentioned items
242
242
  */
243
- async getAttachmentsForContext(
243
+ public async getAttachmentsForContext(
244
244
  contextIds: ContextLocatorId[],
245
245
  ): Promise<FileUIPart[]> {
246
246
  const contextInfo = this.resolveItems(contextIds);
@@ -33,19 +33,19 @@ export type ShortModelId = TypedString<"ShortModelId">;
33
33
  export type QualifiedModelId = `${ProviderId}/${ShortModelId}`;
34
34
 
35
35
  export class AiModelId {
36
- readonly providerId: ProviderId;
37
- readonly shortModelId: ShortModelId;
36
+ public readonly providerId: ProviderId;
37
+ public readonly shortModelId: ShortModelId;
38
38
 
39
- constructor(providerId: ProviderId, shortModelId: ShortModelId) {
39
+ public constructor(providerId: ProviderId, shortModelId: ShortModelId) {
40
40
  this.providerId = providerId;
41
41
  this.shortModelId = shortModelId;
42
42
  }
43
43
 
44
- get id(): QualifiedModelId {
44
+ public get id(): QualifiedModelId {
45
45
  return `${this.providerId}/${this.shortModelId}`;
46
46
  }
47
47
 
48
- static parse(id: string): AiModelId {
48
+ public static parse(id: string): AiModelId {
49
49
  if (!id.includes("/")) {
50
50
  const providerId = guessProviderId(id);
51
51
  return new AiModelId(providerId, id as ShortModelId);
@@ -93,7 +93,7 @@ export class AiModelRegistry {
93
93
  this.buildMaps();
94
94
  }
95
95
 
96
- static getProviderInfo(providerId: ProviderId) {
96
+ public static getProviderInfo(providerId: ProviderId) {
97
97
  const { providerMap } = getProviderMap();
98
98
  return providerMap.get(providerId);
99
99
  }
@@ -104,7 +104,10 @@ export class AiModelRegistry {
104
104
  *
105
105
  * Models should be in the format of `provider_id/short_model_id`.
106
106
  */
107
- static create(opts: { customModels?: string[]; displayedModels?: string[] }) {
107
+ public static create(opts: {
108
+ customModels?: string[];
109
+ displayedModels?: string[];
110
+ }) {
108
111
  const { customModels = [], displayedModels = [] } = opts;
109
112
  return new AiModelRegistry(
110
113
  customModels.map((model) => AiModelId.parse(model).id),
@@ -196,23 +199,23 @@ export class AiModelRegistry {
196
199
  return { modelsByProviderMap, modelsMap };
197
200
  }
198
201
 
199
- getDisplayedModels() {
202
+ public getDisplayedModels() {
200
203
  return this.displayedModels;
201
204
  }
202
205
 
203
- getCustomModels() {
206
+ public getCustomModels() {
204
207
  return this.customModels;
205
208
  }
206
209
 
207
- getModelsByProvider(provider: ProviderId) {
210
+ public getModelsByProvider(provider: ProviderId) {
208
211
  return this.modelsByProviderMap.get(provider) || [];
209
212
  }
210
213
 
211
- getGroupedModelsByProvider() {
214
+ public getGroupedModelsByProvider() {
212
215
  return this.modelsByProviderMap;
213
216
  }
214
217
 
215
- getListModelsByProvider(): [ProviderId, AiModel[]][] {
218
+ public getListModelsByProvider(): [ProviderId, AiModel[]][] {
216
219
  const modelsByProvider = this.getGroupedModelsByProvider();
217
220
  const arrayModels = [...modelsByProvider.entries()];
218
221
  const providerToOrderIdx = getProviderMap().providerToOrderIdx;
@@ -227,11 +230,11 @@ export class AiModelRegistry {
227
230
  return arrayModels;
228
231
  }
229
232
 
230
- getModelsMap() {
233
+ public getModelsMap() {
231
234
  return this.modelsMap;
232
235
  }
233
236
 
234
- getModel(qualifiedModelId: QualifiedModelId) {
237
+ public getModel(qualifiedModelId: QualifiedModelId) {
235
238
  return this.modelsMap.get(qualifiedModelId);
236
239
  }
237
240
  }