Extensions
Ende 2026.12.01
Extensions are new in this release.
An extension is a module your app imports as extension:@scope/name. It runs in
a worker of its own with only the permissions that ende.json grants it, not
the app's. Use one for plugins and other code you want to run without handing
it everything your app may do.
An extension's permissions don't depend on the app's: it may be granted
something the app itself wasn't given, and -A doesn't widen it. To run an
ordinary dependency with less than the app has, use
per-package permissions
instead.
| Extensions | Per-package permissions | |
|---|---|---|
Declared in ende.json under |
extensions |
isolate |
| Imported as | extension:@scope/name |
the dependency's usual specifier |
| May get more than the app has | yes | no: never more than the app |
| Exports that cross | named functions | functions, classes, constants |
Manifest (export const manifest) |
required | optional |
Code pinned in ende.lock |
every file, local sources included | remote and jsr: code; local isn't |
| The app may write its config | no | yes |
A first extension
An extension lives in a folder of its own. This one reads a name from the
data folder:
export const manifest = {
permissions: { read: true }
};
export async function greet(file: string): Promise<string> {
const name = (await Ende.readTextFile(file)).trim();
return `Hello, ${name}!`;
}Declare it in ende.json with its source and what it is granted:
{
"extensions": {
"@acme/greet": {
"source": "./ext/greet/mod.ts",
"permissions": { "read": ["./data"] }
}
}
}Then import it with the extension: scheme. Its functions return promises:
import { greet } from "extension:@acme/greet";
console.log(await greet("./data/name.txt"));$ ende run main.ts
Recorded extension "@acme/greet" in ende.lock; it will run with: read /Users/me/app/data
Hello, Ada!
The app ran with no permission flags. The extension read data/name.txt with
its own grant. The first run recorded the extension in ende.lock; later runs
check it against that record (see Approving changes).
Declaring an extension
Each key under extensions is the extension's name, @scope/name in lowercase
letters, digits and hyphens. Each entry has two fields, both required:
source: the extension's entry module. A path relative toende.jsonthat starts with./or../, afile:orhttps:URL, or ajsr:package.permissions: what the extension is granted.[]grants nothing, a list of names (["read", "net"]) grants each whole kind, and an object grants scoped permissions in the form of a permission set, with relative paths resolved againstende.json.
The ende.json reference lists
every form and the errors for each field.
extensions goes in the workspace root's ende.json. In a workspace member's
ende.json it is an error wherever it would apply: an extension: import,
type checking (even when nothing imports an extension), and ende install,
ende ci, ende cache and ende grants:
$ ende check member/mod.ts
error: "extensions" can only be specified in the workspace root ende.json file. Move them from file:///Users/me/app/member/ende.json to file:///Users/me/app/ende.json, with local sources rewritten relative to it.
A package the root lists under links may declare extensions of its own. They
don't apply: Ende ignores them with a warning, which --quiet hides, and
importing one fails. Declare them in the root's ende.json, with sources
relative to it:
$ ende run use_ext.ts
Warning "extensions" in a linked package's ende.json doesn't apply: a linked package's extensions are ignored. To use them, declare them in file:///Users/me/app/ende.json, with sources relative to that file.
at file:///Users/me/linked/ende.json
error: Unknown extension "@acme/e". ende.json declares no extensions
A missing permissions field is an error, so no extension runs with
permissions nobody wrote down:
$ ende run main.ts
error: extensions["@acme/x"].permissions is required. Use [] to grant no permissions.
A local extension's imports may load any file in its folder, and the app may
not write to that folder. Reading those files at run time, with
Ende.readTextFile() for example, still needs a read grant. So a local source must be in a folder of its own, below the one
that holds ende.json:
$ ende run main.ts
error: extensions["@acme/x"].source "./root.ts" is in the folder that holds ende.json, or above it. A local extension can read its whole folder, and the app can't write to it, so give it a folder of its own, like "./ext/x/mod.ts".
An extension resolves its own imports without the app's import map: each import
has to work as written, as a relative path, a URL or a jsr: specifier. A local
extension's static imports may only read files in its own folder, and a remote
or jsr: extension's may read no local files. An import from elsewhere is
denied whatever flags the app runs with, so move the file into the extension's
folder.
The manifest
An extension's entry module must export a manifest that says which
permissions it needs:
export const manifest = {
permissions: { read: true, net: ["api.example.com"] }
};
Ende reads the manifest from the source without running it, so it must be an
export const of literals: objects, arrays, strings and booleans.
permissions is a list of names or an object of true, false or lists. File
system entries (read, write, ffi) are true or absolute paths, never
relative ones: an extension doesn't know where the app keeps its files, so it
asks for true and the grant in ende.json names the paths.
The extension runs with what both allow: the grant in ende.json intersected
with the manifest. A grant the manifest doesn't ask for isn't given. When the
manifest asks for something the grant doesn't give, the extension still loads,
with a warning, and using it is denied:
$ ende run main.ts
Warning Extension "@acme/greet" asks for permissions that ende.json doesn't grant, so using them will be denied:
env "HOME": add it to extensions["@acme/greet"].permissions.env
Hello, Ada!
A module without a manifest isn't an extension:
$ ende run main.ts
error: Invalid extension "@acme/x" (file:///Users/me/app/ext/nomani/mod.ts): it has no manifest. Add `export const manifest = { permissions: [] }` and list the permissions it needs.
What an extension exports
An extension exports named functions, and the app calls them across the worker boundary:
- Every call is async. A function that returns a value in the extension returns a promise of it in the app.
- Arguments and results are copied with
structured clone.
A function can't be passed: the call fails with a
DataCloneError. - An error thrown in the extension is rethrown in the app with its message,
name and stack. A built-in class, such as
TypeErrororEnde.errors.NotFound, is kept. A class of the extension's own arrives as a plainErrorwith that class'sname, andcauseisn't kept. - An
Ende.Rootpassed as an argument is handed over, not copied. In an extension it carries no authority of its own: the extension's own permissions still decide every operation. - Any other export with a value, such as a class, a constant or a default export, is an error when the extension loads. Type-only exports are fine.
$ ende run main.ts
error: Invalid extension "@acme/x" (file:///Users/me/app/ext/bad/mod.ts:3:8): export "Widget" is not a function. An extension only exports functions, which the app calls across the sandbox.
ende check and the editor see each function with its own parameters and a
promise of its result, so calling one as if it were synchronous is a type
error:
$ ende check badtype.ts
Check badtype.ts
TS2322 [ERROR]: Type 'Promise<string>' is not assignable to type 'string'.
const s: string = greet("./data/name.txt");
^
An extension: name has to be declared in ende.json:
$ ende run undeclared.ts
error: Unknown extension "@acme/gret". ende.json declares @acme/greet
Permissions at run time
An extension never prompts. Anything outside its permissions is denied, and the error names the extension and the grant to add:
$ ende run -A outside.ts
error: Uncaught (in promise) NotCapable: @acme/greet: Requires read access to "./secret.txt". Grant it in ende.json under extensions["@acme/greet"].permissions.read (the extension's manifest must ask for it too)
Here the app ran with -A, and the extension was still denied: the app's
permission flags don't apply to an extension, and neither does a
Ende.permissions.revoke() in the app. A
permission broker can deny
an extension's request, but it can't allow more than the extension's own
permissions.
A write grant has limits too. Outside its own folder, an extension never
creates or writes a file whose name Ende could load as code (a .ts, .js,
.json, .wasm or native library name), and never makes a file executable: a
later run could load that file with the app's permissions. Store data under
another name, such as notes.jsonl rather than notes.json:
$ ende run main.ts
error: Uncaught (in promise) NotCapable: @demo/notes: Requires write access to "./data/notes.json", which is a file Ende could load as code (by its extension), and no sandbox or extension may write code outside its own folder: it could run with the app's permissions on a later run
Config files and lockfiles are refused the same way. See What a sandbox can't write for the full list, which applies to extensions too.
Approving changes
The lockfile pins every extension: its source, a hash of its code, its manifest
and its grant. For a local source, the code is every file in its folder. For a
remote or jsr: source, it is every module the extension imports.
The first time Ende sees an extension, it records it in ende.lock and prints
what it will run with. That line shows even with --quiet. Adding an extension
to ende.json is the approval: it isn't asked about again.
After that, a run whose extension differs from the record stops before the extension starts:
$ ende run main.ts
error: Extension "@acme/greet" changed since ende.lock approved it: its grant in ende.json. Run `ende install` to review the change and approve it.
ende install
shows each change and asks:
$ ende install
Extension "@acme/greet" changed:
grant (ende.json):
- {"read":["./data"]}
+ {"read":["./data"],"net":["api.example.com"]}
it will run with: read /Users/me/app/data
Approve these extension changes? [y/N] y
Recorded the approved changes to extension "@acme/greet" in ende.lock.
The prompt needs stdin and stderr on a terminal. Without one, ende install
prints the change and refuses; ende install --yes approves without asking. A
frozen lockfile can't take the approval.
ende ci never approves a change: its error names
the ende install command to run locally, and you commit the updated
ende.lock.
Warning
Deleting ende.lock drops every approval. The next run records each
extension again as it is now, printing only the Recorded … line. Ende
2026.11.10 and earlier don't know the extensions section, so when one of
them rewrites the lockfile, the section is dropped the same way.
Extensions need the lockfile. "lock": false in ende.json is an error while
extensions are declared. --no-lock runs them unpinned, with a warning that
--quiet doesn't hide:
$ ende run --no-lock main.ts
Warning Extension "@acme/greet" runs unpinned: --no-lock turned off the lockfile, so changes to its code, manifest or grant aren't checked.
Hello, Ada!
What the app can't change
While extensions are declared, the app can't write a local extension's folder,
the root ende.json, the lockfile or the vendor folder, even with -A:
$ ende run -A appwrites.ts
Hello, Ada!
NotCapable: Requires write access to "./ext/greet/mod.ts", which is in the directory of extension "@acme/greet" declared in ende.json. An extension's source can't change while the app runs
NotCapable: Requires write access to "./ende.json", which declares this app's extensions. Edit it outside the app, then run `ende install`
NotCapable: Requires write access to "./ende.lock", which pins this app's extensions. Run `ende install` to change it
Otherwise the app could rewrite an extension, or its grant, and get the
extension's permissions. A subprocess isn't held to this. An app run with
--allow-run can change an extension's code and grant through a subprocess,
and can delete ende.lock too: the next run then records the changed extension
with only a Recorded … line. Don't give --allow-run to an app whose
extensions hold permissions the app itself shouldn't have.
Limits
An extension is a worker in the same process, with its own permissions. That boundary doesn't cover everything:
runandffican escape. A subprocess or native code ignores Ende's permissions, so an extension granted either can do anything the user can. So can one granted unscopedwrite, which could change the app's code; theRecorded …line says so.envandsysare process-wide. Environment variables set by an extension are seen by the app and every other worker.- No CPU or memory isolation. An extension can use as much CPU time and memory as it likes, and a call that never returns keeps the app waiting. Timing side channels between threads aren't addressed.
- Not supported:
ende compileandende desktop(they refuse an app that imports an extension), an extension importing another extension, importing an extension from a worker, import map entries that point atextension:,npm:sources, named permission sets as a grant, and exports other than functions.
Extensions don't share objects with the app. Values are copied both ways, so an extension can't reach the app's globals or modules.