base44-sandbox
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBase44 in the Cloud Sandbox
Base44 云沙箱开发
Author Base44 app code inside Base44's cloud sandbox with your own coding agent. There is no local checkout: you read, write, and run files through the sandbox tools (over MCP or the CLI), and the platform builds and deploys from what you write.
base44 sandboxFor how to connect to the sandbox (MCP endpoint or the CLI, the / / / / / / tools — which the CLI exposes under shorter names ( / / / / / / ), the edit→preview→verify loop, persistence, and concurrency), use the skill. This skill covers what you can author and how once you are connected.
base44 sandboxread_filewrite_fileedit_filerun_commandgreplist_directorycreate_checkpointsandbox readsandbox writesandbox editsandbox runsandbox grepsandbox lssandbox checkpointbase44-remote-devCheck these references first. This skill and its siblings (,base44-remote-dev) are the source of truth — consult them before searching the web. See Reference order & the complete README.base44-sdk
使用您自己的编码Agent在Base44云沙箱中编写Base44应用代码。无需本地检出:您可通过沙箱工具(基于MCP或 CLI)读取、写入和运行文件,平台会根据您编写的内容进行构建和部署。
base44 sandbox如需了解如何连接沙箱(MCP端点或 CLI,//////工具——CLI中使用更短的命令别名://////)、编辑→预览→验证流程、持久化及并发机制,请使用****技能。本技能将介绍连接成功后,您可创建的内容及具体方法。
base44 sandboxread_filewrite_fileedit_filerun_commandgreplist_directorycreate_checkpointsandbox readsandbox writesandbox editsandbox runsandbox grepsandbox lssandbox checkpointbase44-remote-dev⚡ The mental model: writing the file is the deploy
⚡ 核心思路:写入文件即完成部署
You are working on a remote app, not a local checkout. The project-level CLI workflow does not apply — never run , , , , or . They assume a local project and a manual deploy step that does not exist here.
base44 deploybase44 functions deploybase44 ... pushbase44 createbase44 scaffoldInstead: as soon as you write a resource file into the sandbox — a backend function, an entity, or an agent — the platform deploys/syncs it from there. Your write is auto-committed (~5s debounce) and goes live. You do not run, and must not wait for, any / command.
deploypushOne exception — connectors. OAuth connectors aren't authored as files; they're set up against the remote app by its id, either with the MCP connector tools or with the dedicated, projectless commands (which take and need no local project). See Connectors below.
base44 connectors--app-idYou may still use ( in the CLI) for ordinary checks (e.g. , , ) and preview — that is verification, not deployment. See the edit→preview→verify loop in .
run_commandsandbox runnpm run buildnpx tsc --noEmitnpm run lintbase44-remote-dev您正在开发的是远程应用,而非本地检出的项目。项目级CLI工作流不适用——切勿运行、、、或命令。这些命令假设存在本地项目及手动部署步骤,而在本场景中这些都不存在。
base44 deploybase44 functions deploybase44 ... pushbase44 createbase44 scaffold取而代之的是:一旦您将资源文件(后端函数、实体或Agent)写入沙箱,平台就会从沙箱中部署/同步该文件。您的写入操作会自动提交(约5秒防抖)并生效。您无需运行,也不必等待任何/命令。
deploypush一个例外——连接器。OAuth连接器并非通过文件编写,而是通过应用ID针对远程应用进行配置,可使用MCP连接器工具或专用的无项目命令(需指定,无需本地项目)。详见下方 连接器 部分。
base44 connectors--app-id您仍可使用(CLI中为)进行常规检查(例如、、)和预览——这属于验证操作,而非部署。请查看技能中的编辑→预览→验证流程。
run_commandsandbox runnpm run buildnpx tsc --noEmitnpm run lintbase44-remote-devWhat you can author today
当前支持创建的资源
| Resource | Status in the sandbox |
|---|---|
Backend functions ( | ✅ Supported — write the files; they deploy from the sandbox. |
Entities ( | ✅ Supported — write the |
Agents ( | ✅ Supported — write the |
Frontend code ( | ✅ Supported — edit normally; HMR/preview reflects it. Use the |
| Connectors (OAuth integrations) | ✅ Supported — set up via the connect flow below (MCP tools or |
| 资源类型 | 沙箱支持状态 |
|---|---|
后端函数 ( | ✅ 已支持 — 编写文件即可;文件会从沙箱自动部署。 |
实体 ( | ✅ 已支持 — 编写 |
Agent ( | ✅ 已支持 — 编写 |
前端代码 ( | ✅ 已支持 — 正常编辑即可;HMR/预览会实时反映变更。如需SDK API使用方法,请参考** |
| 连接器(OAuth集成) | ✅ 已支持 — 通过下方连接流程配置(MCP工具或 |
Backend functions
后端函数
Backend functions live in , one directory per function (kebab-case name). In the sandbox you only need to create the file directly under — no is required (the sandbox infers the function from the directory; the config file is ignored in this mode):
base44/functions/entry.tsbase44/functions/<name>/function.jsoncbase44/functions/
process-order/
entry.tsEntry file — functions run on Deno (not Node.js), export with , and use the prefix for npm packages:
Deno.serve()npm:typescript
import { createClientFromRequest } from "npm:@base44/sdk";
Deno.serve(async (req) => {
const base44 = createClientFromRequest(req); // inherits the caller's auth
const { orderId } = await req.json();
const order = await base44.entities.Orders.get(orderId);
return Response.json({ success: true, order });
});Conventions:
- Kebab-case directory and function name; entry typically .
entry.ts - for a client in the caller's auth context;
createClientFromRequest(req)for admin-level operations.base44.asServiceRole.… - Read secrets with (configured in app settings).
Deno.env.get("KEY") - Return with ; handle errors and set appropriate status codes.
Response.json(body, { status })
That's enough to author functions correctly. For deeper detail and more examples (service role, secrets, common mistakes), see the skill's reference: — but ignore its "Deploying Functions" / CLI sections and its guidance, which assume a local project and do not apply in the sandbox (here you only write ).
base44-clifunctions-create.mdfunction.jsoncentry.tsCalling the function from the frontend:returns the raw axios response — your function's JSON is onbase44.functions.invoke(name, data)(.data), not the top-level object, and it throws on non-2xx (error body atconst result = res.data). See theerr.response.dataskill'sbase44-sdkfor details.functions.md
后端函数位于目录下,每个函数对应一个短横线命名(kebab-case)的目录。在沙箱中,您只需直接在下创建****文件即可——无需文件(沙箱会从目录推断函数信息;此模式下配置文件会被忽略):
base44/functions/base44/functions/<name>/entry.tsfunction.jsoncbase44/functions/
process-order/
entry.ts入口文件——函数运行在Deno(而非Node.js)环境中,需通过导出,并使用前缀引入npm包:
Deno.serve()npm:typescript
import { createClientFromRequest } from "npm:@base44/sdk";
Deno.serve(async (req) => {
const base44 = createClientFromRequest(req); // 继承调用方的认证信息
const { orderId } = await req.json();
const order = await base44.entities.Orders.get(orderId);
return Response.json({ success: true, order });
});约定:
- 目录和函数名称使用短横线命名(kebab-case);入口文件通常为。
entry.ts - 使用获取调用方认证上下文的客户端;使用
createClientFromRequest(req)执行管理员级操作。base44.asServiceRole.… - 使用读取密钥(在应用设置中配置)。
Deno.env.get("KEY") - 使用返回响应;处理错误并设置合适的状态码。
Response.json(body, { status })
以上内容足以让您正确编写函数。如需更深入的细节和更多示例(服务角色、密钥、常见错误),请查看技能的参考文档:——但请忽略其中的“部署函数”/CLI部分以及****相关指导,这些内容假设存在本地项目,不适用于沙箱环境(在此环境中您只需编写)。
base44-clifunctions-create.mdfunction.jsoncentry.ts从前端调用函数:返回原始axios响应——函数返回的JSON数据位于**base44.functions.invoke(name, data)属性中(.data),而非顶层对象;且当响应状态码非2xx时会抛出错误**(错误体位于const result = res.data)。如需详情,请查看err.response.data技能的base44-sdk。functions.md
Entities
实体
One file per entity in . Just write the file — it auto-syncs; don't run or .
.jsoncbase44/entities/base44 entities pushdeploy- File name: — e.g.
{kebab-case}.jsoncfor an entity namedteam-member.jsonc.TeamMember - Entity : PascalCase, alphanumeric only (
name)./^[a-zA-Z0-9]+$/ - Field names: .
snake_case
jsonc
// base44/entities/task.jsonc
{
"name": "Task",
"type": "object",
"properties": {
"title": { "type": "string", "description": "Task title" },
"status": { "type": "string", "enum": ["todo", "doing", "done"], "default": "todo" },
"due_date": { "type": "string", "format": "date" },
"board_id": { "type": "string", "description": "Owning board" }
},
"required": ["title"]
}Field types: , , , , , , . String formats include , , , , , , . For full schema detail and row-level security (RLS), see the references and — but ignore their / deploy sections; the sandbox syncs the file for you.
stringnumberintegerbooleanarrayobjectbinarydatedate-timeemailuriuuidfilerichtextbase44-clientities-create.mdrls-examples.mdentities push每个实体对应目录下的一个文件。只需编写文件——文件会自动同步;切勿运行或命令。
base44/entities/.jsoncbase44 entities pushdeploy- 文件名:——例如,名为
{短横线命名}.jsonc的实体对应TeamMember。team-member.jsonc - 实体:大驼峰命名(PascalCase),仅包含字母数字(
name)。/^[a-zA-Z0-9]+$/ - 字段名:蛇形命名(snake_case)。
jsonc
// base44/entities/task.jsonc
{
"name": "Task",
"type": "object",
"properties": {
"title": { "type": "string", "description": "任务标题" },
"status": { "type": "string", "enum": ["todo", "doing", "done"], "default": "todo" },
"due_date": { "type": "string", "format": "date" },
"board_id": { "type": "string", "description": "所属看板" }
},
"required": ["title"]
}字段类型包括:、、、、、、。字符串格式包括、、、、、、。如需完整的schema细节和行级安全(RLS)相关内容,请查看技能的参考文档和——但请忽略其中的/部署部分;沙箱会自动同步文件。
stringnumberintegerbooleanarrayobjectbinarydatedate-timeemailuriuuidfilerichtextbase44-clientities-create.mdrls-examples.mdentities pushAgents
Agent
One file per agent in . Just write the file — it auto-syncs; don't run or .
.jsoncbase44/agents/base44 agents pushdeploy- File name: — e.g.
{agent_name}.jsonc.support_agent.jsonc - Agent :
name(lowercase, underscores, 1–100 chars)./^[a-z0-9_]+$/
jsonc
// base44/agents/support_agent.jsonc
{
"name": "support_agent",
"description": "Brief description of what this agent does",
"instructions": "Detailed instructions for the agent's behavior",
"tool_configs": [
{ "entity_name": "tasks", "allowed_operations": ["read", "create", "update", "delete"] },
{ "function_name": "send_email", "description": "Send an email notification" }
],
"whatsapp_greeting": "Hello! How can I help you today?"
}Required: , , . Optional: (default ), . Tool configs are either an entity tool ( + : any of ///) or a backend-function tool ( + ). For the full agent schema, see the Agent Schema section of the skill's — but ignore its / / deploy commands, which assume a local project; in the sandbox the file auto-syncs.
namedescriptioninstructionstool_configs[]whatsapp_greetingentity_nameallowed_operationsreadcreateupdatedeletefunction_namedescriptionbase44-cliSKILL.mdagents pushagents pull每个Agent对应目录下的一个文件。只需编写文件——文件会自动同步;切勿运行或命令。
base44/agents/.jsoncbase44 agents pushdeploy- 文件名:——例如
{agent_name}.jsonc。support_agent.jsonc - Agent :
name(小写字母、下划线,长度1-100字符)。/^[a-z0-9_]+$/
jsonc
// base44/agents/support_agent.jsonc
{
"name": "support_agent",
"description": "该Agent功能的简要描述",
"instructions": "该Agent行为的详细指令",
"tool_configs": [
{ "entity_name": "tasks", "allowed_operations": ["read", "create", "update", "delete"] },
{ "function_name": "send_email", "description": "发送邮件通知" }
],
"whatsapp_greeting": "您好!请问我能为您提供什么帮助?"
}必填字段:、、。可选字段:(默认)、。工具配置可以是实体工具( + :可选///中的任意组合)或后端函数工具( + )。如需完整的Agent schema,请查看技能中的Agent Schema部分——但请忽略其中的//部署命令,这些内容假设存在本地项目;在沙箱环境中文件会自动同步。
namedescriptioninstructionstool_configs[]whatsapp_greetingentity_nameallowed_operationsreadcreateupdatedeletefunction_namedescriptionbase44-cliSKILL.mdagents pushagents pullConnectors (OAuth integrations)
连接器(OAuth集成)
Connectors (Google Calendar, Gmail, Slack, …) give your backend functions tokens to call third-party APIs. In remote-dev there are no connector files to write — you operate on the connector directly against the app by its id. Two surfaces, same backend and same behavior:
Declarative scopes — read before you set. Connecting a connector replaces its scope set with exactly the scopes you pass (it does not merge). Any scope you omit is removed and the user is re-prompted to consent. Always list the connector's current scopes first and pass the complete desired set (the ones you want to keep plus any new ones).
OAuth needs a human. Connecting returns an authorization URL the user must open in a browser to sign in and consent — you cannot complete it yourself. After they finish, re-list to confirm it's connected and to read the granted scopes (a provider may grant fewer than you requested).
连接器(Google日历、Gmail、Slack等)为后端函数提供调用第三方API的令牌。在远程开发场景中,无需编写连接器文件——您只需通过应用ID直接操作远程应用的连接器。有两种操作方式,底层逻辑和行为一致:
声明式权限范围——配置前请阅读。连接连接器会替换其现有的权限范围集合,完全使用您传入的权限范围(不会合并)。任何您未列出的权限范围都会被移除,用户需重新授权同意。请始终先列出连接器当前的权限范围,再传入完整的期望集合(保留现有权限范围 + 添加新权限范围)。
OAuth需要人工操作。连接操作会返回一个授权URL,用户必须在浏览器中打开该URL进行登录和授权——您无法自行完成此步骤。用户完成授权后,重新列出连接器即可确认已连接,并读取已授予的权限范围(服务商可能会授予比您请求更少的权限)。
Over MCP (base44-remote-dev
transport)
base44-remote-dev通过MCP(base44-remote-dev
传输方式)
base44-remote-devTwo tools, both taking . Scopes: needs ; needs (note: not ).
appIdlist_connectorsapps:readinitiate_connector_connectionapps:writesandbox:write- —
list_connectors. With no{ appId, integrationTypes? }, returns the full catalog; each entry has the connector's name, description, whether it's connected, and (if connected) its status and granted scopes. PassintegrationTypesfor full detail on specific connectors.integrationTypes - —
initiate_connector_connection.{ appId, integrationType, scopes, connectionConfig? }is the complete desired set (see the declarative-scopes note). Returns eitherscopes(nothing to do) or aalready_authorized: truefor the user to open. After they sign in, callredirect_urlagain to verify.list_connectors
On appId <APP_ID>: call list_connectors to read googlecalendar's current scopes,
then initiate_connector_connection for googlecalendar with the full scope set
(existing + the calendar.events scope I need). Give me the authorization URL.有两个工具,均需传入。权限范围:需要;需要(注意:不是)。
appIdlist_connectorsapps:readinitiate_connector_connectionapps:writesandbox:write- — 参数为
list_connectors。若不传入{ appId, integrationTypes? },则返回完整的连接器目录;每个条目包含连接器名称、描述、是否已连接,以及(若已连接)状态和已授予的权限范围。传入integrationTypes可获取特定连接器的详细信息。integrationTypes - — 参数为
initiate_connector_connection。{ appId, integrationType, scopes, connectionConfig? }为完整的期望权限范围集合(请查看声明式权限范围的注意事项)。返回结果要么是scopes(无需操作),要么是供用户打开的already_authorized: true。用户登录后,再次调用redirect_url验证连接状态。list_connectors
针对appId <APP_ID>:调用list_connectors读取googlecalendar的当前权限范围,然后使用完整的权限范围集合(现有权限 + 我需要的calendar.events权限)调用initiate_connector_connection连接googlecalendar。请提供授权URL。Over the CLI (projectless, --app-id
)
--app-id通过CLI(无项目,使用--app-id
)
--app-idThese subcommands work without a local project — they resolve the app id from , then , then a local . No is required.
base44 connectors--app-idBASE44_APP_ID.app.jsoncconfig.jsoncbash
undefined这些子命令无需本地项目即可运行——它们会从、环境变量或本地文件中解析应用ID。无需文件。
base44 connectors--app-idBASE44_APP_ID.app.jsoncconfig.jsoncbash
undefined1. See available integration types for the app
1. 查看应用可用的集成类型
npx base44 connectors list-available --app-id <APP_ID>
npx base44 connectors list-available --app-id <APP_ID>
2. Initialize the connector and start OAuth (sets it to EXACTLY these scopes).
2. 初始化连接器并启动OAuth(将权限范围设置为完全匹配以下列表)。
Non-interactive: prints the authorization URL. Interactive: also opens the
非交互式:打印授权URL。交互式:同时打开浏览器并轮询直到授权完成。
browser and polls until authorized.
—
npx base44 connectors initiate --app-id <APP_ID>
--integration-type googlecalendar
--scopes https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar.events
--integration-type googlecalendar
--scopes https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar.events
npx base44 connectors initiate --app-id <APP_ID>
--integration-type googlecalendar
--scopes https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar.events
--integration-type googlecalendar
--scopes https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar.events
3. (optional) Fetch the resulting connector config
3.(可选)获取生成的连接器配置
npx base44 connectors pull --app-id <APP_ID> --dir ./connectors
`--scopes` accepts a space- or comma-separated list. As with MCP, the user must open the printed authorization URL to finish consent; afterwards `list-available` / `pull` reflects the connected state and granted scopes.
> This is the **only** Base44 CLI use that belongs in remote-dev — it targets a remote app by id with no local project and no deploy step. It is not a contradiction of the "no CLI" rule above, which is about local-project/deploy commands.npx base44 connectors pull --app-id <APP_ID> --dir ./connectors
`--scopes`接受空格或逗号分隔的权限范围列表。与MCP方式相同,用户必须打开打印的授权URL完成授权;之后`list-available`/`pull`命令会反映连接器的连接状态和已授予的权限范围。
> 这是远程开发场景中唯一适用的Base44 CLI用法——它通过ID定位远程应用,无需本地项目和部署步骤。这与上文提到的“禁用CLI”规则并不矛盾,该规则针对的是本地项目/部署命令。Using a connected connector in code
在代码中使用已连接的连接器
Connecting only authorizes the connector. To actually call the third-party API, fetch its OAuth access token inside a backend function with the service-role connectors module — — and use the returned (and optional ) in your own :
base44.asServiceRole.connectors.getConnection(integrationType)accessTokenconnectionConfigfetchtypescript
import { createClientFromRequest } from "npm:@base44/sdk";
Deno.serve(async (req) => {
const base44 = createClientFromRequest(req);
// App-scoped OAuth token — backend / service role only.
const { accessToken, connectionConfig } =
await base44.asServiceRole.connectors.getConnection("googlecalendar");
const events = await fetch(
"https://www.googleapis.com/calendar/v3/calendars/primary/events",
{ headers: { Authorization: `Bearer ${accessToken}` } },
).then((r) => r.json());
return Response.json({ events });
});Notes: the connector is app-scoped (one connected account shared by all users); Base44 refreshes the token for you; you make the API calls. replaces the deprecated . For the full module reference (signatures, , the list of available services and their type identifiers), see the skill's .
getConnection()getAccessToken()connectionConfigbase44-sdkconnectors.md连接操作仅完成连接器的授权。要实际调用第三方API,需在后端函数中通过服务角色连接器模块获取OAuth访问令牌————并使用返回的(可选)执行自定义请求:
base44.asServiceRole.connectors.getConnection(integrationType)accessTokenconnectionConfigfetchtypescript
import { createClientFromRequest } from "npm:@base44/sdk";
Deno.serve(async (req) => {
const base44 = createClientFromRequest(req);
// 应用级OAuth令牌——仅后端/服务角色可用。
const { accessToken, connectionConfig } =
await base44.asServiceRole.connectors.getConnection("googlecalendar");
const events = await fetch(
"https://www.googleapis.com/calendar/v3/calendars/primary/events",
{ headers: { Authorization: `Bearer ${accessToken}` } },
).then((r) => r.json());
return Response.json({ events });
});注意:连接器为应用级(所有用户共享一个已连接的账户);Base44会自动刷新令牌;您需自行实现API调用。已替代过时的。如需完整的模块参考(方法签名、、可用服务列表及其类型标识符),请查看技能的。
getConnection()getAccessToken()connectionConfigbase44-sdkconnectors.mdReference order & the complete README
参考顺序与完整README
Consult the references in this skill and its sibling skills (, ) before searching the web. They are the source of truth for the sandbox bridge, file/resource conventions, and SDK APIs — prefer them over general internet results, which are often stale or wrong for Base44.
base44-remote-devbase44-sdkFor the complete, app-specific remote-dev reference (instructions + every endpoint, public, no auth needed to fetch), read the onboarding README for your app:
https://app.base44.com/api/sandbox/<APP_ID>/local-agent/readme.md(The cloud/MCP equivalent is .) See the skill for the connection mechanics this README describes.
…/api/sandbox/<APP_ID>/claude-web/readme.mdbase44-remote-dev请先查阅本技能及其姊妹技能(、)中的参考资料,再搜索网络。这些资料是沙箱桥接、文件/资源约定和SDK API的权威来源——优先使用它们,而非互联网上的通用结果,因为通用结果往往过时或不适用于Base44。
base44-remote-devbase44-sdk如需完整的、特定于应用的远程开发参考资料(说明 + 所有端点,公开访问,无需认证),请查看您应用的入门README:
https://app.base44.com/api/sandbox/<APP_ID>/local-agent/readme.md(云端/MCP对应的地址为)。请查看技能了解该README中描述的连接机制。
…/api/sandbox/<APP_ID>/claude-web/readme.mdbase44-remote-devWorkflow in the sandbox
沙箱中的工作流程
- Orient — /
list_directory/read_file(grep/sandbox ls/sandbox readin the CLI) to understand the app before changing anything.sandbox grep - Author — create or edit resource files (backend functions, entities, agents) and frontend code following the conventions above; set up connectors via the connect flow.
- Verify — optionally (
run_command)sandbox run/npm run build, and usenpx tsc --noEmitto eyeball changes (seeget_app_preview_url).base44-remote-dev - Let it ship — do nothing to deploy. Writing the file is the deploy; the auto-commit (~5s) persists and ships it. Pause a moment after your last edit before disconnecting so the commit lands.
- (Optional) Checkpoint — mark a known-good restore point the user can roll back to with (
create_checkpointin the CLI). It flushes pending changes first, so the checkpoint captures your latest code. Seebase44 sandbox checkpoint --name "..."for details.base44-remote-dev
- 定位 — 使用/
list_directory/read_file(CLI中为grep/sandbox ls/sandbox read)了解应用现状后再进行修改。sandbox grep - 开发 — 按照上述约定创建或编辑资源文件(后端函数、实体、Agent)和前端代码;通过连接流程配置连接器。
- 验证 — 可选择使用(CLI中为
run_command)执行sandbox run/npm run build,并使用npx tsc --noEmit查看变更效果(请查看get_app_preview_url技能)。base44-remote-dev - 自动发布 — 无需执行任何部署操作。写入文件即完成部署;自动提交(约5秒)会持久化并发布变更。断开连接前请稍作等待,确保提交已完成。
- (可选)创建检查点 — 使用(CLI中为
create_checkpoint)标记一个已知的良好恢复点,用户可通过该点回滚。该命令会先刷新待处理的变更,因此检查点会包含您的最新代码。详情请查看base44 sandbox checkpoint --name "..."技能。base44-remote-dev