Documentation
¶
Overview ¶
Package cloudflare is the Cloudflare entry of codemode: the remote end of a remote sandbox as a Durable Object, and the inline sandbox with the QuickJS module the host bundled.
Ports packages/codemode/src/cloudflare.ts. Pi's entry imports `cloudflare:workers`, which exists only inside a Worker; here the Go API is the same behavior for a Go host (QuickJS on wazero), and the Worker itself is the TinyGo build of package codemode (cmd/codemodewasm) served by durable/core/host/cf/src/codemode/sandbox-object.ts, whose limits are the ones of SandboxDurableObject.
Index ¶
Constants ¶
const DefaultRemoteMemoryLimitBytes uint32 = 32 * 1024 * 1024
DefaultRemoteMemoryLimitBytes is the default VM memory limit of SandboxDurableObject. Isolates have 128 MB in total.
Ports packages/codemode/src/cloudflare.ts (DEFAULT_REMOTE_MEMORY_LIMIT_BYTES).
Variables ¶
This section is empty.
Functions ¶
func CreateInlineSandbox ¶
func CreateInlineSandbox(options codemode.InlineSandboxOptions) (*codemode.InlineSandbox, error)
CreateInlineSandbox is InlineSandbox with this entry's QuickJS module: the scripts run on the caller's goroutine, which a script that computes blocks until it awaits a tool or uses up its interrupt budget.
Ports packages/codemode/src/cloudflare.ts (createInlineCodemodeSandbox). options.Wasm is ignored: the module is QuickJSWasm.
func QuickJSWasm ¶
func QuickJSWasm() []byte
QuickJSWasm is the QuickJS module of this entry: the one the package embeds, which Wrangler's CompiledWasm rule supplies to a Worker. The caller must not modify it.
Ports packages/codemode/src/cloudflare.ts (cloudflareQuickJSWasm).
Types ¶
type SandboxDurableObject ¶
type SandboxDurableObject struct {
// MaxInterruptBudget is the interrupt polls per execution. Zero means codemode.DefaultInterruptBudget.
MaxInterruptBudget int
// MaxMemoryLimitBytes is the VM memory per execution. Zero means DefaultRemoteMemoryLimitBytes.
MaxMemoryLimitBytes uint32
}
SandboxDurableObject is the remote end of a remote sandbox: Execute runs a script's VM and calls back into the client for every tool call. The object keeps no state between executions. Limits apply to every request, whatever the client asks for: a request may ask for less, never more.
Ports packages/codemode/src/cloudflare.ts (CodemodeSandboxDurableObject).
func NewSandboxDurableObject ¶
func NewSandboxDurableObject() *SandboxDurableObject
NewSandboxDurableObject returns an object with the default limits.
func (*SandboxDurableObject) Execute ¶
func (o *SandboxDurableObject) Execute(ctx context.Context, request codemode.RemoteRequest, exchange codemode.RemoteExchange) error
Execute is called by a remote sandbox's client. It returns when the script has settled or was stopped, and never fails: what goes wrong is reported to the client through exchange.
Ports packages/codemode/src/cloudflare.ts (CodemodeSandboxDurableObject.execute).
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
codemodewasm
command
Command codemodewasm is the codemode module of the Cloudflare Worker host: package codemode built with TinyGo as a WASI reactor (see durable/core/host/cf/tools/build-codemode-wasm.sh).
|
Command codemodewasm is the codemode module of the Cloudflare Worker host: package codemode built with TinyGo as a WASI reactor (see durable/core/host/cf/tools/build-codemode-wasm.sh). |