Flow SDK: actions, hosts and what a third party could add
This document describes the extension surface of the Flow module (FlowEngine) as it exists in the code, and the
platform rules that bound it. Language reference: FLOW_LANGUAGE.md.
Model
workflow text ──compile──▶ FlowValidatedProgram ──FlowRunner──▶ FlowActionCall ──▶ FlowHost (the app) ──▶ effect
▲ ▲
FlowActionRegistry (definitions) capability grant, allow-list, confirmation, budgets- A definition (
FlowActionDefinition) is data: a name, typed parameters, a result type, a capability and whether the user must confirm. It contains no code. - The host (
FlowHost) is code compiled into the application. It receives calls that have already passed every check and performs them. - The interpreter connects the two. It never touches tabs, files, the network or an AI provider itself.
Defining an action
let translate = FlowActionDefinition(
name: "translate", // one or two lowercase words
summary: "Translate text.",
parameters: [
FlowParameter("content", label: nil, .value([.text])), // positional
FlowParameter("language", label: "into_language", .option(["french", "english"])),
],
result: .text,
capability: .ai, // required; pick the narrowest that applies
confirmation: .never)
let registry = try FlowActionRegistry.standard.adding([translate])
let compilation = FlowCompiler.compile(source, registry: registry)register rejects definitions that could confuse the parser or weaken the checks:
- the name is one or two words of lowercase letters/underscores, not reserved, not
wait, not already taken, and cannot share its first word with an action of a different word count (extractvsextract article); - at most one positional parameter; labels are single lowercase words, unique, not reserved (
asexcepted); - value types cannot be
unknown,nothingoroption; option lists are non-empty lowercase words; - an action with an
asparameter cannot return a value; - a capability is mandatory (only the engine's own
waithas none).
Capabilities are open strings (FlowCapability(rawValue:)). The built-in ones are navigate, read, interact,
submit-form, ai, write-file, download, write-note, write-bookmark, notify. navigate, download,
submit-form and interact are treated as networked and force allow domains.
The same registry must be used to compile and to run; the validated program carries it.
Implementing the host
public protocol FlowHost: Sendable {
func perform(_ call: FlowActionCall) async throws -> FlowValue
func confirm(_ request: FlowConfirmationRequest) async -> Bool
}FlowActionCall carries runID, stepID, action, arguments (by parameter name), policy (the allow-list),
timeoutSeconds and spaceName.
Host obligations:
- Return a value of the declared result type (anything else fails the step as a contract violation).
- Apply
call.policyto everything the engine cannot see: HTTP redirects, sub-frames it reads, files it fetches. - Honour task cancellation promptly (timeouts and user cancellation are delivered that way).
- Treat a
FlowPagewhose handle it does not know as stale and reopenpage.url. - Treat all text coming from pages as untrusted data, in particular before handing it to an AI provider: page content must never be able to change what a workflow does. The engine guarantees this on its side (page text is only ever a value), the host must guarantee it in its prompts.
- Never run a workflow for a private (ghost) window with a
FlowRunStore.
What the engine guarantees before perform is called: the capability was granted for this run, every URL/page
argument is http(s) and on the allow-list, the step and duration budgets are not exhausted, and — for actions
with confirmation: .always — confirm returned true for this very step.
What a third party could add — and what it cannot
Today, in this codebase: a third party cannot add anything at run time. Registries are built in Swift code that is compiled into the app; there is no file format, no download, no plug-in loader for action definitions, and no UI to install one. The extension point above is for code that ships inside the application binary (ORIX's own modules, or a fork).
Workflows themselves are the user-facing extension mechanism: they can be written, imported (Capsule) and shared as text. A workflow is data interpreted over the fixed action set of the installed app; importing one never adds a capability, an action or code.
iOS and iPadOS
- No downloaded or user-supplied native code is ever executed, and none could be: iOS only runs code signed in the app bundle.
- Flow is a data-only interpreted DSL over a fixed action set. It has no way to define functions, no
eval, no access to JavaScriptCore or to a web view's script engine, no dynamic library loading and no way to change the action registry. What the app can do after installing a workflow is exactly what it could do before. - The relevant rule is App Store Review Guideline 2.5.2 (apps must be self-contained and may not download, install or execute code which introduces or changes features or functionality of the app). The design above is intended to stay inside it: interpreted text that only selects among built-in, reviewed features. This must be re-checked against Apple's current guideline text (and the clause of the Developer Program License Agreement on interpreted code) before any distribution — the guideline wording changes and this document is not a legal review. In particular, adding a way to download action definitions or shared workflows from a server controlled by ORIX would need a fresh reading of 2.5.2.
macOS
- The same rule applies to the Mac App Store.
- A real third-party extension mechanism on the Mac (new actions implemented by someone else) would have to run
the extension as a separate, sandboxed process that the user explicitly authorises — for example an App
Extension / ExtensionKit extension or an XPC service with its own entitlements — talking to the app over a
narrow, typed IPC protocol equivalent to
FlowActionCall→FlowValue, with its declared capabilities shown to the user and enforced by the app, not by the extension. - This is not implemented. There is no extension point, no IPC protocol, no discovery and no settings UI for it. Nothing in the module loads code from outside the application.
Stability
- Language version:
FlowLanguage.currentVersion= 1. A workflow declaring another version is rejected (unsupported-version); nothing is migrated automatically. - Stored run logs:
FlowRunStore.currentSchemaVersion= 1, kept in the settingflow.schema_version; tableflow_runs(created idempotently by the module, not by Persistence's migrations).NavigatorDatabase.lifecycle.deleteEverything()does not know this table: the app must also callFlowRunStore.deleteAll(). - Diagnostic codes are part of the contract (the editor may key behaviour on them); messages and hints are not.
Not verified
- No real
FlowHostexists; everything here is exercised with a scripted host in tests. - No App Review has been attempted. The 2.5.2 reasoning above is the design intent, not a ruling.