@@ -16,73 +16,11 @@ import type {
1616 LexicalMetadata ,
1717 RegisteredNodeInfo ,
1818} from './types' ;
19+ import type { ToolExecutionContext } from '@datalayer/jupyter-react' ;
1920
2021// Re-export types for convenience
2122export type { LexicalBlock , LexicalMetadata , RegisteredNodeInfo } ;
22-
23- /**
24- * Base tool execution context - common to all operations
25- */
26- export interface BaseExecutionContext {
27- /**
28- * Datalayer SDK for API operations
29- * (Required for notebook/runtime creation tools)
30- */
31- sdk ?: unknown ; // DatalayerClient (avoid circular import)
32-
33- /**
34- * Authentication provider
35- * (Required for authenticated operations)
36- */
37- auth ?: unknown ; // AuthProvider (avoid circular import)
38-
39- /**
40- * Response format for tool results
41- * - "json": Standard JSON format (default) - structured data
42- * - "toon": TOON format - human/LLM-readable with compact syntax
43- */
44- format ?: 'json' | 'toon' ;
45-
46- /**
47- * Platform-agnostic command execution callback.
48- * Allows operations to invoke platform-specific commands without direct dependencies.
49- *
50- * Operations call this with namespaced command names (e.g., "notebook.insertCell", "lexical.insertBlock").
51- * The platform adapter is responsible for mapping these to the appropriate implementation.
52- *
53- * @param command - Command name with namespace prefix (e.g., "notebook.insertCell")
54- * @param args - Command arguments (platform adapter handles any necessary conversions)
55- * @returns Command result
56- */
57- executeCommand ?: < T = void > ( command : string , args : unknown ) => Promise < T > ;
58-
59- /**
60- * Platform-specific extras (escape hatch for special cases)
61- * Use this to pass additional context that doesn't fit in the standard interface.
62- */
63- extras ?: Record < string , unknown > ;
64- }
65-
66- /**
67- * Lexical-specific execution context
68- * Used by all Lexical block operations (insertBlock, deleteBlock, readBlocks)
69- */
70- export interface LexicalExecutionContext extends BaseExecutionContext {
71- /**
72- * Lexical document ID - universal identifier for both local and remote documents
73- * - Local documents: Same as file URI (e.g., "file:///path/to/document.lexical")
74- * - Remote documents: Datalayer document UID (e.g., "01KAJ42KE2XKM7NBNZV568KXQX")
75- */
76- lexicalId : string ;
77-
78- /**
79- * Executor for calling lexical store operations
80- * Used in ag-ui environments to directly call store methods
81- */
82- executor ?: {
83- execute < T = unknown > ( operationName : string , args ?: unknown ) : Promise < T > ;
84- } ;
85- }
23+ export type { ToolExecutionContext } ;
8624
8725/**
8826 * Core tool operation interface - platform agnostic.
@@ -107,11 +45,11 @@ export interface ToolOperation<TParams, TResult> {
10745 * ToolDefinition (schema), not here. Operations are pure implementation.
10846 *
10947 * @param params - Tool-specific parameters
110- * @param context - Execution context (lexicalId , SDK, auth)
48+ * @param context - Execution context (documentId, executor , SDK, auth)
11149 * @returns Operation result
11250 * @throws Error if operation fails
11351 */
114- execute ( params : TParams , context : LexicalExecutionContext ) : Promise < TResult > ;
52+ execute ( params : TParams , context : ToolExecutionContext ) : Promise < TResult > ;
11553}
11654
11755/**
0 commit comments