@dbx-tools/appkit-lakebox

中文文档
0.9.206发布于 2026/11/11Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 4955

AppKit plugin, user services, routes, metrics, and Mastra tools for one app Lakebox

原始使用文档
文档目录9 节
  1. Register the plugin
  2. Connect Mastra to the same runtime
  3. Render the Lakebox UI
  4. Create a service
  5. Use the agent tools
  6. Understand the lifecycle
  7. Configuration
  8. Interactive testing
  9. Understand security and runtime limits

@dbx-tools/appkit-lakebox

Give each authenticated Databricks App user a persistent Linux home, terminal, desktop, OCI image services, agent tools, and machine metrics in one shared Databricks Lakebox.

Register the plugin

import { createApp, lakebase, server } from "@databricks/appkit";
import { lakebox, LakeboxRuntime } from "@dbx-tools/appkit-lakebox";
import { resolveLakeboxPluginConfig } from "@dbx-tools/appkit-lakebox/config";

const runtime = new LakeboxRuntime(resolveLakeboxPluginConfig({ idleTimeoutSeconds: 1_800 }));

await createApp({
  plugins: [server(), lakebase(), lakebox({ runtime })],
});

Lakebase persists the Databricks-assigned Lakebox ID, serializes first creation across app replicas, and retains the last observed service definitions while the machine is stopped. Register AppKit's lakebase() plugin before users access Lakebox routes.

Connect Mastra to the same runtime

Pass the same LakeboxRuntime to the AppKit plugin and Mastra sandbox. This keeps commands, services, routes, metrics, and user accounts on the same Lakebox:

import { createApp, lakebase, server } from "@databricks/appkit";
import { lakebox, LakeboxRuntime } from "@dbx-tools/appkit-lakebox";
import { resolveLakeboxPluginConfig } from "@dbx-tools/appkit-lakebox/config";
import { lakeboxSkillMounts } from "@dbx-tools/appkit-lakebox/skills";
import { lakeboxWorkspaceSandbox } from "@dbx-tools/appkit-lakebox/workspace";
import { agents, mastra } from "@dbx-tools/appkit-mastra";

const runtime = new LakeboxRuntime(resolveLakeboxPluginConfig());
const analyst = agents.createAgent({
  name: "Analyst",
  instructions: "Use the workspace when the task requires files or commands.",
});

await createApp({
  plugins: [
    server(),
    lakebase(),
    lakebox({ runtime }),
    mastra({
      agents: { analyst },
      sandbox: lakeboxWorkspaceSandbox(runtime),
      localSkillMounts: lakeboxSkillMounts(),
    }),
  ],
});

The sandbox resolves the authenticated Mastra user for each request. It doesn't create compute during agent registration. The first command or service starts the Lakebox when auto is enabled.

Render the Lakebox UI

Register the backend plugin, then render the React package in the same application:

import { LakeboxIndicator, LakeboxPanel } from "@dbx-tools/ui-lakebox/react";

export function LakeboxPage() {
  return (
    <>
      <LakeboxIndicator />
      <LakeboxPanel />
    </>
  );
}

Import the package stylesheet after your AppKit UI theme:

@import "@dbx-tools/ui-lakebox/styles.css";

The components read the API base path from the plugin's published client configuration. You don't need to copy route strings or pass Databricks credentials to the browser.

Create a service

Agents call create_lakebox_service. REST clients send POST /api/lakebox/services:

{
  "name": "hello",
  "image": "docker.io/library/python:3.12-alpine",
  "command": ["sh", "-lc", "python -m http.server \"$SERVICE_PORT\" --bind 127.0.0.1"],
  "mounts": [{ "source": "data", "target": "/data" }]
}

The call returns after the service listens. The runtime injects SERVICE_NAME, SERVICE_PATH, SERVICE_PORT, and PORT. Routed services must listen on 127.0.0.1:$SERVICE_PORT. Mount sources are relative to the user's home.

This is a constrained container API, not the Docker CLI. There is no daemon, port publishing, privileged mode, device access, or bridge network. A Lakebox stop and start restarts services from their saved definitions. Process memory does not resume.

Use the agent tools

ToolEffect
get_lakeboxReturns status, the current user's account, and services without creating the Lakebox.
execute_lakebox_commandRun a command as the user's account.
list_lakebox_servicesList the user's services.
create_lakebox_serviceCreate or replace an image service and wait until ready.
start_lakebox_service, stop_lakebox_serviceStart or stop a saved service, terminal, or desktop.
remove_lakebox_serviceDelete a saved service. Requires approval.
get_lakebox_service_logsRead a bounded service log.

The plugin creates or starts the Lakebox for commands and service mutations when auto is enabled. Listing and status operations don't create it.

Understand the lifecycle

The app service principal owns Lakebox lifecycle calls. An on-behalf-of user identity selects that user's Linux account and authorizes routes, but it never creates, starts, stops, or deletes the Databricks resource.

Lifecycle behavior is:

  1. The first explicit start, command, service mutation, or routed request creates the app's Lakebox when none exists.
  2. The runtime starts the Lakebox and restores saved service definitions.
  3. Each authenticated identity maps to a locked non-sudo account with a persistent home and private service ports.
  4. The Databricks platform stops the Lakebox after the configured idle period.
  5. A later request starts it again. User files and saved service definitions persist, but process memory doesn't.

runtime.stop() stops the shared Lakebox for every user. runtime.delete() permanently deletes the Lakebox and every user's files. Normal AppKit shutdown closes SSH sessions and forwarding bridges but leaves idle shutdown to the platform.

Configuration

OptionDefaultDescription
applicationDBX_TOOLS_LAKEBOX_APPLICATION, DATABRICKS_APP_NAME, or the project directoryStable key for the persisted Lakebox resource ID.
idleTimeoutSeconds3600Platform idle timeout, 60 to 86400 seconds.
autotrueCreate or start the Lakebox on demand.
routePrefix/lakeboxAppKit root for service routes.
metricsIntervalSeconds5Sample interval while a client watches metrics.
sshTransportautoauto, openssh, or ssh2.
ssh2PatchautoApply the ssh2 missing-exec-reply workaround only in development, always, or never.
gatewayPort2222Lakebox SSH gateway port.
connectTimeoutMs30000SSH connection timeout.
commandTimeoutMs120000Default command timeout.
keyDirectory~/.dbx-tools/lakeboxOptional server-side SSH key and known-host storage root.

Interactive testing

test/cli.ts runs the real runtime against a workspace profile as any user:

bun packages/js/node/appkit-lakebox/test/cli.ts --profile <profile> --user [email protected] status
bun packages/js/node/appkit-lakebox/test/cli.ts --profile <profile> --user [email protected] exec id
bunx tsx packages/js/node/appkit-lakebox/test/cli.ts --profile <profile> --user [email protected] serve

serve starts that user's terminal and desktop and proxies their routes on http://127.0.0.1:8787.

Pass a configured profile explicitly. In this harness, the profile identity stands in for the app service principal.

Understand security and runtime limits

  • Each app has at most one managed Lakebox. Users share the machine but not Linux accounts, homes, or service ports.
  • Commands and services don't receive Databricks environment variables, forwarded credentials, cookies, or SSH agent access.
  • Service routes fail closed when a non-loopback request has no authenticated identity.
  • Image services run with private PID, IPC, mount, and user namespaces. They share host networking and must bind only to the injected loopback port.
  • Metrics cover machine CPU, memory, persistent storage, and network counters. They don't expose process data and are sampled only while a client watches.
  • Lakebase is required for app resource identity, replica convergence, and last-known service definitions.

版本与发布记录

@dbx-tools/appkit-lakebox 共发布 51 个版本,首次发布于 2026/10/15;过去 12 个月发布了 51 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.9.206latest2026/11/11今天
0.9.2052026/11/111 天前
0.9.2032026/11/074 天前
0.9.2022026/11/065 天前
0.9.2012026/11/056 天前
0.9.2002026/11/056 天前

关于 @dbx-tools/appkit-lakebox 的常见问题

@dbx-tools/appkit-lakebox 是什么?

AppKit plugin, user services, routes, metrics, and Mastra tools for one app Lakebox

如何安装 @dbx-tools/appkit-lakebox?

在项目目录运行 npm install @dbx-tools/appkit-lakebox,或使用 pnpm add / yarn add / bun add。

@dbx-tools/appkit-lakebox 支持 TypeScript 吗?

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

@dbx-tools/appkit-lakebox 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dbx-tools/appkit-lakebox 可以商用吗?

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

@dbx-tools/appkit-lakebox 的下载量有多少?

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

@dbx-tools/appkit-lakebox 还在维护吗?

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