@falai/agentv4.0.0
DocsExamplesGitHub

Examples

General

  • Quickstarttypescript
  • Fieldstypescript
  • Toolstypescript
  • Instructionstypescript
  • Branchestypescript
  • Triggers And Waitstypescript
  • Streamingtypescript
  • Store And Migrationtypescript
  • Flows From Jsontypescript

Examples

Runnable code that shows the framework in action.

Quickstart

Quickstart: one field, one flow, one turn.

typescript

Fields

Fields: authored once, asked in any order, each with its own wording.

`ask``enum``extract: 'asked'``maxAsks`a step's own `ask`
typescript

Tools

Tools: functions the AI may call while it speaks.

`Tool.handler(argsctx)` → `{ valuedata }``isReadOnly`
typescript

Instructions

Instructions: behavioural rules the AI follows while they apply.

`kind` must/never/should`when` (judged by the AI)`if` (judged
typescript

Branches

Branches: leaving a step early, by the AI or by code.

`branches[]` with `when` (AI) and `if` (code)`then` as a step
typescript

Triggers And Waits

Triggers and waits: flows that start without a message, and steps that

`f.action``f.event``f.condition`; `silence``event` +
typescript

Streaming

Streaming: the reply arrives token by token, the result at the end.

`agent.turnStream``{ delta }` chunksthe `{ doneresult }`
typescript

Store And Migration

Persistence: load, turn, save, and the one-time move of a 3.x session.

`Store``MemoryStore``save(sessionexpectedVersion)`
typescript

Flows From Json

Flows as JSON: store them in a database, let an editor draw them, let a

`FlowSpec``f.fromSpec``toSpec``validateFlow`
typescript