periplon 0.2.0

Rust SDK for building multi-agent AI workflows and automation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# Periplon

A powerful DSL and Rust SDK for building multi-agent AI workflows and automation.

[![Crates.io](https://img.shields.io/crates/v/periplon.svg)](https://crates.io/crates/periplon)
[![Documentation](https://docs.rs/periplon/badge.svg)](https://docs.rs/periplon)
[![License: MIT OR Apache-2.0](https://img.shields.io/badge/License-MIT%20OR%20Apache--2.0-blue.svg)](LICENSE)

## Table of Contents

- [Overview]#overview
- [Features]#features
- [Installation]#installation
- [Quick Start - DSL]#quick-start---dsl
- [Tools]#tools
  - [Executor CLI]#executor-cli
  - [TUI (Terminal Interface)]#tui-terminal-interface
- [SDK Usage]#sdk-usage
- [Documentation]#documentation
- [Examples]#examples
- [Contributing]#contributing
- [License]#license

## Overview

Periplon provides a comprehensive DSL (Domain-Specific Language) for orchestrating multi-agent AI workflows with zero configuration. Define complex automation tasks in YAML, and let Periplon handle the execution, state management, and agent coordination.

**Key Capabilities:**
- 📝 **Powerful DSL** - YAML-based workflow definition language
- 🔄 **Multi-Agent Workflows** - Orchestrate complex AI agent interactions
- 🚀 **Zero Configuration** - Start instantly with embedded web UI and API server
- 🤖 **Natural Language Generation** - Create workflows from plain English
- 💾 **State Management** - Checkpoint and resume execution
- 🔌 **Extensible** - Plugin architecture with ports and adapters
- 🦀 **Type-Safe Rust SDK** - Strong typing with compile-time guarantees for advanced use cases

## Features

### DSL System

The Periplon DSL is the primary interface for building workflows:

- **Multi-Agent Workflows**: Define and orchestrate multiple specialized AI agents
- **Natural Language Generation**: Create workflows from plain English descriptions
- **State Management**: Automatic checkpoint and resume execution
- **Dependency Resolution**: DAG-based task execution with automatic ordering
- **Variable System**: Scoped variables with `${variable}` interpolation
- **Loop Support**: ForEach, While, RepeatUntil, Repeat patterns for iterative tasks
- **Validation**: Comprehensive workflow validation before execution
- **Tool Filtering**: Control which tools each agent can access
- **Permission Modes**: Fine-grained control over agent capabilities
- **Lifecycle Hooks**: on_start, on_complete, on_error event handlers
- **HTTP Collections**: Fetch data from REST APIs with authentication

### Rust SDK

For advanced programmatic usage:

- **Hexagonal Architecture**: Clean separation with ports and adapters pattern
- **Type Safety**: Strong Rust types with compile-time guarantees
- **Async I/O**: Non-blocking async/await using tokio
- **Stream-Based**: Efficient streaming without buffering
- **Error Handling**: Rich error types with context
- **Testability**: Mock adapters for isolated testing

## Installation

### For DSL Users

Build the executor CLI and TUI:

```bash
# Build the executor CLI with full features
cargo build --release --features full

# Build the TUI
cargo build --release --bin periplon-tui --features tui
```

Binaries will be available at:
- `./target/release/periplon-executor`
- `./target/release/periplon-tui`

### For SDK Users

Add to your `Cargo.toml`:

```toml
[dependencies]
periplon = "0.1.0"
tokio = { version = "1", features = ["full"] }
futures = "0.3"
```

For detailed installation instructions, see [Installation Guide](./docs/guides/installation.md).

## Quick Start - DSL

### Creating Your First Workflow

Create a simple workflow file `hello-world.yaml`:

```yaml
name: "Hello World Workflow"
version: "1.0.0"
description: "A simple workflow demonstrating multi-agent coordination"

agents:
  greeter:
    description: "Generate friendly greetings"
    model: "claude-sonnet-4-5"
    permissions:
      mode: "default"

  writer:
    description: "Save greetings to a file"
    model: "claude-sonnet-4-5"
    tools: [Write]
    permissions:
      mode: "acceptEdits"

tasks:
  generate_greeting:
    description: "Generate a friendly greeting message"
    agent: "greeter"

  save_greeting:
    description: "Save the greeting to greeting.txt"
    agent: "writer"
    depends_on: [generate_greeting]
```

### Running the Workflow

```bash
# Validate the workflow
./target/release/periplon-executor validate hello-world.yaml

# Run the workflow
./target/release/periplon-executor run hello-world.yaml
```

### Generate Workflow from Natural Language

```bash
# Generate a workflow from description
./target/release/periplon-executor generate \
  "Create a workflow that analyzes a codebase, finds todos, and generates a report" \
  -o analyze-todos.yaml

# Run the generated workflow
./target/release/periplon-executor run analyze-todos.yaml
```

### Advanced Example: Variable Interpolation

```yaml
name: "Project Analysis"
version: "1.0.0"

inputs:
  project_name:
    type: string
    required: true
    default: "MyProject"

  output_dir:
    type: string
    required: true
    default: "./reports"

agents:
  analyzer:
    description: "Analyze code for ${workflow.project_name}"
    model: "claude-sonnet-4-5"
    tools: [Read, Grep, Glob]
    inputs:
      target_dir:
        type: string
        required: true

tasks:
  scan_codebase:
    description: "Scan ${workflow.project_name} codebase for issues"
    agent: "analyzer"
    inputs:
      target_dir: "./src"
    outputs:
      report:
        source:
          type: file
          path: "${workflow.output_dir}/analysis.json"
```

See the [DSL Overview](./docs/guides/dsl-overview.md) for comprehensive documentation.

## Tools

### Executor CLI

A complete workflow orchestration platform with zero configuration:

- **🚀 Zero-Config Server**: Start instantly with no database required
- **🎨 Embedded Web UI**: Full Next.js interface built into the binary
- **⚡ Production Ready**: API server and web interface in one executable
- **🔧 Developer Friendly**: Hot reload, validation, natural language generation

```bash
# Build the CLI
cargo build --release --features full

# Start server with embedded web UI
./target/release/periplon-executor server --port 8080 --workers

# Access web UI at http://localhost:8080
```

**Documentation:** [CLI Usage](./docs/guides/CLI_USAGE.md) | [Embedded Web UI](./docs/features/EMBEDDED_WEB_UI.md)

### TUI (Terminal Interface)

Interactive terminal interface for workflow management:

- **📁 Workflow Browser**: Browse and manage workflow files
- **✏️ Smart Editor**: YAML editor with syntax highlighting
- **🤖 AI Generation**: Create workflows from natural language
- **📊 Execution Monitor**: Real-time progress tracking
- **💾 State Management**: Save and resume executions
- **⌨️ Keyboard-Driven**: Full keyboard navigation

```bash
# Build the TUI
cargo build --release --bin periplon-tui --features tui

# Launch TUI
./target/release/periplon-tui

# Launch with custom workflow directory
./target/release/periplon-tui --workflow-dir ./my-workflows
```

**Documentation:**
- [User Guide]./docs/tui/user-guide.md
- [Keyboard Shortcuts]./docs/tui/shortcuts.md
- [Architecture]./docs/tui/architecture.md
- [Troubleshooting]./docs/tui/troubleshooting.md

## SDK Usage

For advanced programmatic control, use the Rust SDK directly:

### Simple Query

```rust
use periplon_sdk::{query, Message, ContentBlock};
use futures::StreamExt;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut stream = query("What is 2 + 2?", None).await?;

    while let Some(msg) = stream.next().await {
        match msg {
            Message::Assistant(assistant_msg) => {
                for block in assistant_msg.message.content {
                    if let ContentBlock::Text { text } = block {
                        println!("Assistant: {}", text);
                    }
                }
            }
            _ => {}
        }
    }
    Ok(())
}
```

### Interactive Client

```rust
use periplon_sdk::{PeriplonSDKClient, AgentOptions};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let options = AgentOptions {
        allowed_tools: vec!["Read".to_string(), "Write".to_string()],
        permission_mode: Some("acceptEdits".to_string()),
        ..Default::default()
    };

    let mut client = PeriplonSDKClient::new(options);
    client.connect(None).await?;

    client.query("List files in current directory").await?;
    // Process response...

    client.disconnect().await?;
    Ok(())
}
```

See the [Quick Start Guide](./docs/guides/quick-start.md) for more SDK examples.

## Documentation

### DSL System
- [DSL Overview]./docs/guides/dsl-overview.md - Introduction to the DSL
- [Loop Patterns Guide]./docs/features/loop-patterns.md - Comprehensive loop reference
- [Loop Cookbook]./docs/features/loop-cookbook.md - 25 production-ready patterns
- [Loop Tutorial]./docs/features/loop-tutorial.md - Step-by-step guide
- [DSL Implementation]./docs/api/DSL_IMPLEMENTATION.md - Technical details
- [Natural Language Generation]./docs/api/DSL_NL_GENERATION.md - NL workflow generation
- [HTTP Collections]./docs/features/HTTP_COLLECTION_SUMMARY.md - HTTP/HTTPS integration
- [Security Audit]./docs/api/SECURITY_AUDIT.md - Safety analysis

### Getting Started
- [Installation Guide]./docs/guides/installation.md - Setup and requirements
- [Quick Start Guide]./docs/guides/quick-start.md - Get up and running
- [Configuration Guide]./docs/guides/configuration.md - Agent options and settings

### SDK Reference
- [Rust API Documentation]https://docs.rs/periplon
- [Architecture Guide]./docs/guides/architecture.md - Hexagonal architecture overview
- [Message Types]./docs/api/message-types.md - Message type reference
- [Error Handling]./docs/guides/error-handling.md - Error types and patterns
- [Testing Guide]./docs/guides/testing.md - Comprehensive testing (166+ tests)

### Example Workflows
- [Example Workflows]./examples/dsl_workflows/

## Examples

### DSL Workflow Examples

Run the included DSL examples:

```bash
# DSL executor example
cargo run --example dsl_executor_example
```

**Loop Pattern Examples:**
- [ForEach Demo]./examples/sdk/foreach_demo.rs - Process collections
- [While Demo]./examples/sdk/while_demo.rs - Polling pattern
- [Polling Demo]./examples/sdk/polling_demo.rs - API polling
- [Parallel Demo]./examples/sdk/parallel_foreach_demo.rs - Concurrent execution
- [HTTP Collection Demo]./examples/sdk/http_collection_demo.rs - Fetch from APIs
- [Checkpoint Demo]./examples/sdk/checkpoint_resume_demo.rs - Resume capability

### SDK Examples

Run the included SDK examples:

```bash
# Simple query
cargo run --example simple_query

# Interactive client
cargo run --example interactive_client
```

See [examples/](./examples/) for all examples.

## Requirements

- **Minimum CLI version**: 2.0.0
- **Rust**: 1.70 or later
- **Tokio runtime**: Required for async operations

## Testing

The SDK includes comprehensive test coverage with 166+ integration tests:

```bash
# Run all tests with server features
cargo test --lib --tests --features server

# Run specific test suite
cargo test --test execution_api_tests --features server

# Run tests with output
cargo test --features server -- --nocapture
```

**Test Suites:**
- Authentication & Authorization (26 tests)
- Queue Backend Operations (22 tests)
- Storage Backend Operations (21 tests)
- Schedule Management API (22 tests)
- Execution Management API (22 tests)
- WebSocket Streaming (21 tests)
- Workflow API Integration (32 tests)

See [Testing Guide](./docs/guides/testing.md) for comprehensive documentation and examples.

## Contributing

Contributions are welcome! Please ensure:

1. All tests pass: `cargo test --lib --tests --features server`
2. Code is formatted: `cargo fmt`
3. No clippy warnings: `cargo clippy`
4. Documentation is updated

See [CLAUDE.md](./CLAUDE.md) for development guidelines.

## License

MIT OR Apache-2.0

## Resources

- [Project Documentation]./docs/
- [API Reference]https://docs.rs/periplon
- [Examples]./examples/
- [Change Log]./CHANGELOG.md

---

**Built with ❤️ in Rust**