Conversation
JavaScript Code
Conversation workflow step that executes provided JavaScript source as part of a sequential workflow. - Deterministic JavaScript runtime (QuickJS in Wasm): - Only deterministic APIs are available. Date, Math.random, eval/Function, Promise/async, RegExp, Proxy, ArrayBuffer/typed arrays, WebAssembly, console, JSON.parse/stringify, and Array.prototype.sort are disabled. - Values passed into and returned from the VM must be DV-compatible (null, boolean, number, string, array, object with string keys). - Gas accounting (when and what is charged): - JavaScript execution is metered by the QuickJS VM. The VM reports wasm fuel used; the processor converts it to host gas with: hostGas = ceil(wasmFuel / 1700) (calibration factor currently 1700 fuel per host gas unit). - Document snapshot reads (via document(<pointer>) inside the code): 8 + depth(pointer) + ceil(snapshotBytes/100) per call, where: - depth("/") = 0, depth("/a/b") = 2 (number of path segments), - snapshotBytes is the canonical JSON size of the retrieved snapshot. - Event emissions (if the returned result contains events: [...]): 20 + ceil(eventBytes/100) per emitted event, where eventBytes is the canonical JSON size of that event. (Delivery/handling of those events may incur additional charges elsewhere, outside this step.) - JavaScript bindings available to the code: - `event`: triggering event rendered via the `'simple'` JSON strategy (plain values/arrays, no metadata). - `eventCanonical`: triggering event rendered via the `'official'` strategy. - `currentContract`: the current handler contract rendered via the `'simple'` JSON strategy. - `currentContractCanonical`: current handler contract rendered via the `'official'` strategy. - `document(pointer?)`: document snapshot (absolute path or scope-relative) rendered with the `'simple'` strategy; defaults to `/` when omitted. - `document.canonical(pointer?)`: snapshot rendered using the `'official'` strategy for canonical metadata. - `steps`: results of previously executed steps. - `canon.unwrap(canonical, deep=true)`: converts canonical JSON back to plain values. - `canon.at(canonical, pointer)`: JSON Pointer navigation helper for canonical JSON objects.
HYsLiqsqk7t98d5fK6YxKEQGeqBaHNVjM4rRNdxK4yUW:Conversation/Sequential Workflow StepDLRQwz7MQeCrzjy9bohPNwtCxKEBbKaMK65KBrwjfG6K:Text