@datalayer/jupyter-react 1.1.7 → 1.1.9

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 (222) hide show
  1. package/lib/components/cell/Cell.d.ts +3 -6
  2. package/lib/components/cell/Cell.js +2 -11
  3. package/lib/components/cell/Cell.js.map +1 -1
  4. package/lib/components/cell/CellAdapter.d.ts +1 -1
  5. package/lib/components/codemirror/CodeMirrorOutputToolbar.d.ts +2 -2
  6. package/lib/components/codemirror/CodeMirrorOutputToolbar.js.map +1 -1
  7. package/lib/components/console/ConsoleAdapter.d.ts +1 -1
  8. package/lib/components/console/ConsoleAdapter.js +1 -1
  9. package/lib/components/console/ConsoleAdapter.js.map +1 -1
  10. package/lib/components/jupyterlab/JupyterLabApp.d.ts +16 -19
  11. package/lib/components/jupyterlab/JupyterLabApp.js +21 -21
  12. package/lib/components/jupyterlab/JupyterLabApp.js.map +1 -1
  13. package/lib/components/jupyterlab/JupyterLabAppAdapter.d.ts +4 -4
  14. package/lib/components/jupyterlab/JupyterLabAppAdapter.js +1 -1
  15. package/lib/components/jupyterlab/JupyterLabAppAdapter.js.map +1 -1
  16. package/lib/components/jupyterlab/JupyterLabAppCss.d.ts +1 -4
  17. package/lib/components/jupyterlab/JupyterLabAppCss.js +1 -5
  18. package/lib/components/jupyterlab/JupyterLabAppCss.js.map +1 -1
  19. package/lib/components/kernel/KernelActionMenu.d.ts +2 -2
  20. package/lib/components/kernel/KernelActionMenu.js.map +1 -1
  21. package/lib/components/kernel/KernelDetective.d.ts +1 -1
  22. package/lib/components/kernel/KernelInspector.d.ts +2 -2
  23. package/lib/components/kernel/KernelInspector.js.map +1 -1
  24. package/lib/components/kernel/KernelSelector.d.ts +2 -2
  25. package/lib/components/kernel/KernelSelector.js.map +1 -1
  26. package/lib/components/kernel/KernelUsage.d.ts +2 -2
  27. package/lib/components/kernel/KernelUsage.js.map +1 -1
  28. package/lib/components/kernel/KernelVariables.d.ts +2 -2
  29. package/lib/components/kernel/KernelVariables.js.map +1 -1
  30. package/lib/components/kernel/Kernelndicator.d.ts +1 -1
  31. package/lib/components/kernel/Kernelndicator.js +17 -13
  32. package/lib/components/kernel/Kernelndicator.js.map +1 -1
  33. package/lib/components/kernel/variables/kernelconnector.d.ts +2 -2
  34. package/lib/components/kernel/variables/kernelconnector.js +2 -2
  35. package/lib/components/kernel/variables/widget.d.ts +4 -2
  36. package/lib/components/kernel/variables/widget.js.map +1 -1
  37. package/lib/components/lumino/Lumino.d.ts +2 -8
  38. package/lib/components/lumino/Lumino.js +1 -6
  39. package/lib/components/lumino/Lumino.js.map +1 -1
  40. package/lib/components/lumino/LuminoBox.d.ts +3 -9
  41. package/lib/components/lumino/LuminoBox.js +1 -6
  42. package/lib/components/lumino/LuminoBox.js.map +1 -1
  43. package/lib/components/lumino/ReactPortalWidget.d.ts +1 -2
  44. package/lib/components/notebook/Notebook.d.ts +4 -6
  45. package/lib/components/notebook/Notebook.js +11 -27
  46. package/lib/components/notebook/Notebook.js.map +1 -1
  47. package/lib/components/notebook/Notebook2.d.ts +7 -0
  48. package/lib/components/notebook/Notebook2.js +13 -2
  49. package/lib/components/notebook/Notebook2.js.map +1 -1
  50. package/lib/components/notebook/Notebook2Adapter.d.ts +197 -0
  51. package/lib/components/notebook/Notebook2Adapter.js +563 -9
  52. package/lib/components/notebook/Notebook2Adapter.js.map +1 -1
  53. package/lib/components/notebook/Notebook2Base.d.ts +15 -6
  54. package/lib/components/notebook/Notebook2Base.js +183 -15
  55. package/lib/components/notebook/Notebook2Base.js.map +1 -1
  56. package/lib/components/notebook/Notebook2State.d.ts +36 -8
  57. package/lib/components/notebook/Notebook2State.js +75 -21
  58. package/lib/components/notebook/Notebook2State.js.map +1 -1
  59. package/lib/components/notebook/NotebookAdapter.js +6 -87
  60. package/lib/components/notebook/NotebookAdapter.js.map +1 -1
  61. package/lib/components/notebook/NotebookState.d.ts +11 -11
  62. package/lib/components/notebook/cell/sidebar/CellSidebarButton.js +1 -1
  63. package/lib/components/notebook/cell/sidebar/CellSidebarExtension.d.ts +2 -4
  64. package/lib/components/notebook/cell/sidebar/CellSidebarExtension.js +1 -3
  65. package/lib/components/notebook/cell/sidebar/CellSidebarExtension.js.map +1 -1
  66. package/lib/components/notebook/index.d.ts +1 -0
  67. package/lib/components/notebook/index.js +1 -0
  68. package/lib/components/notebook/index.js.map +1 -1
  69. package/lib/components/notebook/model/JupyterReactNotebookModelFactory.d.ts +28 -1
  70. package/lib/components/notebook/model/JupyterReactNotebookModelFactory.js +15 -1
  71. package/lib/components/notebook/model/JupyterReactNotebookModelFactory.js.map +1 -1
  72. package/lib/components/output/Output.d.ts +11 -13
  73. package/lib/components/output/Output.js +43 -35
  74. package/lib/components/output/Output.js.map +1 -1
  75. package/lib/components/output/OutputAdapter.d.ts +1 -0
  76. package/lib/components/output/OutputAdapter.js +6 -0
  77. package/lib/components/output/OutputAdapter.js.map +1 -1
  78. package/lib/components/output/OutputIPyWidgets.d.ts +2 -2
  79. package/lib/components/output/OutputIPyWidgets.js.map +1 -1
  80. package/lib/components/output/OutputRenderer.d.ts +2 -2
  81. package/lib/components/output/OutputRenderer.js +11 -1
  82. package/lib/components/output/OutputRenderer.js.map +1 -1
  83. package/lib/components/output/ipywidgets/IPyWidgetsViewManager.js +1 -3
  84. package/lib/components/output/ipywidgets/IPyWidgetsViewManager.js.map +1 -1
  85. package/lib/components/terminal/Terminal.d.ts +1 -4
  86. package/lib/components/terminal/Terminal.js +4 -7
  87. package/lib/components/terminal/Terminal.js.map +1 -1
  88. package/lib/components/viewer/Viewer.d.ts +1 -1
  89. package/lib/components/viewer/output/OutputViewer.d.ts +3 -6
  90. package/lib/components/viewer/output/OutputViewer.js +1 -5
  91. package/lib/components/viewer/output/OutputViewer.js.map +1 -1
  92. package/lib/examples/JupyterLabAppHeadless.js +1 -1
  93. package/lib/examples/JupyterLabAppHeadless.js.map +1 -1
  94. package/lib/examples/JupyterLabAppHeadlessServerless.js +1 -1
  95. package/lib/examples/JupyterLabAppHeadlessServerless.js.map +1 -1
  96. package/lib/examples/Notebook2Actions.js +2 -2
  97. package/lib/examples/Notebook2Actions.js.map +1 -1
  98. package/lib/examples/RunningSessions.js +1 -1
  99. package/lib/examples/RunningSessions.js.map +1 -1
  100. package/lib/examples/extensions/celltoolbar/CellToolbarComponent.js +1 -1
  101. package/lib/index.d.ts +4 -0
  102. package/lib/index.js +1 -0
  103. package/lib/index.js.map +1 -1
  104. package/lib/jupyter/Jupyter.d.ts +1 -74
  105. package/lib/jupyter/Jupyter.js +2 -9
  106. package/lib/jupyter/Jupyter.js.map +1 -1
  107. package/lib/jupyter/JupyterConfig.d.ts +6 -0
  108. package/lib/jupyter/JupyterConfig.js +10 -2
  109. package/lib/jupyter/JupyterConfig.js.map +1 -1
  110. package/lib/jupyter/JupyterContext.d.ts +2 -2
  111. package/lib/jupyter/ipywidgets/classic/htmlmanager.d.ts +6 -0
  112. package/lib/jupyter/ipywidgets/classic/htmlmanager.js +8 -0
  113. package/lib/jupyter/ipywidgets/classic/htmlmanager.js.map +1 -1
  114. package/lib/jupyter/ipywidgets/lab/manager.d.ts +6 -0
  115. package/lib/jupyter/ipywidgets/lab/manager.js +8 -0
  116. package/lib/jupyter/ipywidgets/lab/manager.js.map +1 -1
  117. package/lib/jupyter/ipywidgets/libembed-amd.d.ts +1 -1
  118. package/lib/jupyter/ipywidgets/libembed-amd.js +1 -1
  119. package/lib/jupyter/lite/LiteServer.d.ts +1 -1
  120. package/lib/jupyter/lite/LiteServer.js +1 -1
  121. package/lib/theme/JupyterLabCss.d.ts +1 -1
  122. package/lib/theme/JupyterReactTheme.d.ts +1 -1
  123. package/lib/tools/__tests__/operationRunner.test.d.ts +1 -0
  124. package/lib/tools/__tests__/operationRunner.test.js +193 -0
  125. package/lib/tools/__tests__/operationRunner.test.js.map +1 -0
  126. package/lib/tools/core/executor.d.ts +46 -0
  127. package/lib/tools/core/executor.js +55 -0
  128. package/lib/tools/core/executor.js.map +1 -0
  129. package/lib/tools/core/formatter.d.ts +20 -0
  130. package/lib/tools/core/formatter.js +41 -0
  131. package/lib/tools/core/formatter.js.map +1 -0
  132. package/lib/tools/core/index.d.ts +18 -0
  133. package/lib/tools/core/index.js +24 -0
  134. package/lib/tools/core/index.js.map +1 -0
  135. package/lib/tools/core/interfaces.d.ts +38 -0
  136. package/lib/tools/core/interfaces.js +7 -0
  137. package/lib/tools/core/interfaces.js.map +1 -0
  138. package/lib/tools/core/operationRunner.d.ts +27 -0
  139. package/lib/tools/core/operationRunner.js +33 -0
  140. package/lib/tools/core/operationRunner.js.map +1 -0
  141. package/lib/tools/core/schema.d.ts +47 -0
  142. package/lib/tools/core/schema.js +7 -0
  143. package/lib/tools/core/schema.js.map +1 -0
  144. package/lib/tools/core/types.d.ts +36 -0
  145. package/lib/tools/core/types.js +7 -0
  146. package/lib/tools/core/types.js.map +1 -0
  147. package/lib/tools/core/zodUtils.d.ts +56 -0
  148. package/lib/tools/core/zodUtils.js +179 -0
  149. package/lib/tools/core/zodUtils.js.map +1 -0
  150. package/lib/tools/definitions/deleteCell.d.ts +7 -0
  151. package/lib/tools/definitions/deleteCell.js +25 -0
  152. package/lib/tools/definitions/deleteCell.js.map +1 -0
  153. package/lib/tools/definitions/executeCode.d.ts +7 -0
  154. package/lib/tools/definitions/executeCode.js +33 -0
  155. package/lib/tools/definitions/executeCode.js.map +1 -0
  156. package/lib/tools/definitions/index.d.ts +12 -0
  157. package/lib/tools/definitions/index.js +18 -0
  158. package/lib/tools/definitions/index.js.map +1 -0
  159. package/lib/tools/definitions/insertCell.d.ts +7 -0
  160. package/lib/tools/definitions/insertCell.js +24 -0
  161. package/lib/tools/definitions/insertCell.js.map +1 -0
  162. package/lib/tools/definitions/readAllCells.d.ts +7 -0
  163. package/lib/tools/definitions/readAllCells.js +24 -0
  164. package/lib/tools/definitions/readAllCells.js.map +1 -0
  165. package/lib/tools/definitions/readCell.d.ts +7 -0
  166. package/lib/tools/definitions/readCell.js +24 -0
  167. package/lib/tools/definitions/readCell.js.map +1 -0
  168. package/lib/tools/definitions/runCell.d.ts +7 -0
  169. package/lib/tools/definitions/runCell.js +31 -0
  170. package/lib/tools/definitions/runCell.js.map +1 -0
  171. package/lib/tools/definitions/updateCell.d.ts +7 -0
  172. package/lib/tools/definitions/updateCell.js +24 -0
  173. package/lib/tools/definitions/updateCell.js.map +1 -0
  174. package/lib/tools/index.d.ts +20 -0
  175. package/lib/tools/index.js +62 -0
  176. package/lib/tools/index.js.map +1 -0
  177. package/lib/tools/operations/deleteCell.d.ts +49 -0
  178. package/lib/tools/operations/deleteCell.js +103 -0
  179. package/lib/tools/operations/deleteCell.js.map +1 -0
  180. package/lib/tools/operations/executeCode.d.ts +33 -0
  181. package/lib/tools/operations/executeCode.js +45 -0
  182. package/lib/tools/operations/executeCode.js.map +1 -0
  183. package/lib/tools/operations/insertCell.d.ts +27 -0
  184. package/lib/tools/operations/insertCell.js +56 -0
  185. package/lib/tools/operations/insertCell.js.map +1 -0
  186. package/lib/tools/operations/readAllCells.d.ts +21 -0
  187. package/lib/tools/operations/readAllCells.js +45 -0
  188. package/lib/tools/operations/readAllCells.js.map +1 -0
  189. package/lib/tools/operations/readCell.d.ts +39 -0
  190. package/lib/tools/operations/readCell.js +90 -0
  191. package/lib/tools/operations/readCell.js.map +1 -0
  192. package/lib/tools/operations/runCell.d.ts +24 -0
  193. package/lib/tools/operations/runCell.js +124 -0
  194. package/lib/tools/operations/runCell.js.map +1 -0
  195. package/lib/tools/operations/updateCell.d.ts +27 -0
  196. package/lib/tools/operations/updateCell.js +53 -0
  197. package/lib/tools/operations/updateCell.js.map +1 -0
  198. package/lib/tools/schemas/deleteCell.d.ts +20 -0
  199. package/lib/tools/schemas/deleteCell.js +24 -0
  200. package/lib/tools/schemas/deleteCell.js.map +1 -0
  201. package/lib/tools/schemas/executeCode.d.ts +19 -0
  202. package/lib/tools/schemas/executeCode.js +28 -0
  203. package/lib/tools/schemas/executeCode.js.map +1 -0
  204. package/lib/tools/schemas/index.d.ts +12 -0
  205. package/lib/tools/schemas/index.js +18 -0
  206. package/lib/tools/schemas/index.js.map +1 -0
  207. package/lib/tools/schemas/insertCell.d.ts +24 -0
  208. package/lib/tools/schemas/insertCell.js +29 -0
  209. package/lib/tools/schemas/insertCell.js.map +1 -0
  210. package/lib/tools/schemas/readAllCells.d.ts +19 -0
  211. package/lib/tools/schemas/readAllCells.js +18 -0
  212. package/lib/tools/schemas/readAllCells.js.map +1 -0
  213. package/lib/tools/schemas/readCell.d.ts +19 -0
  214. package/lib/tools/schemas/readCell.js +24 -0
  215. package/lib/tools/schemas/readCell.js.map +1 -0
  216. package/lib/tools/schemas/runCell.d.ts +21 -0
  217. package/lib/tools/schemas/runCell.js +39 -0
  218. package/lib/tools/schemas/runCell.js.map +1 -0
  219. package/lib/tools/schemas/updateCell.d.ts +19 -0
  220. package/lib/tools/schemas/updateCell.js +21 -0
  221. package/lib/tools/schemas/updateCell.js.map +1 -0
  222. package/package.json +25 -16
@@ -0,0 +1,179 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * Zod utility functions for tool parameter validation
8
+ *
9
+ * @module tools/core/zodUtils
10
+ */
11
+ import { z } from 'zod';
12
+ import { zodToJsonSchema } from 'zod-to-json-schema';
13
+ /**
14
+ * Converts a Zod schema to ToolDefinition parameters (JSON Schema format).
15
+ *
16
+ * This enables a single source of truth: define the schema once with Zod,
17
+ * and automatically generate the JSON Schema for LLM tool calling.
18
+ *
19
+ * @param schema - Zod schema defining the tool's input parameters
20
+ * @returns JSON Schema object compatible with ToolDefinition.parameters
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const schema = z.object({
25
+ * index: z.number().int().describe('Cell index'),
26
+ * source: z.string().describe('Cell content')
27
+ * });
28
+ *
29
+ * const parameters = zodToToolParameters(schema);
30
+ * // Returns: { type: 'object', properties: {...}, required: [...] }
31
+ * ```
32
+ */
33
+ export function zodToToolParameters(
34
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
+ schema) {
36
+ // Manual conversion for Zod v3/v4 compatibility
37
+ // zod-to-json-schema@3.x doesn't fully support Zod v4
38
+ // Handle both Zod v3 (_def.type === 'object') and Zod v4 (_def.typeName === 'ZodObject')
39
+ const isZodObject = schema?._def?.typeName === 'ZodObject' || schema?._def?.type === 'object';
40
+ if (isZodObject && schema._def?.shape) {
41
+ // Get shape object - handle both Zod v3 (shape is object) and Zod v4 (shape is function)
42
+ const shape = typeof schema._def.shape === 'function'
43
+ ? schema._def.shape()
44
+ : schema._def.shape;
45
+ const properties = {};
46
+ const required = [];
47
+ for (const [key, value] of Object.entries(shape)) {
48
+ let zodField = value;
49
+ // Build property schema
50
+ const prop = {};
51
+ // Unwrap optional/default modifiers to get to the base type
52
+ // Support both Zod v3 (def/def) and Zod v4 (_def)
53
+ let isOptional = false;
54
+ while (zodField._def?.typeName === 'ZodOptional' ||
55
+ zodField._def?.typeName === 'ZodDefault' ||
56
+ zodField._def?.type === 'optional' ||
57
+ zodField._def?.type === 'default' ||
58
+ zodField.def?.type === 'optional' ||
59
+ zodField.def?.type === 'default') {
60
+ if (zodField._def?.typeName === 'ZodOptional' ||
61
+ zodField._def?.type === 'optional' ||
62
+ zodField.def?.type === 'optional') {
63
+ isOptional = true;
64
+ }
65
+ // Unwrap to get the inner type - try all possible paths
66
+ zodField =
67
+ zodField._def?.innerType || zodField.def?.innerType || zodField;
68
+ }
69
+ // Extract description (check at each level)
70
+ // Support both Zod v3 (def.description) and Zod v4 (_def.description)
71
+ const description = value._def?.description ||
72
+ value.def?.description ||
73
+ value.description;
74
+ if (description) {
75
+ prop.description = description;
76
+ }
77
+ // Handle type based on unwrapped field
78
+ // Support both Zod v3 (def.type) and Zod v4 (_def.typeName or _def.type)
79
+ const typeName = zodField._def?.typeName || zodField._def?.type || zodField.def?.type;
80
+ if (typeName === 'ZodString' || typeName === 'string') {
81
+ prop.type = 'string';
82
+ }
83
+ else if (typeName === 'ZodNumber' || typeName === 'number') {
84
+ prop.type = 'number';
85
+ }
86
+ else if (typeName === 'ZodBoolean' || typeName === 'boolean') {
87
+ prop.type = 'boolean';
88
+ }
89
+ else if (typeName === 'ZodEnum' || typeName === 'enum') {
90
+ prop.type = 'string';
91
+ // Enum values can be in different places depending on Zod version:
92
+ // - Zod v4: _def.values (array)
93
+ // - Zod v3: def.entries (object), options (array), or enum (object)
94
+ const enumValues = zodField._def?.values ||
95
+ zodField.def?.values ||
96
+ zodField.options ||
97
+ (zodField.def?.entries ? Object.keys(zodField.def.entries) : null) ||
98
+ (zodField.enum ? Object.keys(zodField.enum) : null) ||
99
+ [];
100
+ prop.enum = Array.isArray(enumValues)
101
+ ? enumValues
102
+ : Object.keys(enumValues || {});
103
+ }
104
+ properties[key] = prop;
105
+ // Mark as required if not optional
106
+ if (!isOptional) {
107
+ required.push(key);
108
+ }
109
+ }
110
+ return {
111
+ type: 'object',
112
+ properties,
113
+ required,
114
+ };
115
+ }
116
+ // Fallback to zod-to-json-schema for other schema types
117
+ // Note: This may not work correctly with Zod v4
118
+ const jsonSchema = zodToJsonSchema(schema, {
119
+ target: 'openApi3',
120
+ $refStrategy: 'none',
121
+ });
122
+ const schemaProperties = jsonSchema.properties || {};
123
+ const requiredFields = jsonSchema.required || [];
124
+ return {
125
+ type: 'object',
126
+ properties: schemaProperties,
127
+ required: requiredFields,
128
+ };
129
+ }
130
+ /**
131
+ * Validates parameters using a Zod schema with user-friendly error messages.
132
+ *
133
+ * This replaces manual type guard functions with automatic runtime validation.
134
+ * On validation failure, throws a descriptive error that helps both developers
135
+ * and LLMs understand what went wrong.
136
+ *
137
+ * @param schema - Zod schema to validate against
138
+ * @param params - Unknown parameters to validate
139
+ * @param operationName - Name of the operation (for error messages)
140
+ * @returns Validated parameters with proper TypeScript type
141
+ * @throws Error with detailed validation failure information
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * const schema = z.object({ index: z.number().int() });
146
+ *
147
+ * // Valid params
148
+ * const validated = validateWithZod(schema, { index: 5 }, 'readCell');
149
+ * // Returns: { index: 5 } with type { index: number }
150
+ *
151
+ * // Invalid params
152
+ * validateWithZod(schema, { index: 'invalid' }, 'readCell');
153
+ * // Throws: Error: Invalid parameters for readCell:
154
+ * // - index: Expected number, received string
155
+ * ```
156
+ */
157
+ export function validateWithZod(schema, params, operationName) {
158
+ try {
159
+ // Parse and validate parameters
160
+ return schema.parse(params);
161
+ }
162
+ catch (error) {
163
+ if (error instanceof z.ZodError) {
164
+ // Convert Zod validation errors to user-friendly format
165
+ const issues = error.issues
166
+ .map(issue => {
167
+ // Build path string (e.g., "cells[0].type" for nested errors)
168
+ const path = issue.path.length > 0 ? issue.path.join('.') : 'root';
169
+ return ` - ${path}: ${issue.message}`;
170
+ })
171
+ .join('\n');
172
+ throw new Error(`Invalid parameters for ${operationName}:\n${issues}\n\n` +
173
+ `Received: ${JSON.stringify(params)}`);
174
+ }
175
+ // Re-throw non-Zod errors
176
+ throw error;
177
+ }
178
+ }
179
+ //# sourceMappingURL=zodUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zodUtils.js","sourceRoot":"","sources":["../../../src/tools/core/zodUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB;AACjC,8DAA8D;AAC9D,MAAW;IAEX,gDAAgD;IAChD,sDAAsD;IACtD,yFAAyF;IACzF,MAAM,WAAW,GACf,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,WAAW,IAAI,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC;IAE5E,IAAI,WAAW,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;QACtC,yFAAyF;QACzF,MAAM,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iBACxB,GAAG,CAAC,KAAK,CAAC,EAAE;gBACX,8DAA8D;gBAC9D,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;gBAEnE,OAAO,OAAO,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;YACzC,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,MAAM,IAAI,KAAK,CACb,0BAA0B,aAAa,MAAM,MAAM,MAAM;gBACvD,aAAa,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CACxC,CAAC;QACJ,CAAC;QAED,0BAA0B;QAC1B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Delete cell tool definition.
3
+ *
4
+ * @module tools/definitions/deleteCell
5
+ */
6
+ import type { ToolDefinition } from '../core/schema';
7
+ export declare const deleteCellTool: ToolDefinition;
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ import { zodToToolParameters } from '../core/zodUtils';
7
+ import { deleteCellParamsSchema } from '../schemas/deleteCell';
8
+ export const deleteCellTool = {
9
+ name: 'datalayer_deleteCell',
10
+ displayName: 'Delete Notebook Cell(s)',
11
+ toolReferenceName: 'deleteCell',
12
+ description: 'Deletes one or more cells from a Jupyter notebook at the specified indices. Cells are deleted in reverse order to prevent index shifting.',
13
+ // Generate parameters from Zod schema (single source of truth)
14
+ parameters: zodToToolParameters(deleteCellParamsSchema),
15
+ operation: 'deleteCell',
16
+ config: {
17
+ confirmationMessage: (params) => `Delete ${params.indices.length} cell${params.indices.length !== 1 ? 's' : ''} at ${params.indices.length === 1 ? `index ${params.indices[0]}` : `indices ${params.indices.join(', ')}`}?`,
18
+ invocationMessage: (params) => `Deleting ${params.indices.length} cell${params.indices.length !== 1 ? 's' : ''}`,
19
+ requiresConfirmation: true,
20
+ canBeReferencedInPrompt: true,
21
+ priority: 'medium',
22
+ },
23
+ tags: ['cell', 'notebook', 'manipulation', 'delete'],
24
+ };
25
+ //# sourceMappingURL=deleteCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteCell.js","sourceRoot":"","sources":["../../../src/tools/definitions/deleteCell.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,yBAAyB;IACtC,iBAAiB,EAAE,YAAY;IAC/B,WAAW,EACT,2IAA2I;IAE7I,+DAA+D;IAC/D,UAAU,EAAE,mBAAmB,CAAC,sBAAsB,CAAC;IAEvD,SAAS,EAAE,YAAY;IAEvB,MAAM,EAAE;QACN,mBAAmB,EAAE,CAAC,MAA6B,EAAE,EAAE,CACrD,UAAU,MAAM,CAAC,OAAO,CAAC,MAAM,QAAQ,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG;QAC5L,iBAAiB,EAAE,CAAC,MAA6B,EAAE,EAAE,CACnD,YAAY,MAAM,CAAC,OAAO,CAAC,MAAM,QAAQ,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACnF,oBAAoB,EAAE,IAAI;QAC1B,uBAAuB,EAAE,IAAI;QAC7B,QAAQ,EAAE,QAAQ;KACnB;IAED,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,CAAC;CACrD,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Execute code tool definition.
3
+ *
4
+ * @module tools/definitions/executeCode
5
+ */
6
+ import type { ToolDefinition } from '../core/schema';
7
+ export declare const executeCodeTool: ToolDefinition;
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ import { zodToToolParameters } from '../core/zodUtils';
7
+ import { executeCodeParamsSchema } from '../schemas/executeCode';
8
+ export const executeCodeTool = {
9
+ name: 'datalayer_executeCode',
10
+ displayName: 'Execute Code in Kernel',
11
+ toolReferenceName: 'executeCode',
12
+ description: 'Execute code directly in the kernel (not saved to notebook) on the current activated notebook.\n\n' +
13
+ 'Recommended to use in following cases:\n' +
14
+ '1. Execute Jupyter magic commands (e.g., %timeit, %pip install xxx)\n' +
15
+ '2. Performance profiling and debugging\n' +
16
+ '3. View intermediate variable values (e.g., print(xxx), df.head())\n' +
17
+ "4. Temporary calculations and quick tests (e.g., np.mean(df['xxx']))\n" +
18
+ '5. Execute Shell commands in Jupyter server (e.g., !git xxx)\n\n' +
19
+ 'Under no circumstances should you use this tool to:\n' +
20
+ '1. Import new modules or perform variable assignments that affect subsequent Notebook execution\n' +
21
+ "2. Execute dangerous code that may harm the Jupyter server or the user's data without permission",
22
+ parameters: zodToToolParameters(executeCodeParamsSchema),
23
+ operation: 'executeCode',
24
+ config: {
25
+ confirmationMessage: (params) => `Execute code: ${params.code.substring(0, 50)}${params.code.length > 50 ? '...' : ''}?`,
26
+ invocationMessage: () => 'Executing code in kernel',
27
+ requiresConfirmation: false,
28
+ canBeReferencedInPrompt: true,
29
+ priority: 'high',
30
+ },
31
+ tags: ['kernel', 'notebook', 'execute', 'code', 'inspection', 'magic'],
32
+ };
33
+ //# sourceMappingURL=executeCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executeCode.js","sourceRoot":"","sources":["../../../src/tools/definitions/executeCode.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC7C,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,wBAAwB;IACrC,iBAAiB,EAAE,aAAa;IAChC,WAAW,EACT,oGAAoG;QACpG,0CAA0C;QAC1C,uEAAuE;QACvE,0CAA0C;QAC1C,sEAAsE;QACtE,wEAAwE;QACxE,kEAAkE;QAClE,uDAAuD;QACvD,mGAAmG;QACnG,kGAAkG;IAEpG,UAAU,EAAE,mBAAmB,CAAC,uBAAuB,CAAC;IAExD,SAAS,EAAE,aAAa;IAExB,MAAM,EAAE;QACN,mBAAmB,EAAE,CAAC,MAAwB,EAAE,EAAE,CAChD,iBAAiB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG;QACzF,iBAAiB,EAAE,GAAG,EAAE,CAAC,0BAA0B;QACnD,oBAAoB,EAAE,KAAK;QAC3B,uBAAuB,EAAE,IAAI;QAC7B,QAAQ,EAAE,MAAM;KACjB;IAED,IAAI,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC;CACvE,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Tool definitions (schemas) for notebook operations.
3
+ *
4
+ * @module tools/definitions
5
+ */
6
+ export * from './insertCell';
7
+ export * from './deleteCell';
8
+ export * from './updateCell';
9
+ export * from './readCell';
10
+ export * from './readAllCells';
11
+ export * from './runCell';
12
+ export * from './executeCode';
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * Tool definitions (schemas) for notebook operations.
8
+ *
9
+ * @module tools/definitions
10
+ */
11
+ export * from './insertCell';
12
+ export * from './deleteCell';
13
+ export * from './updateCell';
14
+ export * from './readCell';
15
+ export * from './readAllCells';
16
+ export * from './runCell';
17
+ export * from './executeCode';
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/definitions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Insert cell tool definition.
3
+ *
4
+ * @module tools/definitions/insertCell
5
+ */
6
+ import type { ToolDefinition } from '../core/schema';
7
+ export declare const insertCellTool: ToolDefinition;
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ import { zodToToolParameters } from '../core/zodUtils';
7
+ import { insertCellParamsSchema } from '../schemas/insertCell';
8
+ export const insertCellTool = {
9
+ name: 'datalayer_insertCell',
10
+ displayName: 'Insert Notebook Cell',
11
+ toolReferenceName: 'insertCell',
12
+ description: 'IMPORTANT: Call readAllCells first to see the current notebook structure and determine the correct insertion point. Then, insert a code or markdown cell into a Jupyter notebook at a specified position or at the end',
13
+ parameters: zodToToolParameters(insertCellParamsSchema),
14
+ operation: 'insertCell',
15
+ config: {
16
+ confirmationMessage: (params) => `Insert ${params.type} cell into notebook?\n\n${params.source}`,
17
+ invocationMessage: (params) => `Inserting ${params.type} cell into notebook`,
18
+ requiresConfirmation: true,
19
+ canBeReferencedInPrompt: true,
20
+ priority: 'high',
21
+ },
22
+ tags: ['cell', 'notebook', 'manipulation', 'create'],
23
+ };
24
+ //# sourceMappingURL=insertCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insertCell.js","sourceRoot":"","sources":["../../../src/tools/definitions/insertCell.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,sBAAsB;IACnC,iBAAiB,EAAE,YAAY;IAC/B,WAAW,EACT,wNAAwN;IAE1N,UAAU,EAAE,mBAAmB,CAAC,sBAAsB,CAAC;IAEvD,SAAS,EAAE,YAAY;IAEvB,MAAM,EAAE;QACN,mBAAmB,EAAE,CAAC,MAAwC,EAAE,EAAE,CAChE,UAAU,MAAM,CAAC,IAAI,2BAA2B,MAAM,CAAC,MAAM,EAAE;QACjE,iBAAiB,EAAE,CAAC,MAAwB,EAAE,EAAE,CAC9C,aAAa,MAAM,CAAC,IAAI,qBAAqB;QAC/C,oBAAoB,EAAE,IAAI;QAC1B,uBAAuB,EAAE,IAAI;QAC7B,QAAQ,EAAE,MAAM;KACjB;IAED,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,CAAC;CACrD,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Read all cells tool definition.
3
+ *
4
+ * @module tools/definitions/readAllCells
5
+ */
6
+ import type { ToolDefinition } from '../core/schema';
7
+ export declare const readAllCellsTool: ToolDefinition;
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ import { zodToToolParameters } from '../core/zodUtils';
7
+ import { readAllCellsParamsSchema } from '../schemas/readAllCells';
8
+ export const readAllCellsTool = {
9
+ name: 'datalayer_readAllCells',
10
+ displayName: 'Read All Notebook Cells',
11
+ toolReferenceName: 'readAllCells',
12
+ description: "Read all cells from the Jupyter notebook. Supports two response formats: 'brief' (default) returns index, type, and 40-char content preview for structure queries and counting cells; 'detailed' returns full content with source, execution_count, and outputs. Use brief when you need to see notebook structure, count cells, or quickly scan content. Use detailed when you need to read full cell content or outputs. Brief format preview shows first 40 characters of cell source. Returns array of cells with: index (cell position), type (code, markdown, raw), preview (brief only), and optionally source/execution_count/outputs (detailed only). Works on active notebook.",
13
+ parameters: zodToToolParameters(readAllCellsParamsSchema),
14
+ operation: 'readAllCells',
15
+ config: {
16
+ confirmationMessage: () => 'Read all cells from notebook?',
17
+ invocationMessage: () => 'Reading all cells',
18
+ requiresConfirmation: false,
19
+ canBeReferencedInPrompt: true,
20
+ priority: 'high',
21
+ },
22
+ tags: ['cell', 'notebook', 'read', 'inspect', 'all'],
23
+ };
24
+ //# sourceMappingURL=readAllCells.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readAllCells.js","sourceRoot":"","sources":["../../../src/tools/definitions/readAllCells.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,MAAM,CAAC,MAAM,gBAAgB,GAAmB;IAC9C,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EAAE,yBAAyB;IACtC,iBAAiB,EAAE,cAAc;IACjC,WAAW,EACT,0pBAA0pB;IAE5pB,UAAU,EAAE,mBAAmB,CAAC,wBAAwB,CAAC;IAEzD,SAAS,EAAE,cAAc;IAEzB,MAAM,EAAE;QACN,mBAAmB,EAAE,GAAG,EAAE,CAAC,+BAA+B;QAC1D,iBAAiB,EAAE,GAAG,EAAE,CAAC,mBAAmB;QAC5C,oBAAoB,EAAE,KAAK;QAC3B,uBAAuB,EAAE,IAAI;QAC7B,QAAQ,EAAE,MAAM;KACjB;IAED,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC;CACrD,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Read cell tool definition.
3
+ *
4
+ * @module tools/definitions/readCell
5
+ */
6
+ import type { ToolDefinition } from '../core/schema';
7
+ export declare const readCellTool: ToolDefinition;
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ import { zodToToolParameters } from '../core/zodUtils';
7
+ import { readCellParamsSchema } from '../schemas/readCell';
8
+ export const readCellTool = {
9
+ name: 'datalayer_readCell',
10
+ displayName: 'Read Notebook Cell',
11
+ toolReferenceName: 'readCell',
12
+ description: 'Reads a specific cell from a Jupyter notebook by index, including source code and outputs',
13
+ parameters: zodToToolParameters(readCellParamsSchema),
14
+ operation: 'readCell',
15
+ config: {
16
+ confirmationMessage: (params) => `Read cell at index ${params.index}?`,
17
+ invocationMessage: (params) => `Reading cell ${params.index}`,
18
+ requiresConfirmation: false,
19
+ canBeReferencedInPrompt: true,
20
+ priority: 'high',
21
+ },
22
+ tags: ['cell', 'notebook', 'read', 'inspect'],
23
+ };
24
+ //# sourceMappingURL=readCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readCell.js","sourceRoot":"","sources":["../../../src/tools/definitions/readCell.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,CAAC,MAAM,YAAY,GAAmB;IAC1C,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,iBAAiB,EAAE,UAAU;IAC7B,WAAW,EACT,2FAA2F;IAE7F,UAAU,EAAE,mBAAmB,CAAC,oBAAoB,CAAC;IAErD,SAAS,EAAE,UAAU;IAErB,MAAM,EAAE;QACN,mBAAmB,EAAE,CAAC,MAAyB,EAAE,EAAE,CACjD,sBAAsB,MAAM,CAAC,KAAK,GAAG;QACvC,iBAAiB,EAAE,CAAC,MAAyB,EAAE,EAAE,CAC/C,gBAAgB,MAAM,CAAC,KAAK,EAAE;QAChC,oBAAoB,EAAE,KAAK;QAC3B,uBAAuB,EAAE,IAAI;QAC7B,QAAQ,EAAE,MAAM;KACjB;IAED,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC;CAC9C,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Run cell tool definition.
3
+ *
4
+ * @module tools/definitions/runCell
5
+ */
6
+ import type { ToolDefinition } from '../core/schema';
7
+ export declare const runCellTool: ToolDefinition;
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ import { zodToToolParameters } from '../core/zodUtils';
7
+ import { runCellParamsSchema } from '../schemas/runCell';
8
+ export const runCellTool = {
9
+ name: 'datalayer_runCell',
10
+ displayName: 'Run Notebook Cell',
11
+ toolReferenceName: 'runCell',
12
+ description: 'Runs a code cell in a Jupyter notebook and returns its outputs with execution metadata. ' +
13
+ 'Supports timeout and streaming progress updates. ' +
14
+ 'Returns execution_count, outputs, and elapsed_time. ' +
15
+ 'If no index is provided, runs the currently active cell.',
16
+ parameters: zodToToolParameters(runCellParamsSchema),
17
+ operation: 'runCell',
18
+ config: {
19
+ confirmationMessage: (params) => params.index !== undefined
20
+ ? `Run cell at index ${params.index}?`
21
+ : 'Run cell?',
22
+ invocationMessage: (params) => params.index !== undefined
23
+ ? `Running cell ${params.index}${params.timeoutSeconds ? ` (timeout: ${params.timeoutSeconds}s)` : ''}`
24
+ : `Running cell${params.timeoutSeconds ? ` (timeout: ${params.timeoutSeconds}s)` : ''}`,
25
+ requiresConfirmation: false,
26
+ canBeReferencedInPrompt: true,
27
+ priority: 'high',
28
+ },
29
+ tags: ['cell', 'notebook', 'execute', 'run', 'outputs'],
30
+ };
31
+ //# sourceMappingURL=runCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runCell.js","sourceRoot":"","sources":["../../../src/tools/definitions/runCell.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,CAAC,MAAM,WAAW,GAAmB;IACzC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,mBAAmB;IAChC,iBAAiB,EAAE,SAAS;IAC5B,WAAW,EACT,0FAA0F;QAC1F,mDAAmD;QACnD,sDAAsD;QACtD,0DAA0D;IAE5D,UAAU,EAAE,mBAAmB,CAAC,mBAAmB,CAAC;IAEpD,SAAS,EAAE,SAAS;IAEpB,MAAM,EAAE;QACN,mBAAmB,EAAE,CAAC,MAA0B,EAAE,EAAE,CAClD,MAAM,CAAC,KAAK,KAAK,SAAS;YACxB,CAAC,CAAC,qBAAqB,MAAM,CAAC,KAAK,GAAG;YACtC,CAAC,CAAC,WAAW;QACjB,iBAAiB,EAAE,CAAC,MAAmD,EAAE,EAAE,CACzE,MAAM,CAAC,KAAK,KAAK,SAAS;YACxB,CAAC,CAAC,gBAAgB,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,MAAM,CAAC,cAAc,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACvG,CAAC,CAAC,eAAe,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,MAAM,CAAC,cAAc,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;QAC3F,oBAAoB,EAAE,KAAK;QAC3B,uBAAuB,EAAE,IAAI;QAC7B,QAAQ,EAAE,MAAM;KACjB;IAED,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC;CACxD,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Update cell tool definition.
3
+ *
4
+ * @module tools/definitions/updateCell
5
+ */
6
+ import type { ToolDefinition } from '../core/schema';
7
+ export declare const updateCellTool: ToolDefinition;
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ import { zodToToolParameters } from '../core/zodUtils';
7
+ import { updateCellParamsSchema } from '../schemas/updateCell';
8
+ export const updateCellTool = {
9
+ name: 'datalayer_updateCell',
10
+ displayName: 'Update Notebook Cell',
11
+ toolReferenceName: 'updateCell',
12
+ description: "Updates (overwrites) a cell's source code at the specified index. Does NOT execute the cell.",
13
+ parameters: zodToToolParameters(updateCellParamsSchema),
14
+ operation: 'updateCell',
15
+ config: {
16
+ confirmationMessage: (params) => `Update cell at index ${params.index}?\n\n${params.source}`,
17
+ invocationMessage: (params) => `Updating cell ${params.index}`,
18
+ requiresConfirmation: false,
19
+ canBeReferencedInPrompt: true,
20
+ priority: 'medium',
21
+ },
22
+ tags: ['cell', 'notebook', 'manipulation', 'update'],
23
+ };
24
+ //# sourceMappingURL=updateCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateCell.js","sourceRoot":"","sources":["../../../src/tools/definitions/updateCell.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,sBAAsB;IACnC,iBAAiB,EAAE,YAAY;IAC/B,WAAW,EACT,8FAA8F;IAEhG,UAAU,EAAE,mBAAmB,CAAC,sBAAsB,CAAC;IAEvD,SAAS,EAAE,YAAY;IAEvB,MAAM,EAAE;QACN,mBAAmB,EAAE,CAAC,MAAyC,EAAE,EAAE,CACjE,wBAAwB,MAAM,CAAC,KAAK,QAAQ,MAAM,CAAC,MAAM,EAAE;QAC7D,iBAAiB,EAAE,CAAC,MAAyB,EAAE,EAAE,CAC/C,iBAAiB,MAAM,CAAC,KAAK,EAAE;QACjC,oBAAoB,EAAE,KAAK;QAC3B,uBAAuB,EAAE,IAAI;QAC7B,QAAQ,EAAE,QAAQ;KACnB;IAED,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,CAAC;CACrD,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { ToolDefinition } from './core/schema';
2
+ import type { ToolOperation } from './core/interfaces';
3
+ /**
4
+ * Array of all notebook tool definitions
5
+ */
6
+ export declare const notebookToolDefinitions: ToolDefinition[];
7
+ /**
8
+ * Registry of all notebook tool operations
9
+ * Maps operation names to their implementations
10
+ */
11
+ export declare const notebookToolOperations: Record<string, ToolOperation<unknown, unknown>>;
12
+ /**
13
+ * Complete notebook tools bundle for easy iteration and registration
14
+ */
15
+ export declare const notebookTools: {
16
+ definitions: ToolDefinition<unknown>[];
17
+ operations: Record<string, ToolOperation<unknown, unknown>>;
18
+ };
19
+ export * from './core';
20
+ export * from './definitions';
@@ -0,0 +1,62 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * Platform-agnostic notebook tools.
8
+ *
9
+ * @module tools
10
+ */
11
+ // Import all tool definitions
12
+ import { insertCellTool } from './definitions/insertCell';
13
+ import { deleteCellTool } from './definitions/deleteCell';
14
+ import { updateCellTool } from './definitions/updateCell';
15
+ import { readCellTool } from './definitions/readCell';
16
+ import { readAllCellsTool } from './definitions/readAllCells';
17
+ import { runCellTool } from './definitions/runCell';
18
+ import { executeCodeTool } from './definitions/executeCode';
19
+ // Import all operations
20
+ import { insertCellOperation } from './operations/insertCell';
21
+ import { deleteCellOperation } from './operations/deleteCell';
22
+ import { updateCellOperation } from './operations/updateCell';
23
+ import { readCellOperation } from './operations/readCell';
24
+ import { readAllCellsOperation } from './operations/readAllCells';
25
+ import { runCellOperation } from './operations/runCell';
26
+ import { executeCodeOperation } from './operations/executeCode';
27
+ /**
28
+ * Array of all notebook tool definitions
29
+ */
30
+ export const notebookToolDefinitions = [
31
+ insertCellTool,
32
+ deleteCellTool,
33
+ updateCellTool,
34
+ readCellTool,
35
+ readAllCellsTool,
36
+ runCellTool,
37
+ executeCodeTool,
38
+ ];
39
+ /**
40
+ * Registry of all notebook tool operations
41
+ * Maps operation names to their implementations
42
+ */
43
+ export const notebookToolOperations = {
44
+ insertCell: insertCellOperation,
45
+ deleteCell: deleteCellOperation,
46
+ updateCell: updateCellOperation,
47
+ readCell: readCellOperation,
48
+ readAllCells: readAllCellsOperation,
49
+ runCell: runCellOperation,
50
+ executeCode: executeCodeOperation,
51
+ };
52
+ /**
53
+ * Complete notebook tools bundle for easy iteration and registration
54
+ */
55
+ export const notebookTools = {
56
+ definitions: notebookToolDefinitions,
57
+ operations: notebookToolOperations,
58
+ };
59
+ // Re-export everything for convenience
60
+ export * from './core';
61
+ export * from './definitions';
62
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,8BAA8B;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,M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