@deepnote/runtime-core

中文文档
0.8.0发布于 2026/11/05Apache-2.0TypeScriptESM + CJS近 30 天下载 3248

Core runtime for executing Deepnote projects

原始使用文档
文档目录9 节
  1. Installation
  2. Prerequisites
  3. Usage
  4. Runtime config
  5. Execution options
  6. Agent block providers
  7. Custom endpoints
  8. Sharing notebooks with Cloud
  9. Result shape

@deepnote/runtime-core

Core runtime for executing Deepnote projects.

This project is under active development and is not ready for use. Expect breaking changes.

Installation

npm install @deepnote/runtime-core

Prerequisites

Node.js 22.14.0 or later is required. Agent blocks use AI SDK 7 and its matching provider packages.

You must have deepnote-toolkit with the server extra installed in your Python environment:

pip install "deepnote-toolkit[server]"

Usage

import { ExecutionEngine } from "@deepnote/runtime-core";

const engine = new ExecutionEngine({
  // Python executable, venv directory, or command in PATH (for example: 'python3')
  pythonEnv: "python",
  workingDirectory: "/path/to/project",
});

try {
  await engine.start();

  const summary = await engine.runFile("./my-project.deepnote", {
    onBlockStart: (block, index, total) => {
      console.log(`Running [${index + 1}/${total}] ${block.type}...`);
    },
    onBlockDone: (result) => {
      console.log(result.success ? "ok" : "failed");
    },
  });

  console.log(
    `Executed ${summary.executedBlocks}/${summary.totalBlocks} blocks in ${summary.totalDurationMs}ms`,
  );
} finally {
  await engine.stop();
}

Runtime config

ExecutionEngine accepts:

  • pythonEnv: string - Python executable or environment path used to launch deepnote-toolkit
  • workingDirectory: string - Working directory for execution
  • serverPort?: number - Optional server port (auto-assigned when omitted)

Execution options

runFile(filePath, options) and runProject(file, options) support:

  • Notebook / block filtering: notebookName, blockId, blockIds
  • Input injection before execution: inputs
  • Database integration metadata for agent block awareness: integrations
  • Cancellation of agent blocks: signal — code and SQL blocks still run to completion, and an aborted agent is reported as a failed block rather than a rejection
  • Callbacks: onBlockStart, onBlockDone, onOutput, onAgentEvent, onServerStarting, onServerReady

Agent block providers

Set metadata.deepnote_agent_model to a model ID. Names starting with claude- select Anthropic; other names select OpenAI. For local runs, use provider:model to choose a provider explicitly, such as anthropic:auto or openai-compatible:llama4.

Without a provider prefix, auto or an omitted model selects OpenAI. An explicit model overrides the provider's model environment variable; otherwise that variable or the default below is used.

ProviderDefault modelAPI keyModel override
openaigpt-6.1-solOPENAI_API_KEYOPENAI_MODEL
anthropicclaude-opus-5-5ANTHROPIC_API_KEYANTHROPIC_MODEL
openai-compatibleMust be setDEEPNOTE_AGENT_API_KEYDEEPNOTE_AGENT_MODEL

Callers that pass apiKey themselves can look up the variable a provider falls back to with getAgentApiKeyEnvVar(parseAgentModel(spec).providerId).

Custom endpoints

Use OPENAI_BASE_URL (including /v1) or ANTHROPIC_BASE_URL (with or without /v1) to override a provider's endpoint. The openai provider always uses the Responses API, so its endpoint must support it.

Other endpoints, such as OpenRouter, Ollama, and LiteLLM, use the openai-compatible provider. It uses Chat Completions and needs a key, endpoint (DEEPNOTE_AGENT_BASE_URL), and a model that supports tool calling. Set the model in the block or use openai-compatible:auto with DEEPNOTE_AGENT_MODEL. Use the endpoint's model IDs; for OpenRouter, for example, openai-compatible:anthropic/claude-opus-5.5.

Sharing notebooks with Cloud

Use auto or a supported model ID without a provider prefix, such as claude-opus-5-5, claude-sonnet-5-5, gpt-6-sol, or gpt-6-luna. Unsupported names, including provider prefixes, use workspace settings instead.

auto uses workspace settings in Cloud and the defaults above locally. Local keys and endpoints do not configure Cloud.

Result shape

Execution methods return ExecutionSummary:

  • totalBlocks
  • executedBlocks
  • failedBlocks
  • totalDurationMs

版本与发布记录

@deepnote/runtime-core 共发布 9 个版本,首次发布于 2026/02/12;过去 12 个月发布了 9 个版本。

版本发布日期距今
0.8.0latest2026/11/056 天前
0.7.02026/10/1230 天前
0.6.02026/10/051 个月前
0.5.02026/08/132 个月前
0.4.02026/06/294 个月前
0.3.02026/03/237 个月前

关于 @deepnote/runtime-core 的常见问题

@deepnote/runtime-core 是什么?

Core runtime for executing Deepnote projects

如何安装 @deepnote/runtime-core?

在项目目录运行 npm install @deepnote/runtime-core,或使用 pnpm add / yarn add / bun add。

@deepnote/runtime-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@deepnote/runtime-core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@deepnote/runtime-core 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.14.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@deepnote/runtime-core 可以商用吗?

@deepnote/runtime-core 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@deepnote/runtime-core 的下载量有多少?

根据 npm 官方下载统计,@deepnote/runtime-core 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,248 次,日均约 108 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@deepnote/runtime-core 还在维护吗?

最新版本 0.8.0 发布于 2026/11/05(6 天前);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2026/02/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。