@specrun/cli 0.1.0-beta1
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.
- package/LICENSE +21 -0
- package/README.md +191 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1281 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 spichen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# agentflow
|
|
2
|
+
|
|
3
|
+
A lightweight CLI framework for building and executing agentic workflows using the [Oracle Agent Spec](https://docs.oracle.com/en/cloud/paas/digital-assistant/agent-spec/) (v26.1.0).
|
|
4
|
+
|
|
5
|
+
Define multi-step AI workflows as JSON, wire up LLM-powered agents and external tools, and run them from the command line.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Agent Spec compliant** - Implements the Oracle Agent Spec v26.1.0 format for portable workflow definitions
|
|
10
|
+
- **Graph-based execution** - Flows are compiled into directed graphs with control flow and data flow edges
|
|
11
|
+
- **LLM integration** - OpenAI-compatible LLM provider with tool-calling loop support
|
|
12
|
+
- **External tools** - Tools are standalone executables (shell scripts, Python, etc.) that communicate via JSON over stdin/stdout
|
|
13
|
+
- **Branching logic** - Conditional routing with `BranchingNode` for dynamic workflows
|
|
14
|
+
- **Validation** - Spec-level and graph-level validation catches errors before execution
|
|
15
|
+
- **Scaffolding** - `agentflow init` generates a project template to get started quickly
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install
|
|
21
|
+
npm run build
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This produces the `agentflow` CLI at `dist/index.js`.
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
### 1. Scaffold a new project
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
agentflow init my-project
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
This creates:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
my-project/
|
|
38
|
+
flow.json - Agent Spec flow definition
|
|
39
|
+
tools/example_tool.sh - Example tool script
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 2. Run a flow
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
agentflow run my-project/flow.json \
|
|
46
|
+
--tools-dir my-project/tools \
|
|
47
|
+
--input '{"query": "hello"}'
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 3. Validate a flow
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
agentflow validate my-project/flow.json --tools-dir my-project/tools
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## CLI Reference
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
agentflow [options] <command>
|
|
60
|
+
|
|
61
|
+
Options:
|
|
62
|
+
-v, --verbose Enable verbose logging
|
|
63
|
+
|
|
64
|
+
Commands:
|
|
65
|
+
run <flow.json> Run an Agent Spec flow
|
|
66
|
+
--tools-dir <dir> Directory containing tool executables
|
|
67
|
+
--input <json> Input JSON object
|
|
68
|
+
|
|
69
|
+
validate <flow.json> Validate a flow definition
|
|
70
|
+
--tools-dir <dir> Directory containing tool executables
|
|
71
|
+
|
|
72
|
+
init <project-name> Scaffold a new agentflow project
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## How It Works
|
|
76
|
+
|
|
77
|
+
### Flow Definition
|
|
78
|
+
|
|
79
|
+
Flows are JSON files following the Agent Spec format. A flow consists of **nodes** connected by **control flow** (execution order) and **data flow** (data passing) edges.
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"component_type": "Flow",
|
|
84
|
+
"agentspec_version": "26.1.0",
|
|
85
|
+
"name": "my-flow",
|
|
86
|
+
"start_node": {
|
|
87
|
+
"component_type": "StartNode",
|
|
88
|
+
"name": "start",
|
|
89
|
+
"inputs": [{"json_schema": {"title": "query", "type": "string"}}]
|
|
90
|
+
},
|
|
91
|
+
"nodes": [ ... ],
|
|
92
|
+
"control_flow_connections": [
|
|
93
|
+
{"from_node": "start", "to_node": "agent"},
|
|
94
|
+
{"from_node": "agent", "to_node": "end"}
|
|
95
|
+
],
|
|
96
|
+
"data_flow_connections": [
|
|
97
|
+
{"source_node": "start", "source_output": "query", "destination_node": "agent", "destination_input": "query"},
|
|
98
|
+
{"source_node": "agent", "source_output": "result", "destination_node": "end", "destination_input": "result"}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Node Types
|
|
104
|
+
|
|
105
|
+
| Node | Description |
|
|
106
|
+
|------|-------------|
|
|
107
|
+
| `StartNode` | Entry point of the flow. Defines expected inputs. |
|
|
108
|
+
| `EndNode` | Exit point. Supports named branches for multi-branch flows. |
|
|
109
|
+
| `AgentNode` | LLM-powered agent with a system prompt and optional tools. Runs an automatic tool-calling loop (up to 10 rounds). |
|
|
110
|
+
| `LlmNode` | Runs a prompt template through an LLM. Supports `{{variable}}` substitution. |
|
|
111
|
+
| `ToolNode` | Executes an external tool directly within the flow. |
|
|
112
|
+
| `BranchingNode` | Routes execution to different branches based on an input-to-branch mapping. |
|
|
113
|
+
|
|
114
|
+
### Tools
|
|
115
|
+
|
|
116
|
+
Tools are standalone executables placed in a directory. They receive JSON input on stdin and return JSON output on stdout:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
#!/usr/bin/env bash
|
|
120
|
+
# tools/echo_tool.sh
|
|
121
|
+
INPUT=$(cat)
|
|
122
|
+
MESSAGE=$(echo "$INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('message',''))")
|
|
123
|
+
echo "{\"response\": \"Echo: $MESSAGE\"}"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Tools are referenced by name in flow definitions and resolved from the `--tools-dir` at runtime.
|
|
127
|
+
|
|
128
|
+
### Execution Pipeline
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
JSON file → Parse → Validate spec → Compile graph → Validate graph → Run
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
1. **Parse** - Reads the Agent Spec JSON and resolves all node types
|
|
135
|
+
2. **Validate spec** - Checks structural correctness (required fields, valid references)
|
|
136
|
+
3. **Compile** - Builds an executable graph with control and data flow edges
|
|
137
|
+
4. **Validate graph** - Ensures the graph is well-formed (reachable nodes, valid connections)
|
|
138
|
+
5. **Run** - Executes the graph from `StartNode` to `EndNode`, passing state between nodes
|
|
139
|
+
|
|
140
|
+
### Runner Defaults
|
|
141
|
+
|
|
142
|
+
| Setting | Default |
|
|
143
|
+
|---------|---------|
|
|
144
|
+
| Max iterations | 50 |
|
|
145
|
+
| Timeout | 5 minutes |
|
|
146
|
+
| Max tool rounds (per agent) | 10 |
|
|
147
|
+
| Tool execution timeout | 30 seconds |
|
|
148
|
+
|
|
149
|
+
## Project Structure
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
src/
|
|
153
|
+
cli/ Command handlers (run, validate, init)
|
|
154
|
+
spec/ Agent Spec parser and validator
|
|
155
|
+
graph/ Graph compilation and validation
|
|
156
|
+
node/ Node executors (agent, llm, tool, branching)
|
|
157
|
+
runner/ Flow execution engine with event system
|
|
158
|
+
tool/ Tool registry (filesystem) and subprocess executor
|
|
159
|
+
llm/ LLM provider interface and OpenAI implementation
|
|
160
|
+
state/ Immutable state management
|
|
161
|
+
scaffold/ Project template generation
|
|
162
|
+
examples/
|
|
163
|
+
research-assistant/ Example flow with web_search and calculator tools
|
|
164
|
+
testdata/ Test flow definitions and tool scripts
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Environment Variables
|
|
168
|
+
|
|
169
|
+
| Variable | Description |
|
|
170
|
+
|----------|-------------|
|
|
171
|
+
| `OPENAI_API_KEY` | Required. API key for the OpenAI provider. |
|
|
172
|
+
|
|
173
|
+
## Development
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Run in development mode
|
|
177
|
+
npm run dev -- run flow.json
|
|
178
|
+
|
|
179
|
+
# Run tests
|
|
180
|
+
npm test
|
|
181
|
+
|
|
182
|
+
# Type check
|
|
183
|
+
npm run typecheck
|
|
184
|
+
|
|
185
|
+
# Build
|
|
186
|
+
npm run build
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
See [LICENSE](LICENSE) for details.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|