Documentation
¶
Overview ¶
Package model defines FlowBaton's versioned, device-independent flow contract.
Index ¶
- Constants
- Variables
- func NormalizePressKey(authored string) string
- func PressKeyCanonical(authored string) (string, bool)
- type Command
- type CommandForm
- type CommandKeyword
- type Condition
- type Config
- type ContractDescriptor
- type Diagnostic
- type ElementSelector
- type ElementTrait
- type ExecutionPlan
- type FileLink
- type FileLinkKind
- type Flow
- type Platform
- type Position
- type SizeSelector
- type SourceInfo
- type WorkspaceAndroidConfig
- type WorkspaceConfig
- type WorkspaceExecutionOrder
- type WorkspaceIOSConfig
- type WorkspacePlatformConfig
Constants ¶
const ASTVersionV0 = "flowbaton.ast/v0"
ASTVersionV0 identifies the first frozen FlowBaton syntax contract.
Variables ¶
var PressKeyCodes = []string{
"HOME", "LOCK", "ENTER", "BACKSPACE", "BACK", "POWER", "TAB",
"VOLUME_UP", "VOLUME_DOWN",
"REMOTE_DPAD_UP", "REMOTE_DPAD_DOWN", "REMOTE_DPAD_LEFT", "REMOTE_DPAD_RIGHT", "REMOTE_DPAD_CENTER",
"REMOTE_MEDIA_PLAY_PAUSE", "REMOTE_MEDIA_STOP", "REMOTE_MEDIA_NEXT", "REMOTE_MEDIA_PREVIOUS",
"REMOTE_MEDIA_REWIND", "REMOTE_MEDIA_FAST_FORWARD",
"REMOTE_SYSTEM_NAVIGATION_UP", "REMOTE_SYSTEM_NAVIGATION_DOWN",
"REMOTE_BUTTON_A", "REMOTE_BUTTON_B", "REMOTE_MENU",
"TV_INPUT", "TV_INPUT_HDMI_1", "TV_INPUT_HDMI_2", "TV_INPUT_HDMI_3",
}
PressKeyCodes is the supported pressKey set in canonical UPPER_SNAKE form. It includes standard device keys and Android TV remote keys. The parser and compiler normalize authored values through NormalizePressKey before lookup. The order keeps parser diagnostics deterministic.
Functions ¶
func NormalizePressKey ¶
NormalizePressKey folds an authored pressKey value to its canonical form. Key names are case-insensitive, with spaces and underscores interchangeable.
func PressKeyCanonical ¶
PressKeyCanonical returns the canonical KeyCode string for an authored value and whether it is a supported key.
Types ¶
type Command ¶
type Command struct {
Kind CommandKeyword `json:"kind"`
Form CommandForm `json:"form"`
Arguments any `json:"arguments,omitempty"`
Selector *ElementSelector `json:"selector,omitempty"`
Condition *Condition `json:"condition,omitempty"`
Children []Command `json:"children,omitempty"`
Links []FileLink `json:"links,omitempty"`
Label *string `json:"label,omitempty"`
Optional *bool `json:"optional,omitempty"`
Source SourceInfo `json:"-"`
}
Command is the common v0 discriminated command node. Arguments retains the complete normalized YAML value while typed fields expose traversal-critical selector, condition, composite, and file-link data.
func (Command) Equivalent ¶
Equivalent checks semantic command data while ignoring source locations.
type CommandForm ¶
type CommandForm string
CommandForm records whether a command used scalar or object YAML syntax.
const ( CommandFormScalar CommandForm = "scalar" CommandFormObject CommandForm = "object" )
type CommandKeyword ¶
type CommandKeyword string
CommandKeyword is a canonical YAML command discriminator.
const ( CommandLaunchApp CommandKeyword = "launchApp" CommandStopApp CommandKeyword = "stopApp" CommandKillApp CommandKeyword = "killApp" CommandClearState CommandKeyword = "clearState" CommandClearKeychain CommandKeyword = "clearKeychain" CommandSetPermissions CommandKeyword = "setPermissions" CommandTapOn CommandKeyword = "tapOn" CommandDoubleTapOn CommandKeyword = "doubleTapOn" CommandLongPressOn CommandKeyword = "longPressOn" CommandAssertVisible CommandKeyword = "assertVisible" CommandAssertNotVisible CommandKeyword = "assertNotVisible" CommandAssertTrue CommandKeyword = "assertTrue" CommandAssertNoDefectsWithAI CommandKeyword = "assertNoDefectsWithAI" CommandAssertScreenshot CommandKeyword = "assertScreenshot" CommandAssertWithAI CommandKeyword = "assertWithAI" CommandExtractTextWithAI CommandKeyword = "extractTextWithAI" CommandBack CommandKeyword = "back" CommandHideKeyboard CommandKeyword = "hideKeyboard" CommandPasteText CommandKeyword = "pasteText" CommandScroll CommandKeyword = "scroll" CommandScrollUntilVisible CommandKeyword = "scrollUntilVisible" CommandInputText CommandKeyword = "inputText" CommandInputRandomText CommandKeyword = "inputRandomText" CommandInputRandomNumber CommandKeyword = "inputRandomNumber" CommandInputRandomEmail CommandKeyword = "inputRandomEmail" CommandInputRandomPersonName CommandKeyword = "inputRandomPersonName" CommandInputRandomCityName CommandKeyword = "inputRandomCityName" CommandInputRandomCountryName CommandKeyword = "inputRandomCountryName" CommandInputRandomColorName CommandKeyword = "inputRandomColorName" CommandSwipe CommandKeyword = "swipe" CommandOpenLink CommandKeyword = "openLink" CommandOpenBrowser CommandKeyword = "openBrowser" CommandPressKey CommandKeyword = "pressKey" CommandEraseText CommandKeyword = "eraseText" CommandAction CommandKeyword = "action" CommandTakeScreenshot CommandKeyword = "takeScreenshot" CommandExtendedWaitUntil CommandKeyword = "extendedWaitUntil" CommandRunFlow CommandKeyword = "runFlow" CommandSetLocation CommandKeyword = "setLocation" CommandSetOrientation CommandKeyword = "setOrientation" CommandRepeat CommandKeyword = "repeat" CommandRetry CommandKeyword = "retry" CommandCopyTextFrom CommandKeyword = "copyTextFrom" CommandSetClipboard CommandKeyword = "setClipboard" CommandRunScript CommandKeyword = "runScript" CommandEvalScript CommandKeyword = "evalScript" CommandWaitForAnimationToEnd CommandKeyword = "waitForAnimationToEnd" CommandTravel CommandKeyword = "travel" CommandStartRecording CommandKeyword = "startRecording" CommandStopRecording CommandKeyword = "stopRecording" CommandAddMedia CommandKeyword = "addMedia" CommandSetAirplaneMode CommandKeyword = "setAirplaneMode" CommandToggleAirplaneMode CommandKeyword = "toggleAirplaneMode" CommandApplyConfiguration CommandKeyword = "applyConfiguration" CommandDefineVariables CommandKeyword = "defineVariables" )
func CommandKeywords ¶
func CommandKeywords() []CommandKeyword
CommandKeywords returns the canonical 53-keyword catalog in contract order.
type Condition ¶
type Condition struct {
Platform *Platform `json:"platform,omitempty"`
Visible *ElementSelector `json:"visible,omitempty"`
NotVisible *ElementSelector `json:"notVisible,omitempty"`
ScriptCondition *string `json:"true,omitempty"`
Label *string `json:"label,omitempty"`
Optional *bool `json:"optional,omitempty"`
Source SourceInfo `json:"-"`
FieldSources map[string]SourceInfo `json:"-"`
}
Condition is the complete v0 conditional wrapper.
type Config ¶
type Config struct {
Name string `json:"name,omitempty"`
AppID string `json:"appId,omitempty"`
URL string `json:"url,omitempty"`
Tags []string `json:"tags,omitempty"`
Env map[string]string `json:"env,omitempty"`
OnFlowStart []Command `json:"onFlowStart,omitempty"`
OnFlowComplete []Command `json:"onFlowComplete,omitempty"`
Properties map[string]string `json:"properties,omitempty"`
Ext map[string]any `json:"ext,omitempty"`
Source SourceInfo `json:"-"`
FieldSources map[string]SourceInfo `json:"-"`
}
Config is the typed first document of a flow file.
func (Config) EffectiveAppID ¶
EffectiveAppID is what a flow's commands are about.
specs/01-core-engine.md:17 makes `url` the web equivalent of `appId`: "if present becomes effective appId". So this is the one place the rule lives — the session, the evaluation context and the element lookup all read it, because a flow whose target depends on which of them asked is a flow that taps in one app and asserts in another.
type ContractDescriptor ¶
type ContractDescriptor struct {
Version string `json:"version"`
CommandKeywords []CommandKeyword `json:"commandKeywords"`
SelectorFields []string `json:"selectorFields"`
ConditionFields []string `json:"conditionFields"`
}
ContractDescriptor is the serializable v0 AST contract surface.
func ContractV0 ¶
func ContractV0() ContractDescriptor
ContractV0 returns a defensive copy of the frozen v0 AST descriptor.
type Diagnostic ¶
type Diagnostic struct {
Code string `json:"code"`
Message string `json:"message"`
Suggestion string `json:"suggestion,omitempty"`
Source SourceInfo `json:"-"`
}
Diagnostic is a stable, location-aware parser or contract error.
func (Diagnostic) Error ¶
func (d Diagnostic) Error() string
Error renders a deterministic operator-facing diagnostic.
type ElementSelector ¶
type ElementSelector struct {
TextRegex *string `json:"text,omitempty"`
IDRegex *string `json:"id,omitempty"`
Size *SizeSelector `json:"size,omitempty"`
Optional *bool `json:"optional,omitempty"`
RetryTapIfNoChange *bool `json:"retryTapIfNoChange,omitempty"`
WaitUntilVisible *bool `json:"waitUntilVisible,omitempty"`
Point *string `json:"point,omitempty"`
Start *string `json:"start,omitempty"`
End *string `json:"end,omitempty"`
Below *ElementSelector `json:"below,omitempty"`
Above *ElementSelector `json:"above,omitempty"`
LeftOf *ElementSelector `json:"leftOf,omitempty"`
RightOf *ElementSelector `json:"rightOf,omitempty"`
ContainsChild *ElementSelector `json:"containsChild,omitempty"`
ContainsDescendants []ElementSelector `json:"containsDescendants,omitempty"`
ChildOf *ElementSelector `json:"childOf,omitempty"`
Traits []ElementTrait `json:"traits,omitempty"`
Index *string `json:"index,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Selected *bool `json:"selected,omitempty"`
Checked *bool `json:"checked,omitempty"`
Focused *bool `json:"focused,omitempty"`
Repeat *int `json:"repeat,omitempty"`
Delay *int `json:"delay,omitempty"`
WaitToSettleTimeoutMS *int `json:"waitToSettleTimeoutMs,omitempty"`
Label *string `json:"label,omitempty"`
CSS *string `json:"css,omitempty"`
Source SourceInfo `json:"-"`
FieldSources map[string]SourceInfo `json:"-"`
}
ElementSelector is the complete v0 selector surface.
type ElementTrait ¶
type ElementTrait string
ElementTrait is a selector trait token.
const ( ElementTraitText ElementTrait = "TEXT" ElementTraitSquare ElementTrait = "SQUARE" ElementTraitLongText ElementTrait = "LONG_TEXT" )
type ExecutionPlan ¶
type ExecutionPlan struct {
SelectedRoots []string `json:"selectedRoots"`
}
ExecutionPlan is the boundary after workspace discovery, filtering, and ordering. Capability analysis only sees explicitly selected roots.
type FileLink ¶
type FileLink struct {
Kind FileLinkKind `json:"kind"`
Path string `json:"path"`
ResolvedPath string `json:"-"`
Source SourceInfo `json:"-"`
}
FileLink records a link without performing filesystem validation.
type FileLinkKind ¶
type FileLinkKind string
FileLinkKind identifies why a command links a file.
const ( FileLinkFlow FileLinkKind = "flow" FileLinkScript FileLinkKind = "script" FileLinkMedia FileLinkKind = "media" )
type Flow ¶
type Flow struct {
SchemaVersion string `json:"schemaVersion"`
Path string `json:"-"`
Config Config `json:"config"`
Commands []Command `json:"commands"`
Source SourceInfo `json:"-"`
}
Flow is a parsed two-document flow. Commands contains author-written commands; ExecutionCommands adds the synthetic configuration prologue.
func (Flow) ExecutionCommands ¶
ExecutionCommands returns a fresh executable sequence with configuration and environment initialization before author-written commands.
type Position ¶
type Position struct {
Line int `json:"line"`
Column int `json:"column"`
Offset int `json:"offset"`
}
Position is a one-based source position. Offset is a zero-based byte offset.
type SizeSelector ¶
type SizeSelector struct {
Width *int `json:"width,omitempty"`
Height *int `json:"height,omitempty"`
Tolerance *int `json:"tolerance,omitempty"`
}
SizeSelector is the typed selector size constraint.
type SourceInfo ¶
SourceInfo identifies a source span. It is deliberately non-semantic and is excluded from serialized contract snapshots.
type WorkspaceAndroidConfig ¶
type WorkspaceAndroidConfig struct {
DisableAnimations bool `json:"disableAnimations,omitempty"`
}
WorkspaceAndroidConfig holds Android workspace behavior.
type WorkspaceConfig ¶
type WorkspaceConfig struct {
Flows []string `json:"flows"`
IncludeTags []string `json:"includeTags,omitempty"`
ExcludeTags []string `json:"excludeTags,omitempty"`
ExecutionOrder *WorkspaceExecutionOrder `json:"executionOrder,omitempty"`
TargetBranch string `json:"targetBranch,omitempty"`
Notifications map[string]any `json:"notifications,omitempty"`
DisableRetries *bool `json:"disableRetries,omitempty"`
Platform *WorkspacePlatformConfig `json:"platform,omitempty"`
TestOutputDir string `json:"testOutputDir,omitempty"`
Unknown map[string]any `json:"unknown,omitempty"`
Source SourceInfo `json:"-"`
}
WorkspaceConfig models the independently parsed workspace configuration.
type WorkspaceExecutionOrder ¶
type WorkspaceExecutionOrder struct {
ContinueOnFailure bool `json:"continueOnFailure,omitempty"`
FlowsOrder []string `json:"flowsOrder,omitempty"`
}
WorkspaceExecutionOrder is the workspace ordering contract.
type WorkspaceIOSConfig ¶
type WorkspaceIOSConfig struct {
DisableAnimations bool `json:"disableAnimations,omitempty"`
SnapshotKeyHonorModalViews bool `json:"snapshotKeyHonorModalViews,omitempty"`
}
WorkspaceIOSConfig holds iOS workspace behavior.
type WorkspacePlatformConfig ¶
type WorkspacePlatformConfig struct {
Android *WorkspaceAndroidConfig `json:"android,omitempty"`
IOS *WorkspaceIOSConfig `json:"ios,omitempty"`
}
WorkspacePlatformConfig holds platform-specific workspace behavior.