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
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
name: CI

on:
  push:
    branches: [ main, develop ]
  pull_request:
    branches: [ main, develop ]

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  # Web UI build (must run first as other jobs depend on it)
  build-web:
    name: Build Web UI
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
          cache-dependency-path: web/package-lock.json

      - name: Install dependencies
        run: |
          cd web
          npm ci

      - name: Type check
        run: |
          cd web
          npm run type-check

      - name: Lint
        run: |
          cd web
          npm run lint

      - name: Build static export
        run: |
          cd web
          npm run build

      - name: Upload web build artifact
        uses: actions/upload-artifact@v4
        with:
          name: web-ui-build
          path: web/out/
          if-no-files-found: error

  # Code quality checks
  check:
    name: Check
    runs-on: ubuntu-latest
    needs: [build-web]
    steps:
      - uses: actions/checkout@v4

      - name: Free disk space
        run: |
          sudo rm -rf /usr/share/dotnet
          sudo rm -rf /usr/local/lib/android
          sudo rm -rf /opt/ghc
          sudo rm -rf /opt/hostedtoolcache/CodeQL
          sudo docker image prune --all --force
          df -h

      - name: Download web build
        uses: actions/download-artifact@v4
        with:
          name: web-ui-build
          path: web/out/

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: ~/.cargo/registry
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

      - name: Cache cargo index
        uses: actions/cache@v4
        with:
          path: ~/.cargo/git
          key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

      - name: Cache cargo build
        uses: actions/cache@v4
        with:
          path: target
          key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

      - name: Check formatting
        run: cargo fmt --all -- --check

      - name: Run clippy
        run: cargo clippy --all-targets --all-features -- -D clippy::correctness -D clippy::suspicious -D clippy::perf -W clippy::style -W clippy::complexity

      - name: Check documentation
        run: cargo doc --no-deps --all-features

  # Unit and integration tests
  test:
    name: Test Suite (${{ matrix.os }}, ${{ matrix.rust }})
    runs-on: ${{ matrix.os }}
    needs: [build-web]
    continue-on-error: ${{ matrix.rust == 'beta' }}
    strategy:
      fail-fast: false
      matrix:
        include:
          # Primary testing on Ubuntu with both stable and beta
          - os: ubuntu-latest
            rust: stable
          - os: ubuntu-latest
            rust: beta
          # Cross-platform validation on stable only
          - os: macos-latest
            rust: stable
          - os: windows-latest
            rust: stable
    steps:
      - uses: actions/checkout@v4

      - name: Free disk space (Ubuntu only)
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo rm -rf /usr/share/dotnet
          sudo rm -rf /usr/local/lib/android
          sudo rm -rf /opt/ghc
          sudo rm -rf /opt/hostedtoolcache/CodeQL
          sudo docker image prune --all --force
          df -h

      - name: Download web build
        uses: actions/download-artifact@v4
        with:
          name: web-ui-build
          path: web/out/

      - name: Verify web build artifact
        shell: bash
        run: |
          echo "Checking web/out directory..."
          if [ ! -d "web/out" ]; then
            echo "WARNING: web/out directory does not exist"
            ls -la web/ || true
          else
            echo "Directory exists. Contents:"
            ls -la web/out/ || true
            echo "File count:"
            find web/out -type f 2>/dev/null | wc -l || echo "0"
          fi

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: ~/.cargo/registry
          key: ${{ runner.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

      - name: Cache cargo index
        uses: actions/cache@v4
        with:
          path: ~/.cargo/git
          key: ${{ runner.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

      - name: Cache cargo build
        uses: actions/cache@v4
        with:
          path: target
          key: ${{ runner.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

      - name: Run unit tests (lib, default features)
        run: cargo test --lib --verbose

      - name: Run unit tests (bins, default features)
        run: cargo test --bins --verbose

      - name: Clean build artifacts before all-features
        run: cargo clean --release

      - name: Run unit tests (lib, all features)
        run: cargo test --lib --all-features --verbose

      - name: Run unit tests (bins, all features)
        run: cargo test --bins --all-features --verbose

      - name: Clean build artifacts before TUI
        run: cargo clean --release

      - name: Run unit tests (lib, TUI feature)
        run: cargo test --lib --features tui --verbose

      - name: Run unit tests (bins, TUI feature)
        run: cargo test --bins --features tui --verbose

      - name: Run doc tests
        run: cargo test --doc --all-features

  # Build TUI binaries for multiple platforms
  build-tui:
    name: Build TUI (${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          # Linux x86_64
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact_name: periplon-tui
            asset_name: periplon-tui-linux-x86_64

          # Linux ARM64
          - os: ubuntu-latest
            target: aarch64-unknown-linux-gnu
            artifact_name: periplon-tui
            asset_name: periplon-tui-linux-aarch64

          # macOS x86_64 (Intel) - use macos-13 for native Intel build
          - os: macos-13
            target: x86_64-apple-darwin
            artifact_name: periplon-tui
            asset_name: periplon-tui-macos-x86_64

          # macOS ARM64 (Apple Silicon) - use macos-latest for native ARM build
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact_name: periplon-tui
            asset_name: periplon-tui-macos-aarch64

          # Windows x86_64
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact_name: periplon-tui.exe
            asset_name: periplon-tui-windows-x86_64.exe

    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Install cross-compilation tools (Linux ARM64)
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: ~/.cargo/registry
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

      - name: Cache cargo index
        uses: actions/cache@v4
        with:
          path: ~/.cargo/git
          key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

      - name: Cache cargo build
        uses: actions/cache@v4
        with:
          path: target
          key: ${{ runner.os }}-${{ matrix.target }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}

      - name: Build TUI binary
        run: cargo build --release --bin periplon-tui --features tui --target ${{ matrix.target }}

      - name: Strip binary (Unix)
        if: matrix.os != 'windows-latest'
        run: |
          if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
            aarch64-linux-gnu-strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
          else
            strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
          fi

      - name: Calculate checksum (Unix)
        if: matrix.os != 'windows-latest'
        run: |
          cd target/${{ matrix.target }}/release
          shasum -a 256 ${{ matrix.artifact_name }} > ${{ matrix.asset_name }}.sha256

      - name: Calculate checksum (Windows)
        if: matrix.os == 'windows-latest'
        run: |
          cd target/${{ matrix.target }}/release
          certutil -hashfile ${{ matrix.artifact_name }} SHA256 > ${{ matrix.asset_name }}.sha256

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.asset_name }}
          path: |
            target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
            target/${{ matrix.target }}/release/${{ matrix.asset_name }}.sha256
          if-no-files-found: error

  # Build DSL executor binaries
  build-executor:
    name: Build Executor (${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact_name: periplon-executor
            asset_name: periplon-executor-linux-x86_64

          # macOS x86_64 (Intel) - use macos-13 for native Intel build
          - os: macos-13
            target: x86_64-apple-darwin
            artifact_name: periplon-executor
            asset_name: periplon-executor-macos-x86_64

          # macOS ARM64 (Apple Silicon) - use macos-latest for native ARM build
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact_name: periplon-executor
            asset_name: periplon-executor-macos-aarch64

          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact_name: periplon-executor.exe
            asset_name: periplon-executor-windows-x86_64.exe

    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: ~/.cargo/registry
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

      - name: Build executor binary
        run: cargo build --release --bin periplon-executor --target ${{ matrix.target }}

      - name: Strip binary (Unix)
        if: matrix.os != 'windows-latest'
        run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.asset_name }}
          path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
          if-no-files-found: error

  # Security audit
  audit:
    name: Security Audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install cargo-audit
        run: cargo install cargo-audit

      - name: Run security audit
        run: cargo audit

  # Code coverage
  coverage:
    name: Code Coverage
    runs-on: ubuntu-latest
    continue-on-error: true  # Don't fail CI if coverage fails
    needs: [build-web]
    steps:
      - uses: actions/checkout@v4

      - name: Free disk space
        run: |
          sudo rm -rf /usr/share/dotnet
          sudo rm -rf /usr/local/lib/android
          sudo rm -rf /opt/ghc
          sudo rm -rf /opt/hostedtoolcache/CodeQL
          sudo docker image prune --all --force
          df -h

      - name: Download web build
        uses: actions/download-artifact@v4
        with:
          name: web-ui-build
          path: web/out/

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo-tarpaulin
        id: cache-tarpaulin
        uses: actions/cache@v4
        with:
          path: ~/.cargo/bin/cargo-tarpaulin
          key: ${{ runner.os }}-cargo-tarpaulin-0.31.0

      - name: Install tarpaulin
        if: steps.cache-tarpaulin.outputs.cache-hit != 'true'
        run: |
          # Use precompiled binary for faster installation
          TARPAULIN_VERSION="0.31.0"
          wget https://github.com/xd009642/tarpaulin/releases/download/${TARPAULIN_VERSION}/cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz
          tar -xzf cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz -C ~/.cargo/bin/
          chmod +x ~/.cargo/bin/cargo-tarpaulin

      - name: Generate coverage (unit tests only)
        run: |
          # Run tarpaulin on unit tests only (lib and bins, excluding integration tests)
          # Using --lib and --bins flags to exclude integration tests in tests/
          cargo tarpaulin \
            --features cli,server \
            --workspace \
            --lib \
            --bins \
            --timeout 600 \
            --out xml \
            || echo "Coverage generation failed but continuing..."

      - name: Upload coverage to Codecov
        if: success() || failure()
        uses: codecov/codecov-action@v4
        with:
          files: ./cobertura.xml
          fail_ci_if_error: false