flatagents 2.6.0__tar.gz → 3.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flatagents-2.6.0 → flatagents-3.0.0}/AGENTS.md +16 -1
- {flatagents-2.6.0 → flatagents-3.0.0}/PKG-INFO +4 -4
- {flatagents-2.6.0 → flatagents-3.0.0}/README.md +3 -3
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/__init__.py +1 -1
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/flatagent.d.ts +1 -1
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/flatagent.slim.d.ts +1 -1
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/flatagents-runtime.d.ts +1 -1
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/flatagents-runtime.schema.json +1 -1
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/flatagents-runtime.slim.d.ts +1 -1
- flatagents-3.0.0/flatagents/assets/flatmachine.d.ts +367 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/flatmachine.schema.json +117 -114
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/flatmachine.slim.d.ts +14 -13
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/profiles.d.ts +1 -1
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/profiles.slim.d.ts +1 -1
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/providers/openai_codex_auth.py +4 -4
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/providers/openai_codex_client.py +2 -2
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/providers/openai_codex_login.py +2 -2
- {flatagents-2.6.0 → flatagents-3.0.0}/pyproject.toml +1 -1
- flatagents-2.6.0/MACHINES.md +0 -207
- flatagents-2.6.0/flatagents/assets/flatmachine.d.ts +0 -480
- {flatagents-2.6.0 → flatagents-3.0.0}/.gitignore +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/README.md +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/__init__.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/flatagent.schema.json +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/assets/profiles.schema.json +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/baseagent.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/flatagent.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/monitoring.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/profiles.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/providers/__init__.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/providers/anthropic.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/providers/cerebras.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/providers/github_copilot_auth.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/providers/github_copilot_client.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/providers/github_copilot_login.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/providers/github_copilot_types.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/providers/openai.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/providers/openai_codex_types.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/tool_loop.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/tools.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/utils.py +0 -0
- {flatagents-2.6.0 → flatagents-3.0.0}/flatagents/validation.py +0 -0
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
```yaml
|
|
23
23
|
# profiles.yml — agents reference by name
|
|
24
24
|
spec: flatprofiles
|
|
25
|
-
spec_version: "
|
|
25
|
+
spec_version: "3.0.0"
|
|
26
26
|
data:
|
|
27
27
|
model_profiles:
|
|
28
28
|
fast: { provider: cerebras, name: zai-glm-4.6, temperature: 0.6 }
|
|
@@ -52,6 +52,21 @@ Resolution: default → profile → overrides → override
|
|
|
52
52
|
- Inline flatagent config (`spec: flatagent`)
|
|
53
53
|
- Typed adapter ref: `{ type: "flatagent" | "smolagents" | "pi-agent", ref?: "...", config?: {...} }`
|
|
54
54
|
|
|
55
|
+
## LLM I/O & Formatting (Hard Rules)
|
|
56
|
+
|
|
57
|
+
- Between LLM stages, default to **plain text/Markdown** handoffs.
|
|
58
|
+
- Avoid JSON/Jinja-shaped model-to-model output unless required by strict schema validation or a boundary contract (API/DB/file format).
|
|
59
|
+
- Why: JSON/Jinja handoffs increase parse fragility and token overhead.
|
|
60
|
+
- Keep `input` / `output_to_context` mappings explicit and shallow.
|
|
61
|
+
- Push heavy transforms to boundary actions only (final save/write steps).
|
|
62
|
+
- Preserve full source text across stages (avoid excerpt-only chains unless explicitly requested).
|
|
63
|
+
- Jinja in config (`input`, `output_to_context`, `transitions`, `foreach`, `wait_for`) must be cross-SDK portable:
|
|
64
|
+
- use property access, comparisons, simple conditionals
|
|
65
|
+
- avoid Python-specific features (`.items()`, `|tojson`, `len()`, `isinstance()`, list comprehensions).
|
|
66
|
+
- **Never truncate** LLM inputs/outputs silently.
|
|
67
|
+
- If size is a problem: ask user, enforce prompt limits, reject+retry, or add a repair/compaction stage.
|
|
68
|
+
- Each transform must have a one-line justification; otherwise remove it.
|
|
69
|
+
|
|
55
70
|
## State Fields
|
|
56
71
|
|
|
57
72
|
| Field | Purpose |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flatagents
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: A lightweight framework for building LLM-powered agents.
|
|
5
5
|
Project-URL: Homepage, https://github.com/memgrafter/flatagents
|
|
6
6
|
Project-URL: Repository, https://github.com/memgrafter/flatagents
|
|
@@ -45,7 +45,7 @@ Description-Content-Type: text/markdown
|
|
|
45
45
|
|
|
46
46
|
Define single-call LLM agents in YAML. Use this package when you want **one structured call** per agent, with optional MCP tools and profile-driven model configs. For orchestration, install `flatmachines` separately.
|
|
47
47
|
|
|
48
|
-
**For LLM/machine readers:** see [
|
|
48
|
+
**For LLM/machine readers:** see [AGENTS.md](./AGENTS.md).
|
|
49
49
|
|
|
50
50
|
## Install
|
|
51
51
|
|
|
@@ -137,7 +137,7 @@ model:
|
|
|
137
137
|
name: gpt-5
|
|
138
138
|
backend: codex
|
|
139
139
|
oauth:
|
|
140
|
-
auth_file: ~/.
|
|
140
|
+
auth_file: ~/.agents/flatmachines/auth.json
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
```yaml
|
|
@@ -152,7 +152,7 @@ model:
|
|
|
152
152
|
Login helpers:
|
|
153
153
|
|
|
154
154
|
```bash
|
|
155
|
-
python -m flatagents.providers.openai_codex_login --auth-file ~/.
|
|
155
|
+
python -m flatagents.providers.openai_codex_login --auth-file ~/.agents/flatmachines/auth.json
|
|
156
156
|
python -m flatagents.providers.github_copilot_login --auth-file ~/.agents/flatmachines/auth.json
|
|
157
157
|
```
|
|
158
158
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Define single-call LLM agents in YAML. Use this package when you want **one structured call** per agent, with optional MCP tools and profile-driven model configs. For orchestration, install `flatmachines` separately.
|
|
4
4
|
|
|
5
|
-
**For LLM/machine readers:** see [
|
|
5
|
+
**For LLM/machine readers:** see [AGENTS.md](./AGENTS.md).
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -94,7 +94,7 @@ model:
|
|
|
94
94
|
name: gpt-5
|
|
95
95
|
backend: codex
|
|
96
96
|
oauth:
|
|
97
|
-
auth_file: ~/.
|
|
97
|
+
auth_file: ~/.agents/flatmachines/auth.json
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
```yaml
|
|
@@ -109,7 +109,7 @@ model:
|
|
|
109
109
|
Login helpers:
|
|
110
110
|
|
|
111
111
|
```bash
|
|
112
|
-
python -m flatagents.providers.openai_codex_login --auth-file ~/.
|
|
112
|
+
python -m flatagents.providers.openai_codex_login --auth-file ~/.agents/flatmachines/auth.json
|
|
113
113
|
python -m flatagents.providers.github_copilot_login --auth-file ~/.agents/flatmachines/auth.json
|
|
114
114
|
```
|
|
115
115
|
|
|
@@ -252,7 +252,7 @@ export interface BackendConfig {
|
|
|
252
252
|
dynamodb_table?: string;
|
|
253
253
|
aws_region?: string;
|
|
254
254
|
}
|
|
255
|
-
export const SPEC_VERSION = "
|
|
255
|
+
export const SPEC_VERSION = "3.0.0";
|
|
256
256
|
export interface SDKRuntimeWrapper {
|
|
257
257
|
spec: "flatagents-runtime";
|
|
258
258
|
spec_version: typeof SPEC_VERSION;
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/**
|
|
2
|
+
FlatMachine Configuration Schema
|
|
3
|
+
|
|
4
|
+
A machine defines how agents are connected and executed:
|
|
5
|
+
states, transitions, conditions, and loops.
|
|
6
|
+
|
|
7
|
+
While flatagents defines WHAT each agent is (model + prompts + output schema),
|
|
8
|
+
flatmachines defines HOW agents are connected and executed.
|
|
9
|
+
|
|
10
|
+
STRUCTURE
|
|
11
|
+
spec - Fixed string "flatmachine"
|
|
12
|
+
spec_version - Semver string
|
|
13
|
+
data - The machine configuration
|
|
14
|
+
metadata - Extensibility layer
|
|
15
|
+
|
|
16
|
+
DERIVED SCHEMAS
|
|
17
|
+
This file (/flatmachine.d.ts) is the SOURCE OF TRUTH for all FlatMachine schemas.
|
|
18
|
+
Other schemas (JSON Schema, etc.) are DERIVED from this file using scripts.
|
|
19
|
+
See /scripts/generate-spec-assets.ts
|
|
20
|
+
|
|
21
|
+
DATA FIELDS
|
|
22
|
+
Core
|
|
23
|
+
name - Machine identifier
|
|
24
|
+
expression_engine - "simple" (default) or "cel"
|
|
25
|
+
|
|
26
|
+
Context + references
|
|
27
|
+
context - Initial context values (Jinja2 templates)
|
|
28
|
+
agents - Map of agent name to AgentRef (path, inline config, or typed adapter ref)
|
|
29
|
+
machines - Map of machine name to config file path or inline config
|
|
30
|
+
|
|
31
|
+
Orchestration + runtime config
|
|
32
|
+
states - Map of state name to state definition
|
|
33
|
+
settings - Optional settings
|
|
34
|
+
persistence - Checkpoint backend settings
|
|
35
|
+
lifecycle_hooks - Machine lifecycle hook reference(s) resolved by runtime registry
|
|
36
|
+
|
|
37
|
+
STATE FIELDS
|
|
38
|
+
Lifecycle / control flow
|
|
39
|
+
type - "initial" or "final" (optional)
|
|
40
|
+
on_error - Error handling: "error_state" or {default: "...", ErrorType: "..."}
|
|
41
|
+
timeout - State timeout in seconds (context-dependent)
|
|
42
|
+
transitions - Ordered list of transitions ({ condition?: string, to: string })
|
|
43
|
+
|
|
44
|
+
Data mapping
|
|
45
|
+
input - Input mapping (Jinja2 templates)
|
|
46
|
+
output_to_context - Map output to context (Jinja2 templates)
|
|
47
|
+
output - Final output mapping (typically for final states)
|
|
48
|
+
|
|
49
|
+
Agent execution
|
|
50
|
+
agent - Agent name to execute (from agents map)
|
|
51
|
+
execution - Execution type config: {type: "retry", backoffs: [...], jitter: 0.1}
|
|
52
|
+
sampling - Sampling hint (single|multi)
|
|
53
|
+
tool_loop - Enable/configure model-driven tool loop
|
|
54
|
+
|
|
55
|
+
Machine invocation / parallelism
|
|
56
|
+
machine - Machine name or array for parallel execution (from machines map)
|
|
57
|
+
foreach - Jinja2 expression yielding array for dynamic parallelism
|
|
58
|
+
as - Variable name for foreach item (default: "item")
|
|
59
|
+
key - Optional key expression for foreach result mapping
|
|
60
|
+
mode - Completion semantics: "settled" (default) or "any"
|
|
61
|
+
|
|
62
|
+
State hooks
|
|
63
|
+
action - Hook action to execute
|
|
64
|
+
hooks - State-local hook reference(s) resolved by runtime registry
|
|
65
|
+
|
|
66
|
+
External signal wait
|
|
67
|
+
wait_for - Channel to wait for external signal (Jinja2 template)
|
|
68
|
+
|
|
69
|
+
Fire-and-forget launch
|
|
70
|
+
launch - Machine(s) to start without blocking
|
|
71
|
+
launch_input - Input for launched machines
|
|
72
|
+
|
|
73
|
+
STATE NOTES
|
|
74
|
+
- Only `machine` supports array-based parallel invocation (`machine: [a, b, c]`), not `agent`.
|
|
75
|
+
- State hooks are local to the state where they are declared.
|
|
76
|
+
- `wait_for` checkpoints the machine and exits; it resumes when a matching signal arrives.
|
|
77
|
+
- `launch` is fire-and-forget, while `machine` performs launch + blocking read.
|
|
78
|
+
- For fault-tolerant parallelism, run work as machines (checkpoint/retry/error handling),
|
|
79
|
+
not raw agent calls.
|
|
80
|
+
|
|
81
|
+
RUNTIME MODEL
|
|
82
|
+
All machine invocations are launches. Communication via result backend.
|
|
83
|
+
machine: child → launch + blocking read
|
|
84
|
+
machine: [a,b,c] → launch all + wait for all
|
|
85
|
+
launch: child → launch only, no read
|
|
86
|
+
|
|
87
|
+
URI scheme flatagents://{execution_id}/[checkpoint|result]
|
|
88
|
+
Parent generates child's execution_id, passes it to child. Child writes
|
|
89
|
+
result to its URI. Parent reads from known URI. No direct messaging.
|
|
90
|
+
|
|
91
|
+
Local SDKs may optimize blocking reads as function returns (in-memory backend).
|
|
92
|
+
This decouples output from read, enabling both local and distributed execution.
|
|
93
|
+
|
|
94
|
+
Launch intents are checkpointed before execution (outbox pattern).
|
|
95
|
+
On resume, SDK checks if launched machine exists before re-launching.
|
|
96
|
+
|
|
97
|
+
EXPRESSION SYNTAX (Simple Mode)
|
|
98
|
+
Comparisons: ==, !=, <, <=, >, >=
|
|
99
|
+
Boolean: and, or, not
|
|
100
|
+
Field access: context.field, input.field, output.field
|
|
101
|
+
Literals: "string", 42, true, false, null
|
|
102
|
+
Example: "context.score >= 8 and context.round < 4"
|
|
103
|
+
|
|
104
|
+
EXPRESSION SYNTAX (CEL Mode)
|
|
105
|
+
All simple syntax, plus:
|
|
106
|
+
List macros: context.items.all(i, i > 0)
|
|
107
|
+
String methods: context.name.startsWith("test")
|
|
108
|
+
Timestamps: context.created > now - duration("24h")
|
|
109
|
+
|
|
110
|
+
EXAMPLES
|
|
111
|
+
See `sdk/examples/` and `AGENTS.md` for full workflow examples
|
|
112
|
+
|
|
113
|
+
PERSISTENCE
|
|
114
|
+
MachineSnapshot - Wire format for checkpoints (execution_id, state, context, step)
|
|
115
|
+
PersistenceConfig - Backend config: {enabled: true, backend: "local"|"memory"|"sqlite"}
|
|
116
|
+
checkpoint_on - Events to checkpoint: ["machine_start", "execute", "machine_end"]
|
|
117
|
+
|
|
118
|
+
MACHINE LAUNCHING
|
|
119
|
+
States can launch peer machines via `machine:` field
|
|
120
|
+
MachineReference - {path: "./peer.yml"} or {inline: {...}}
|
|
121
|
+
|
|
122
|
+
URI SCHEME
|
|
123
|
+
Format: flatagents://{execution_id}[/{path}]
|
|
124
|
+
|
|
125
|
+
Paths
|
|
126
|
+
/checkpoint - Machine state for resume
|
|
127
|
+
/result - Final output after completion
|
|
128
|
+
|
|
129
|
+
Examples
|
|
130
|
+
flatagents://550e8400-e29b-41d4-a716-446655440000/checkpoint
|
|
131
|
+
flatagents://550e8400-e29b-41d4-a716-446655440000/result
|
|
132
|
+
|
|
133
|
+
Each machine execution has a unique_id. Parent generates child's ID
|
|
134
|
+
before launching, enabling parent to know where to read results without
|
|
135
|
+
any child-to-parent messaging.
|
|
136
|
+
|
|
137
|
+
EXECUTION CONFIG
|
|
138
|
+
type - "default" | "retry" | "parallel" | "mdap_voting"
|
|
139
|
+
backoffs - Retry: seconds between retries
|
|
140
|
+
jitter - Retry: random factor (0-1)
|
|
141
|
+
n_samples - Parallel: number of samples
|
|
142
|
+
k_margin - MDAP voting: consensus threshold
|
|
143
|
+
max_candidates - MDAP voting: max candidates
|
|
144
|
+
|
|
145
|
+
MACHINE INPUT
|
|
146
|
+
Per-machine input configuration for parallel execution.
|
|
147
|
+
Use when different machines need different inputs.
|
|
148
|
+
|
|
149
|
+
LAUNCH INTENT
|
|
150
|
+
Launch intent for outbox pattern.
|
|
151
|
+
Recorded in checkpoint before launching to ensure exactly-once semantics.
|
|
152
|
+
|
|
153
|
+
HOOK REFERENCES
|
|
154
|
+
Hooks are referenced by name and resolved via a runtime HooksRegistry.
|
|
155
|
+
This keeps machine configs language-agnostic — the same YAML works with
|
|
156
|
+
Python, JavaScript, Rust, or any other SDK.
|
|
157
|
+
|
|
158
|
+
Lifecycle hooks apply to machine-level lifecycle events only:
|
|
159
|
+
lifecycle_hooks: "logging"
|
|
160
|
+
|
|
161
|
+
State hooks apply only to the declaring state:
|
|
162
|
+
states:
|
|
163
|
+
review:
|
|
164
|
+
hooks: "review-hooks"
|
|
165
|
+
|
|
166
|
+
With constructor args
|
|
167
|
+
hooks:
|
|
168
|
+
name: "my-hooks"
|
|
169
|
+
args:
|
|
170
|
+
working_dir: "."
|
|
171
|
+
|
|
172
|
+
Composite (multiple hooks)
|
|
173
|
+
hooks:
|
|
174
|
+
- "logging"
|
|
175
|
+
- name: "my-hooks"
|
|
176
|
+
args: { working_dir: "." }
|
|
177
|
+
|
|
178
|
+
The same HooksRef shape is used by `lifecycle_hooks` and state `hooks`.
|
|
179
|
+
The SDK's HooksRegistry maps names to implementations.
|
|
180
|
+
Built-in hooks (e.g., "logging", "webhook") are pre-registered.
|
|
181
|
+
Custom hooks are registered by the runner before machine execution.
|
|
182
|
+
|
|
183
|
+
MACHINE SNAPSHOT
|
|
184
|
+
Wire format for checkpoints.
|
|
185
|
+
context.machine - Runtime-owned metadata (execution_id, step, state, cost/calls)
|
|
186
|
+
Rebuilt from live machine state on each step/resume.
|
|
187
|
+
parent_execution_id - Lineage tracking
|
|
188
|
+
pending_launches - Outbox pattern
|
|
189
|
+
waiting_channel - Signal channel this machine is blocked on (v1.2.0)
|
|
190
|
+
config_hash - Content-addressed machine config key for cross-SDK resume (v2.1.0)
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
export const SPEC_VERSION = "3.0.0";
|
|
194
|
+
|
|
195
|
+
export interface MachineWrapper {
|
|
196
|
+
spec: "flatmachine";
|
|
197
|
+
spec_version: string;
|
|
198
|
+
data: MachineData;
|
|
199
|
+
metadata?: Record<string, any>;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Runtime-owned metadata injected at context.machine */
|
|
203
|
+
export interface MachineRuntimeMetadata {
|
|
204
|
+
execution_id: string;
|
|
205
|
+
machine_name: string;
|
|
206
|
+
parent_execution_id?: string;
|
|
207
|
+
spec_version: string;
|
|
208
|
+
step: number;
|
|
209
|
+
current_state: string;
|
|
210
|
+
total_api_calls: number;
|
|
211
|
+
total_cost: number;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface MachineData {
|
|
215
|
+
name?: string;
|
|
216
|
+
expression_engine?: "simple" | "cel";
|
|
217
|
+
/**
|
|
218
|
+
* Initial user context. Runtime reserves `context.machine` and overwrites
|
|
219
|
+
* it each step/resume with MachineRuntimeMetadata.
|
|
220
|
+
*/
|
|
221
|
+
context?: Record<string, any> & { machine?: MachineRuntimeMetadata };
|
|
222
|
+
agents?: Record<string, AgentRef>;
|
|
223
|
+
machines?: Record<string, string | MachineWrapper>;
|
|
224
|
+
states: Record<string, StateDefinition>;
|
|
225
|
+
settings?: MachineSettings;
|
|
226
|
+
persistence?: PersistenceConfig;
|
|
227
|
+
lifecycle_hooks?: HooksRef;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface AgentRefConfig {
|
|
231
|
+
type: string;
|
|
232
|
+
ref?: string;
|
|
233
|
+
config?: Record<string, any>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export type AgentRef = string | AgentWrapper | AgentRefConfig;
|
|
237
|
+
|
|
238
|
+
export type HooksRef = string | HooksRefConfig | Array<string | HooksRefConfig>;
|
|
239
|
+
|
|
240
|
+
export interface HooksRefConfig {
|
|
241
|
+
name: string;
|
|
242
|
+
args?: Record<string, any>;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface MachineSettings {
|
|
246
|
+
max_steps?: number;
|
|
247
|
+
parallel_fallback?: "sequential" | "error";
|
|
248
|
+
[key: string]: any;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface StateDefinition {
|
|
252
|
+
// Lifecycle / control flow
|
|
253
|
+
on_error?: string | Record<string, string>;
|
|
254
|
+
timeout?: number;
|
|
255
|
+
transitions?: Transition[];
|
|
256
|
+
type?: "initial" | "final";
|
|
257
|
+
|
|
258
|
+
// Data mapping
|
|
259
|
+
input?: Record<string, any>;
|
|
260
|
+
output?: Record<string, any>;
|
|
261
|
+
output_to_context?: Record<string, any>;
|
|
262
|
+
|
|
263
|
+
// Agent execution
|
|
264
|
+
agent?: string;
|
|
265
|
+
execution?: ExecutionConfig;
|
|
266
|
+
sampling?: "single" | "multi";
|
|
267
|
+
tool_loop?: boolean | ToolLoopStateConfig;
|
|
268
|
+
|
|
269
|
+
// Machine invocation / parallelism
|
|
270
|
+
as?: string;
|
|
271
|
+
foreach?: string;
|
|
272
|
+
key?: string;
|
|
273
|
+
machine?: string | string[] | MachineInput[];
|
|
274
|
+
mode?: "settled" | "any";
|
|
275
|
+
|
|
276
|
+
// State action
|
|
277
|
+
action?: string;
|
|
278
|
+
|
|
279
|
+
// State hooks
|
|
280
|
+
hooks?: HooksRef;
|
|
281
|
+
|
|
282
|
+
// External signal wait
|
|
283
|
+
wait_for?: string;
|
|
284
|
+
|
|
285
|
+
// Fire-and-forget launch
|
|
286
|
+
launch?: string | string[];
|
|
287
|
+
launch_input?: Record<string, any>;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export interface ToolLoopStateConfig {
|
|
291
|
+
max_tool_calls?: number; // default: 50
|
|
292
|
+
max_turns?: number; // default: 20
|
|
293
|
+
allowed_tools?: string[]; // allowlist
|
|
294
|
+
denied_tools?: string[]; // denylist (wins)
|
|
295
|
+
tool_timeout?: number; // seconds, default: 30
|
|
296
|
+
total_timeout?: number; // seconds, default: 600
|
|
297
|
+
max_cost?: number; // dollars
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface MachineInput {
|
|
301
|
+
name: string;
|
|
302
|
+
input?: Record<string, any>;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export interface ExecutionConfig {
|
|
306
|
+
type: "default" | "retry" | "parallel" | "mdap_voting";
|
|
307
|
+
backoffs?: number[];
|
|
308
|
+
jitter?: number;
|
|
309
|
+
n_samples?: number;
|
|
310
|
+
k_margin?: number;
|
|
311
|
+
max_candidates?: number;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export interface Transition {
|
|
315
|
+
condition?: string;
|
|
316
|
+
to: string;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
import { AgentWrapper, OutputSchema, ModelConfig } from "./flatagent";
|
|
320
|
+
export { AgentWrapper, OutputSchema };
|
|
321
|
+
|
|
322
|
+
export type FlatmachineConfig = MachineWrapper;
|
|
323
|
+
|
|
324
|
+
export interface LaunchIntent {
|
|
325
|
+
execution_id: string;
|
|
326
|
+
machine: string;
|
|
327
|
+
input: Record<string, any>;
|
|
328
|
+
launched: boolean;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export interface MachineSnapshot {
|
|
332
|
+
execution_id: string;
|
|
333
|
+
machine_name: string;
|
|
334
|
+
spec_version: string;
|
|
335
|
+
current_state: string;
|
|
336
|
+
context: Record<string, any> & { machine?: MachineRuntimeMetadata };
|
|
337
|
+
step: number;
|
|
338
|
+
created_at: string;
|
|
339
|
+
event?: string;
|
|
340
|
+
output?: Record<string, any>;
|
|
341
|
+
total_api_calls?: number;
|
|
342
|
+
total_cost?: number;
|
|
343
|
+
parent_execution_id?: string;
|
|
344
|
+
pending_launches?: LaunchIntent[];
|
|
345
|
+
waiting_channel?: string;
|
|
346
|
+
tool_loop_state?: {
|
|
347
|
+
chain: Array<Record<string, any>>;
|
|
348
|
+
turns: number;
|
|
349
|
+
tool_calls_count: number;
|
|
350
|
+
loop_cost: number;
|
|
351
|
+
};
|
|
352
|
+
config_hash?: string;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export interface PersistenceConfig {
|
|
356
|
+
enabled: boolean;
|
|
357
|
+
backend: "local" | "sqlite" | "memory";
|
|
358
|
+
/** Database file path for sqlite backend. Defaults to "flatmachines.sqlite". */
|
|
359
|
+
db_path?: string;
|
|
360
|
+
checkpoint_on?: string[];
|
|
361
|
+
[key: string]: any;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export interface MachineReference {
|
|
365
|
+
path?: string;
|
|
366
|
+
inline?: MachineWrapper;
|
|
367
|
+
}
|