From e6b6e8329baf3dd8ad67eadd67510e2f7324809b Mon Sep 17 00:00:00 2001 From: Nathan Flurry Date: Wed, 2 Sep 2026 03:15:28 -0700 Subject: [PATCH] docs(execution): document inline ESM support --- docs/content/docs/javascript.mdx | 9 +++++++++ examples/js-sdk-overview/src/index.ts | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/content/docs/javascript.mdx b/docs/content/docs/javascript.mdx index 54503db4c4..d10db05419 100644 --- a/docs/content/docs/javascript.mdx +++ b/docs/content/docs/javascript.mdx @@ -31,6 +31,15 @@ Returning `undefined`, a function, a symbol, or a circular value fails with +Inline JavaScript defaults to ES modules, including static and dynamic imports, +`export` declarations, and top-level `await`. Node-compatible +`data:text/javascript` imports work too, including base64 payloads with unique +URL fragments. You do not need to write an `.mjs` file to use these features. + +`execute()` does not return the module namespace. Use `evaluate()` for a +JSON-serializable host result, or assign to `globalThis` when another call in the +same context needs the value. + Executions are ephemeral, so capture stdio only when you want it — `"stderr"` for diagnostics, `"all"` for both streams. `onStdout`/`onStderr` stream live and work independently of capture. diff --git a/examples/js-sdk-overview/src/index.ts b/examples/js-sdk-overview/src/index.ts index 8b17c951f2..c2c1968e84 100644 --- a/examples/js-sdk-overview/src/index.ts +++ b/examples/js-sdk-overview/src/index.ts @@ -4,7 +4,10 @@ const runtime = await AgentOs.create(); try { const result = await runtime.javascript.execute( - `console.log("hello from agentOS")`, + ` + export const message = await Promise.resolve("hello from agentOS"); + console.log(message); + `, { output: { capture: "all" } }, ); console.log(result.outcome === "succeeded" ? result.stdout : result.error); // "hello from agentOS\n"