@deepnote/blocks
Advanced tools
+66
-16
@@ -89,2 +89,13 @@ //#region rolldown:runtime | ||
| //#endregion | ||
| //#region src/blocks/agent-blocks.ts | ||
| function createPythonCodeForAgentBlock(block) { | ||
| const prompt = block.content ?? ""; | ||
| if (!prompt.trim()) return "# [agent block] (empty system prompt)"; | ||
| return `# [agent block] System prompt:\n${prompt.split("\n").map((line) => `# ${line}`).join("\n")}`; | ||
| } | ||
| function isAgentBlock(block) { | ||
| return block.type === "agent"; | ||
| } | ||
| //#endregion | ||
| //#region src/blocks/executable-blocks.ts | ||
@@ -330,11 +341,2 @@ /** | ||
| }); | ||
| const agentBlockSchema = zod.z.object({ | ||
| ...executableBlockFields, | ||
| type: zod.z.literal("agent"), | ||
| content: zod.z.string().optional(), | ||
| metadata: executableBlockMetadataSchema.extend({ | ||
| deepnote_variable_name: zod.z.string().optional(), | ||
| deepnote_agent_model: zod.z.string().optional() | ||
| }).default({}) | ||
| }); | ||
| const bigNumberBlockSchema = zod.z.object({ | ||
@@ -355,2 +357,17 @@ ...executableBlockFields, | ||
| }); | ||
| const mcpServerSchema = zod.z.object({ | ||
| name: zod.z.string(), | ||
| command: zod.z.string(), | ||
| args: zod.z.array(zod.z.string()).optional(), | ||
| env: zod.z.record(zod.z.string()).optional() | ||
| }); | ||
| const agentBlockSchema = zod.z.object({ | ||
| ...executableBlockFields, | ||
| type: zod.z.literal("agent"), | ||
| content: zod.z.string().optional(), | ||
| metadata: executableBlockMetadataSchema.extend({ | ||
| deepnote_agent_model: zod.z.string().default("auto"), | ||
| deepnote_mcp_servers: zod.z.array(mcpServerSchema).optional() | ||
| }).default({}) | ||
| }); | ||
| const inputTextBlockSchema = zod.z.object({ | ||
@@ -538,2 +555,3 @@ ...executableBlockFields, | ||
| }).optional(), | ||
| mcpServers: zod.z.array(mcpServerSchema).optional(), | ||
| requirements: zod.z.array(zod.z.string()).optional(), | ||
@@ -788,10 +806,38 @@ sqlCacheMaxAge: zod.z.number().optional() | ||
| //#endregion | ||
| //#region src/blocks/agent-blocks.ts | ||
| function createPythonCodeForAgentBlock(block) { | ||
| const prompt = block.content ?? ""; | ||
| if (!prompt.trim()) return "# [agent block] (empty system prompt)"; | ||
| return `# [agent block] System prompt:\n${prompt.split("\n").map((line) => `# ${line}`).join("\n")}`; | ||
| //#region src/output-text.ts | ||
| const unknownObjectSchema = zod.z.object({}).passthrough(); | ||
| /** | ||
| * Extract a human-readable text string from a single Jupyter-style output object. | ||
| * Returns null if the output type is unrecognized or has no textual representation. | ||
| */ | ||
| function extractOutputText(output, options) { | ||
| const outResult = unknownObjectSchema.safeParse(output); | ||
| if (!outResult.success) return null; | ||
| const out = outResult.data; | ||
| if (out.output_type === "stream" && typeof out.text === "string") return out.text; | ||
| if (out.output_type === "execute_result" || out.output_type === "display_data") { | ||
| const dataResult = unknownObjectSchema.safeParse(out.data); | ||
| const data = dataResult.success ? dataResult.data : void 0; | ||
| if (data?.["text/plain"]) return String(data["text/plain"]); | ||
| if (data?.["text/html"]) return "[HTML output]"; | ||
| if (data?.["image/png"] || data?.["image/jpeg"]) return "[Image output]"; | ||
| } | ||
| if (out.output_type === "error") { | ||
| let text = `Error: ${String(out.ename || "Error")}: ${String(out.evalue || "")}`; | ||
| if (options?.includeTraceback && Array.isArray(out.traceback)) text += "\n" + out.traceback.map((line) => line.replace(/\x1b\[[0-9;]*m/g, "")).join("\n"); | ||
| return text; | ||
| } | ||
| return null; | ||
| } | ||
| function isAgentBlock(block) { | ||
| return block.type === "agent"; | ||
| /** | ||
| * Extract human-readable text from an array of Jupyter-style output objects. | ||
| * Joins non-null results with newlines. | ||
| */ | ||
| function extractOutputsText(outputs, options) { | ||
| const texts = []; | ||
| for (const output of outputs) { | ||
| const text = extractOutputText(output, options); | ||
| if (text != null) texts.push(text); | ||
| } | ||
| return texts.join("\n"); | ||
| } | ||
@@ -1258,6 +1304,10 @@ | ||
| exports.executionSummarySchema = executionSummarySchema; | ||
| exports.extractOutputText = extractOutputText; | ||
| exports.extractOutputsText = extractOutputsText; | ||
| exports.generateSortingKey = generateSortingKey; | ||
| exports.getSqlEnvVarName = getSqlEnvVarName; | ||
| exports.isAgentBlock = isAgentBlock; | ||
| exports.isExecutableBlock = isExecutableBlock; | ||
| exports.isExecutableBlockType = isExecutableBlockType; | ||
| exports.mcpServerSchema = mcpServerSchema; | ||
| exports.parseYaml = parseYaml; | ||
@@ -1264,0 +1314,0 @@ exports.serializeDeepnoteFile = serializeDeepnoteFile; |
+63
-17
@@ -63,2 +63,13 @@ import { z } from "zod"; | ||
| //#endregion | ||
| //#region src/blocks/agent-blocks.ts | ||
| function createPythonCodeForAgentBlock(block) { | ||
| const prompt = block.content ?? ""; | ||
| if (!prompt.trim()) return "# [agent block] (empty system prompt)"; | ||
| return `# [agent block] System prompt:\n${prompt.split("\n").map((line) => `# ${line}`).join("\n")}`; | ||
| } | ||
| function isAgentBlock(block) { | ||
| return block.type === "agent"; | ||
| } | ||
| //#endregion | ||
| //#region src/blocks/executable-blocks.ts | ||
@@ -304,11 +315,2 @@ /** | ||
| }); | ||
| const agentBlockSchema = z.object({ | ||
| ...executableBlockFields, | ||
| type: z.literal("agent"), | ||
| content: z.string().optional(), | ||
| metadata: executableBlockMetadataSchema.extend({ | ||
| deepnote_variable_name: z.string().optional(), | ||
| deepnote_agent_model: z.string().optional() | ||
| }).default({}) | ||
| }); | ||
| const bigNumberBlockSchema = z.object({ | ||
@@ -329,2 +331,17 @@ ...executableBlockFields, | ||
| }); | ||
| const mcpServerSchema = z.object({ | ||
| name: z.string(), | ||
| command: z.string(), | ||
| args: z.array(z.string()).optional(), | ||
| env: z.record(z.string()).optional() | ||
| }); | ||
| const agentBlockSchema = z.object({ | ||
| ...executableBlockFields, | ||
| type: z.literal("agent"), | ||
| content: z.string().optional(), | ||
| metadata: executableBlockMetadataSchema.extend({ | ||
| deepnote_agent_model: z.string().default("auto"), | ||
| deepnote_mcp_servers: z.array(mcpServerSchema).optional() | ||
| }).default({}) | ||
| }); | ||
| const inputTextBlockSchema = z.object({ | ||
@@ -512,2 +529,3 @@ ...executableBlockFields, | ||
| }).optional(), | ||
| mcpServers: z.array(mcpServerSchema).optional(), | ||
| requirements: z.array(z.string()).optional(), | ||
@@ -762,10 +780,38 @@ sqlCacheMaxAge: z.number().optional() | ||
| //#endregion | ||
| //#region src/blocks/agent-blocks.ts | ||
| function createPythonCodeForAgentBlock(block) { | ||
| const prompt = block.content ?? ""; | ||
| if (!prompt.trim()) return "# [agent block] (empty system prompt)"; | ||
| return `# [agent block] System prompt:\n${prompt.split("\n").map((line) => `# ${line}`).join("\n")}`; | ||
| //#region src/output-text.ts | ||
| const unknownObjectSchema = z.object({}).passthrough(); | ||
| /** | ||
| * Extract a human-readable text string from a single Jupyter-style output object. | ||
| * Returns null if the output type is unrecognized or has no textual representation. | ||
| */ | ||
| function extractOutputText(output, options) { | ||
| const outResult = unknownObjectSchema.safeParse(output); | ||
| if (!outResult.success) return null; | ||
| const out = outResult.data; | ||
| if (out.output_type === "stream" && typeof out.text === "string") return out.text; | ||
| if (out.output_type === "execute_result" || out.output_type === "display_data") { | ||
| const dataResult = unknownObjectSchema.safeParse(out.data); | ||
| const data = dataResult.success ? dataResult.data : void 0; | ||
| if (data?.["text/plain"]) return String(data["text/plain"]); | ||
| if (data?.["text/html"]) return "[HTML output]"; | ||
| if (data?.["image/png"] || data?.["image/jpeg"]) return "[Image output]"; | ||
| } | ||
| if (out.output_type === "error") { | ||
| let text = `Error: ${String(out.ename || "Error")}: ${String(out.evalue || "")}`; | ||
| if (options?.includeTraceback && Array.isArray(out.traceback)) text += "\n" + out.traceback.map((line) => line.replace(/\x1b\[[0-9;]*m/g, "")).join("\n"); | ||
| return text; | ||
| } | ||
| return null; | ||
| } | ||
| function isAgentBlock(block) { | ||
| return block.type === "agent"; | ||
| /** | ||
| * Extract human-readable text from an array of Jupyter-style output objects. | ||
| * Joins non-null results with newlines. | ||
| */ | ||
| function extractOutputsText(outputs, options) { | ||
| const texts = []; | ||
| for (const output of outputs) { | ||
| const text = extractOutputText(output, options); | ||
| if (text != null) texts.push(text); | ||
| } | ||
| return texts.join("\n"); | ||
| } | ||
@@ -1211,2 +1257,2 @@ | ||
| //#endregion | ||
| export { DeepnoteError, EncodingError, INPUT_BLOCK_TYPES, InvalidValueError, ParseError, ProhibitedYamlFeatureError, SchemaValidationError, UnsupportedBlockTypeError, YamlParseError, convertToEnvironmentVariableName, createMarkdown, createPythonCode, decodeUtf8NoBom, deepnoteBlockSchema, deepnoteFileSchema, deepnoteSnapshotSchema, deserializeDeepnoteFile, environmentSchema, executionErrorSchema, executionSchema, executionSummarySchema, generateSortingKey, getSqlEnvVarName, isExecutableBlock, isExecutableBlockType, parseYaml, serializeDeepnoteFile, serializeDeepnoteSnapshot, stripMarkdown }; | ||
| export { DeepnoteError, EncodingError, INPUT_BLOCK_TYPES, InvalidValueError, ParseError, ProhibitedYamlFeatureError, SchemaValidationError, UnsupportedBlockTypeError, YamlParseError, convertToEnvironmentVariableName, createMarkdown, createPythonCode, decodeUtf8NoBom, deepnoteBlockSchema, deepnoteFileSchema, deepnoteSnapshotSchema, deserializeDeepnoteFile, environmentSchema, executionErrorSchema, executionSchema, executionSummarySchema, extractOutputText, extractOutputsText, generateSortingKey, getSqlEnvVarName, isAgentBlock, isExecutableBlock, isExecutableBlockType, mcpServerSchema, parseYaml, serializeDeepnoteFile, serializeDeepnoteSnapshot, stripMarkdown }; |
+1
-1
| { | ||
| "name": "@deepnote/blocks", | ||
| "version": "4.4.0", | ||
| "version": "4.5.0", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2698197
1.53%27737
2.26%