App deployment · Carry source as data
App deployment · Carry source as data from the built-in skills in Executor 2.0.0-beta.79.
This page covers Carry source as data from the built-in skills shipped with Executor 2.0.0-beta.79. It contains app-authoring/deploy.md.
Previous: App deployment · Local source with the CLI (continued)
Carry source as data
When source comes from framework.describe or appManagement.source, transform
its files in the same execution and pass them to create or commit. For a small
edit, replace only the affected file content and retain the other files. Check
that the expected text exists before applying a text replacement. Do not print
the entire app and retype it to change one style or operation.
The code-mode skill’s 65,536-character program limit counts source written
into the program, not source it reads with appManagement.source. When new
files do not fit in one program, add them over several executions: each reads
the working source, adds some files and commits the complete list.
If you have a shell and the CLI, use the local CLI path above instead of
serializing files into tool calls. Otherwise, for locally authored files,
generate the { path, content } array with a local
script and JSON serialization. Insert that serialized value as JavaScript data
in the execute payload; keep it out of shell interpolation. JSON handles
quotes, backticks, newlines and literal ${...} without changing the source.
Do not wrap arbitrary source in a manually constructed template literal.
The local script can prepare the payload, but remote execute cannot read a
local path. Submit the actual contents through the available tool interface.
Updating a hosted app
Use the shared commit and deploy workflow to edit an existing app. appManagement.source
reads working Git source; apps.source reads immutable deployed source. Saving
one does not change the other. Read both when you need to compare pending edits
with the running app.
const executor = tools.executor;
const path = { organization: "<approved-organization-id>", app: "<app-id>" };
const source = await executor.appManagement.source({ path });
const entry = source.files.find((file) => file.path === "index.ts");
if (!entry || entry.content.split("<exact old text>").length !== 2) {
throw new Error("Expected one match in index.ts; review the edit.");
}
const files = source.files.map((file) =>
file.path === entry.path
? { ...file, content: file.content.replace("<exact old text>", "<replacement text>") }
: file,
);
const saved = await executor.appManagement.commit({
path,
body: { expected: source.revision.commit, files, message: "Update app" },
});
if (saved.removed.count > 0) {
throw new Error(
`The save removed ${saved.removed.count} files: ${saved.removed.paths.join(", ")}`,
);
}
return await executor.appManagement.deploy({
path,
body: { commit: saved.revision.commit },
});
Commit sends the complete file list; omitted files are deleted. The result’s
removed has their count and at most 100 of their paths; check it before
deploying, as above. A deleted file is still in source.files: add it back and
commit against saved.revision.commit. A stale
expected returns SourceError with reason: "conflict". Read working source
again and reconcile the edits before retrying. Deploying returns { app, version }, preserves the app ID and data, and never updates the Git branch.
It has no expected-active-version argument. Check the app’s linked accounts
after changing account requirements; an account whose provider no requirement
uses no longer applies.
Every call follows the active version, so nothing needs updating to pick up
new code. The next execute lists and calls the new tools. Activating a
version re-registers each webhook source’s subscriptions on it in the
background, usually within seconds, without blocking tool calls; the app’s
Webhooks tab shows their status. A manual (setup) subscription keeps its
callback URL, secret and setup fields while the activated version keeps the same
signingSecret and accepts the same state fields; changing either needs a new setup. It also deletes the saved settings of schedules
the new version no longer declares.
apps.versions lists retained versions. apps.source accepts an optional
query.version to read a specific version. apps.activate requires
body: { version, expectedVersion }, where expectedVersion is the
app’s current active version. A stale value returns AppVersionChanged.
Activation only changes which code runs; it does not reverse app data or changes
made in external services. Source reads and deploys follow the
hosted product’s access rules. Discover tools again in a new execute after changing code.
apps.rename changes the app’s name and the slug derived from it; the app ID,
accounts, links and data stay. A new slug changes the agent namespace
tools.<slug>, the Git clone URL and, on hosted, the page address
appUi.location returns, so old addresses stop working. Local page addresses
use the app ID and do not change. No operation changes the slug alone.
Dependencies and current boundaries
Every app declares the exact apps version in package.json dependencies:
{ "dependencies": { "apps": "<version>" } }. framework.release returns the
version this host runs (executor apps framework in the CLI); a deploy without
it fails and names the same version. That package supplies the server and browser
framework, and the exact version keeps rebuilds on it across host upgrades. Apps
Executor generates, such as imported MCP apps, already declare it. Keep it when
editing, and change it only to upgrade the app. The host retains the compiled framework with each app version. Missing
or unsupported packages fail the build without replacing the active app.
Installation disables lifecycle scripts. Do not depend on the Executor SDK in
app code. Native dependencies that need scripts are unsupported.
Hosted builds currently run with limited memory. A build with very large
dependencies can fail with BuildMemoryExceeded; no new version is activated.
This limit is planned to increase. Report the failure to the user instead of
changing the app. Executor errors include recovery.action for the user and
recovery.instructions for agents; follow those instructions.
App code never runs in the host process; it runs in its own Worker, below, and
cannot start processes or read the host’s files. It receives the fields of
selected accounts. When the provider declares hosts, each string field not
marked plain() or raw() arrives as a handle that Executor’s network replaces
only on requests to those hosts; other fields arrive as their values
(accounts.md). Accounts connected
through an OAuth client the Executor instance provides are the exception: their
credentials are always handles, even when marked plain() or raw(), and work
only in account.headers() on requests to the instance’s hosts that the
provider also declares (accounts.md).
Forward context.signal to fetch or other
interruptible operations. Cancellation and execution limits are cooperative;
completed writes are not rolled back. App-owned storage persists across calls.
Durable background work uses workflows (workflows.md).
Fetch from app code
App code runs on workerd, Cloudflare’s Workers runtime, on every host. Its fetch
accepts the standard RequestInit with three exceptions, which TypeScript’s
types and a local type check do not catch:
redirectmust be"follow"or"manual". To reject redirects, send"manual"and treat a 3xx response as the error.cachemust be"no-store"or"no-cache", or omitted.integritymust be empty or omitted.
ctx.fetch rejects an unsupported value with FetchOptionUnsupported, which
names the option and the values it accepts. A request without a User-Agent
is sent with User-Agent: Executor, because some APIs, such as GitHub’s, answer
403 without one. A User-Agent app code sets is sent unchanged.
App code can reach public hosts with no allowlist, so a 403 or 404 from one is that service’s answer. Executor refuses only requests it must not send:
- To a private, loopback or internal address named in the URL, on Cloud and on
self-host. Local allows them; a self-host operator allows them with
EXECUTOR_APPS_ALLOW_PRIVATE_FETCH=true. - Carrying a credential handle to a host its provider does not allow.
ctx.fetch then rejects with NetworkRefused, whose refusal.reason and
message name the host and the rule. The global fetch instead receives status
421 with the refusal in an x-executor-refused header, as URI-encoded JSON, and
in the body as JSON. A public name that resolves to a private address passes
this check, and the network still refuses it: self-host fails the fetch with a
network error, and Cloud answers with Cloudflare’s own 403 whose body reads
error code: ….
Working: custom tools, API-key and OAuth providers, saved account selection,
retained builds, configured copies, live discovery and tool calls. The local
catalog imports OpenAPI and remote MCP apps. Custom Add also generates GraphQL
apps. OAuth clients can be supplied or resolved through
DCR/CIMD; the host stores and refreshes grants. Private local/self-host app UI,
app data, webhook lifecycle and scheduled mutations are implemented. App-to-app
calls and executor dev remain deferred.