Host bridge
Sandboxed widgets sometimes need read-only access to host data — inventory levels, feature flags, or other app APIs. The host bridge exposes allowlisted functions without putting them on the AST.
Provide allowlisted bridge modules
Register bridge modules from your Vue app. Keys use the host-bridge: prefix:
import { provideArrowHostBridge } from 'comark-arrow/vue'
provideArrowHostBridge({
'host-bridge:erp': {
getStockLevel: (sku) => inventory.read(String(sku)),
},
})
Never put bridge functions on the AST or in markdown. Supply them only from the host application at render time.
Import inside the sandbox
Sandboxed source imports bridge modules like any other module:
import { getStockLevel } from 'host-bridge:erp'
export default html`
<p>Stock: ${() => getStockLevel('SKU-001')}</p>
`
Prefer read-only bridge names
Treat bridge functions as a narrow, reviewed API surface:
- Prefer read-only names (
getStockLevel,listOrders). - Mutating functions are an explicit host opt-in — route writes through a confirmation step in the host app.
- Review bridge exposure the same way you review any server-side endpoint called from user content.
Streaming
Keep incomplete ```arrow fences non-executable while Comark streams. Pending sandboxes show a placeholder and never boot QuickJS on partial source.
Security
Agent-authored ArrowJS source runs in QuickJS/WASM only. Review widgets like generated numbers; pin @arrow-js/sandbox and allowlist ArrowSandbox in security().