Skip to main content

Local Stitchflow daemon for browser automation tasks and data sync

Project description

stitchflow-local-agent

Local daemons that automate SaaS admin tasks for a Stitchflow workspace:

  • Action agent — executes user removals and role changes in ChatGPT and Calendly.
  • Data sync — exports user CSVs from ChatGPT and Calendly, then uploads them to Stitchflow.

Both run headlessly via agent-browser (Playwright) using a shared persistent browser profile for session management.

Install

pip install "git+https://github.com/Stitchflow-website-webapps/stitchflow-local-agent.git"

Two CLI commands become available:

CLI Purpose
stitchflow-agent Action execution — user removal, role changes
stitchflow-sync Daily data sync — app CSV export and Stitchflow upload

Quick start

# 1. First-time setup — installs agent-browser, opens browsers for login
stitchflow-agent setup
stitchflow-sync setup

# 2. Single run
stitchflow-agent run
stitchflow-sync run

# 3. Foreground daemon commands (for local testing)
stitchflow-agent daemon
stitchflow-sync daemon

# 4. Check health
stitchflow-agent status
stitchflow-sync status

Package structure

stitchflow_local_agent/
  common/                  shared config, browser helpers, daemon, logging, installer
  actions/
    api_client.py          Stitchflow task API client
    dispatcher.py          task routing by (integration, action)
    chatgpt/               ChatGPT: remove_user
    calendly/              Calendly: remove_user, change_role
  sync/
    stitchflow_upload.py   generic CSV → Stitchflow UI upload
    calendly/              Calendly user export (UI-based)
    chatgpt/               ChatGPT user export (API via browser session)
  agent_cli.py             stitchflow-agent entrypoint
  sync_cli.py              stitchflow-sync entrypoint

Action agent (stitchflow-agent)

Polls the Stitchflow API for pending tasks, claims them, and executes each one through browser automation.

stitchflow-agent setup    # auto-install agent-browser + Chromium, configure env, open login
stitchflow-agent login    # re-authenticate (auto-installs if missing)
stitchflow-agent run      # process all pending tasks once
stitchflow-agent daemon   # poll continuously (foreground; launchd/task manages background)
stitchflow-agent status   # show config, daemon PID, last task results

Supported actions

Integration Action Description
ChatGPT remove_user Remove a team member by email from the ChatGPT admin panel
Calendly remove_user Remove a user from the Calendly organization
Calendly change_role Change a user's role (Admin ↔ User)

Extending

Register a new handler in actions/dispatcher.py:

HANDLERS[("app_name", "action_name")] = handler_function

Data sync (stitchflow-sync)

Exports user CSVs from connected apps and uploads each to the matching Stitchflow connection. All configured apps are synced in a single cycle.

stitchflow-sync setup     # open Calendly, ChatGPT, and Stitchflow for login
stitchflow-sync run       # run one full sync cycle
stitchflow-sync daemon    # local foreground loop (use launchd/task scheduler for production background runs)
stitchflow-sync status    # show config, logs, daemon status, recent CSVs

Supported sync sources

App Export method Notes
Calendly UI automation — click Export → Active → download ZIP CSV extracted from ZIP automatically
ChatGPT API via browser session — JS fetches /api/auth/session, paginates the users API Account ID auto-discovered from session

Sync cycle

Each cycle runs sequentially: Calendly export → upload → ChatGPT export → upload → close browser.

Calendly

  1. Opens Calendly admin → clicks Export → Active → downloads ZIP → extracts CSV.
  2. Opens Stitchflow → Connections → searches "Calendly" → uploads CSV → polls until "Connected".

ChatGPT

  1. Opens ChatGPT → executes JS that fetches the auth token, auto-discovers the workspace account ID from the session, and paginates the users API.
  2. Converts the returned JSON to CSV in Python, saves to ~/.stitchflow/data-sync/chatgpt/.
  3. Opens Stitchflow → Connections → searches "ChatGPT" → uploads CSV → polls until "Connected".

Audit logs

JSONL logs under ~/.stitchflow/logs/:

File Records
calendly-export.jsonl Each Calendly export — timestamp, CSV path, file size (success) or error (failure)
chatgpt-export.jsonl Each ChatGPT export — timestamp, CSV path, file size, user count (success) or error (failure)
data-sync-audit.jsonl Each Stitchflow upload per app — timestamp, CSV path (success) or error (failure)
data-sync.log Full sync cycle run log

Extending

Add a new sync source in three steps:

  1. Create sync/<app>/export.py with an async def export_<app>_users() -> str | None function.
  2. The upload side (sync/stitchflow_upload.py) is already generic — pass any app_name.
  3. Wire the export into sync_cli.py's run_sync() via _sync_app().

Environment variables

Variable Required Default Description
STITCHFLOW_API_URL Yes http://localhost:3030 Stitchflow API base URL
STITCHFLOW_WORKSPACE_ID Yes Stitchflow workspace ID
STITCHFLOW_API_KEY No API key (prefer keyring storage)
AGENT_BROWSER_PROFILE No ~/.agent-browser-profile Persistent Chromium profile path
CHATGPT_ACCOUNT_ID No auto-discovered Override for ChatGPT workspace ID (normally detected from session)
STITCHFLOW_AGENT_POLL_INTERVAL_SECONDS No 60 Action daemon poll interval
STITCHFLOW_AGENT_POLL_MAX_IDLE_SECONDS No 900 Action daemon max idle backoff
STITCHFLOW_AGENT_POLL_MAX_ERROR_SECONDS No 300 Action daemon max error backoff
STITCHFLOW_SYNC_INTERVAL_SECONDS No 86400 Sync daemon interval (24 h)

All config is persisted to ~/.stitchflow/agent.env during setup.

Daemon scheduling (recommended for production)

See DAEMON_SETUP.md for macOS launchd and Windows Task Scheduler installation guides covering both daemons.

Security

  • API keys — stored in the OS credential manager (macOS Keychain / Windows DPAPI) via keyring. Falls back to ~/.stitchflow/agent.env if keyring is unavailable.
  • Browser sessions — maintained in a persistent profile at ~/.agent-browser-profile. No credentials are stored in code or config files.
  • Action proof artifactsbefore.png, after.png, and audit.json per task under ~/.stitchflow/artifacts/.
  • Audit trail — rolling log at ~/.stitchflow/logs/audit.log.

Dependencies

Package Purpose
Python 3.11 - 3.13 Runtime
httpx Async HTTP client for the Stitchflow API
keyring OS credential manager integration
agent-browser Playwright-based browser automation CLI (installed via npm)

stitchflow-agent setup / stitchflow-sync setup auto-installs agent-browser via npm install -g agent-browser (or brew install agent-browser on macOS), then runs agent-browser install to download Chromium.

Building and releasing

All Python source files are compiled to native extensions via Cython before distribution. Published wheels contain only compiled binaries — no .py or .c source files.

Release workflow

  1. Bump the version in pyproject.toml.
  2. Commit the version bump, then create the matching tag from that same commit: git commit -am "Release v<version>" && git tag v<version> && git push && git push --tags.
  3. GitHub Actions builds compiled wheels for macOS (ARM + Intel), Linux, and Windows across Python 3.11–3.13.
  4. A verification step checks that no source files leaked into any wheel.
  5. The workflow validates that GITHUB_REF matches [project].version before publishing.
  6. Wheels are published to PyPI automatically.

Local testing

# Install build deps
pip install "cython>=3.0" setuptools wheel

# Compile extensions in-place (for development testing)
python setup.py build_ext --inplace

# Build a wheel for your current platform
pip wheel . --no-deps -w dist/

# Verify no source files in the wheel
unzip -l dist/*.whl | grep -E '\.(py|c)$'
# (should return no results)

CI configuration

The build pipeline is defined in .github/workflows/build-wheels.yml. It requires a PYPI_API_TOKEN secret configured in the GitHub repository settings under an environment named pypi.

Further reading

  • ARCHITECTURE.md — internals: dispatcher, browser layer, sync pipeline, error handling, file layout.
  • DAEMON_SETUP.md — launchd / Task Scheduler install guides.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

stitchflow_local_agent-0.3.16.4-cp313-cp313-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.13Windows x86-64

stitchflow_local_agent-0.3.16.4-cp313-cp313-win32.whl (1.4 MB view details)

Uploaded CPython 3.13Windows x86

stitchflow_local_agent-0.3.16.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.16.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (10.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

stitchflow_local_agent-0.3.16.4-cp313-cp313-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

stitchflow_local_agent-0.3.16.4-cp313-cp313-macosx_10_13_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

stitchflow_local_agent-0.3.16.4-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12Windows x86-64

stitchflow_local_agent-0.3.16.4-cp312-cp312-win32.whl (1.4 MB view details)

Uploaded CPython 3.12Windows x86

stitchflow_local_agent-0.3.16.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.16.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (10.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

stitchflow_local_agent-0.3.16.4-cp312-cp312-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

stitchflow_local_agent-0.3.16.4-cp312-cp312-macosx_10_13_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

stitchflow_local_agent-0.3.16.4-cp311-cp311-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.11Windows x86-64

stitchflow_local_agent-0.3.16.4-cp311-cp311-win32.whl (1.5 MB view details)

Uploaded CPython 3.11Windows x86

stitchflow_local_agent-0.3.16.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.16.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (11.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

stitchflow_local_agent-0.3.16.4-cp311-cp311-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

stitchflow_local_agent-0.3.16.4-cp311-cp311-macosx_10_9_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 544e9a9841868671cb766a591a131b6e945437d47c452afc4ef398cd5181d9b7
MD5 6439119a30b9cebd2d9f8853269b03a8
BLAKE2b-256 13b3c8fe125e359b1e0d75b5c1e8c47c1a6ffe1f2c6be56c6412d3af1cc64e28

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp313-cp313-win32.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 f71edc968250e7fea4aa037d4469cf52b1d477dd1000f66d6d832ee50428f02e
MD5 4dde93b922ef57e4e3cb684af8f4f494
BLAKE2b-256 0dc60e5f474b69f25b00c967018d037e7b980b0afd5029f143e7d852f7185d8a

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd05759132eb02766ca8aa4d86687d9cb0cdef16ccd8e45242472a3ea171f24e
MD5 8c767559caed98308db806f1ab1e77c3
BLAKE2b-256 887b3f6727cd00312282eb443760828d563273128fd2fc6f2ddd9eeacf6d7a33

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 e90bf63790c2daaceeecec232d61679e41aa0c6317d4bd5693be6d5599824f3f
MD5 b8b54dd752fce6f86741be6f2b6597af
BLAKE2b-256 dd74a1f9a6297f32c66a82abc8e9a8bf2a9b7c96bde6c791b4bce98b7d14455f

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f12c62e08ce5e6850198b6886b61519f7455c9939e66408f2506a4c8d847eff
MD5 21bac81389e549054b3d0e869e3e0df3
BLAKE2b-256 c981e13cd3fe36fe13e8ff5b4f316fab71bb2e937d2f883c5a5afb9256696d15

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 18f0c16801e91ff2ba06fd87c57bfc253648aeebdede88c37ab7dd38b0dd9614
MD5 70a032161749a48e84a3233800b1eeaf
BLAKE2b-256 2719cf7cf3a8351876ead0750af180db5c8d09cd7f7721b957ce074979e4e35b

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a1aa299e0b2c07cdb75b00ac0d4ca361319316fa95ee9fda42f083499bd2b5a7
MD5 13b1281b5caf017205a62ae288c92b24
BLAKE2b-256 313071c4d44d4c39adac15c12d85d7d9c0a780dba40fb20b74ad5e00c44eff23

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp312-cp312-win32.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 59e9e2ce7f62ac93a6d38b167bd861eb7399d2e305af3a43be3ab63bcb6cb0f4
MD5 0f3d18295b9b7251c7c20556168d0bc6
BLAKE2b-256 7ca0ebcf3fcd315a0a09f2eaed52691da4b5fd4e575205cb8351c69b189b384c

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e0b0d6ae31d0cfc148297cb20d53a630d722602260b030cf333bcd8c934a3099
MD5 a092330de208f37f4bee702e469c6ca5
BLAKE2b-256 39b67a02bfef4b7368ab894e13595d3286873a7fc027ef12d0194a2e821a3bd0

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 78a5cb7b3f040e64478e59520a3428212b14fdcc0e753d54302dadbd66710336
MD5 fe9902a5d4d02d3d9cea68643d9aae22
BLAKE2b-256 b5e724046a915b129a0c25d9d514ae0aa2d2dee18f9333df730f0d481c894522

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 985ca52822de9ac2809b8ae71520e7c89a00cc254c9942d161633785928b4c4e
MD5 09d0bc9ec868657779ff3c9277f8e729
BLAKE2b-256 8a16571824997a39636b23fc992961ea6e88c2ba7993205971ed0964be7a47fd

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 963d35e8070e33bcc93ef3f61978b766efb2d5da748eed5f03de59a6479046e9
MD5 c1a90c65579cfb2a358b3543af1cd867
BLAKE2b-256 887eb5ea6811c6ccbefb3c4bf24af975aeea648ba6ea1fb170c4855751eacf61

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4a26bc1ca60f816c24ea3af5bb6c67ba34128850f6790589ec01885302d7b09c
MD5 9b25b10c71abab337f50337144606162
BLAKE2b-256 d19e0c04695277a3a3c5625e8e74226f739ae75e064f2c6b80d973e735975641

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp311-cp311-win32.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 21ae045f41b7971c8ebc8a19e64d33e99aa68e58c6f3887816127b89f29e5fbd
MD5 7f0b5065769c63a3a99d017394d1e65c
BLAKE2b-256 f0ed50398e3989639d84ddd63475787ab3bab8f1652ffd90420ab78de9667473

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1b0046876632185a1c95030da8069025a294eaaa103f8c4ac0a02d3677f437b4
MD5 81ca354235eacc41f19474746d0e030f
BLAKE2b-256 bcc5f79633c6ca432b531cd645dc1c2ab28abed18afb8a296906219b83e30918

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 384aa1d35cd5297d76b3b86d4d59773932a69694ea94846f4b5d13dcc93aa6e6
MD5 a4bf3305ffeadd1758b6ea15ee3ce339
BLAKE2b-256 9ed316501c6a99d0204f6c98af4b179eb3ff25e2d9a9cd5aaa32fc4831f14160

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 49cc03a5bc8f5202b0623126e53a59907bfcbfec6a32cfa92de4f33e505808e4
MD5 e614ace362b02fca1d9cc6bd36c58992
BLAKE2b-256 4c3dab69c5819d12142bd783faf0c469f1609bf390f0e4867a10fa57d7065143

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.4-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ea11efc5fbcf3ae92e2b91f8d7e4681ea11357759e0a20807d1397b39950e4c2
MD5 d7063b75bb23ebff719c5a487f960757
BLAKE2b-256 bf6e40064aa94e5913cbd9fa0925f4d38a52bbff4c12d93072c7c6ab532e7cf5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page