Embedding Final in Go
Final was designed first as a language for AI tools, and second as a general-purpose stack language you can drive from Go. The Introduction and Features survey already mentioned embedding; this section is the host API guide.
You embed Final by creating a Session, then calling Send with a string of Final source. Each Send is one interpret/compile batch: the script runs to completion (or faults), captured stdout comes back as a string, and dictionary state in that Session persists for later Sends.
| Page | Contents |
|---|---|
| 2 Embedding Models | finalgo (simple) vs finalembed (host types); Session / Send / async; LockSession; agent sample app |
| Security Restrictions | Disabled-set capability model for sandboxed AI and other hosts |
Already covered elsewhere
- Interactive use without embedding — The Final TUI
- File / HTTP / threading affordances that SRs can deny — File Streams, Web Dialing, Threading
- How a Session-local dictionary relates to the VM — How Final Works
Which package?
- Prefer
finalgofor agentic and request/response hosts: create a Session,Sendscripts, optionally exposeFinalToolto an LLM. That is the path used by the sample chat app. - Use
finalembedwhen the host must register its own Go types so Final scripts can construct and drive them (widgets, domain objects, generators).
Details and tradeoffs: 2 Embedding Models.