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.3-cp313-cp313-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.13Windows x86-64

stitchflow_local_agent-0.3.16.3-cp313-cp313-win32.whl (1.2 MB view details)

Uploaded CPython 3.13Windows x86

stitchflow_local_agent-0.3.16.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.16.3-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (9.3 MB view details)

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

stitchflow_local_agent-0.3.16.3-cp313-cp313-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

stitchflow_local_agent-0.3.16.3-cp313-cp313-macosx_10_13_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

stitchflow_local_agent-0.3.16.3-cp312-cp312-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12Windows x86-64

stitchflow_local_agent-0.3.16.3-cp312-cp312-win32.whl (1.2 MB view details)

Uploaded CPython 3.12Windows x86

stitchflow_local_agent-0.3.16.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.16.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (9.5 MB view details)

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

stitchflow_local_agent-0.3.16.3-cp312-cp312-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

stitchflow_local_agent-0.3.16.3-cp312-cp312-macosx_10_13_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

stitchflow_local_agent-0.3.16.3-cp311-cp311-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.11Windows x86-64

stitchflow_local_agent-0.3.16.3-cp311-cp311-win32.whl (1.3 MB view details)

Uploaded CPython 3.11Windows x86

stitchflow_local_agent-0.3.16.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.16.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (9.7 MB view details)

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

stitchflow_local_agent-0.3.16.3-cp311-cp311-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

stitchflow_local_agent-0.3.16.3-cp311-cp311-macosx_10_9_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c3bf5c6a07b4c38b64345a957f4022decdf2e12928ab5466895777ff6122f2e7
MD5 80cedca59b481a7d31dc5b6896ed8f65
BLAKE2b-256 49cc2642eec4672a051da735177f8cfac0160e9314e8aba73dc8c066233cf660

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 fd346853069adbc39f071b938de83572ea30e29173b64b2a5d989a84ad777c30
MD5 3b8e100076dffcc054cc664c6db51859
BLAKE2b-256 6096888df8bff32fbcb64e7d2f996c4c4c92254f36c9240dc51374785376367a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7d82e4fd4ff19313a17e33a85bf0e0b0da8d9e7cd5426fdd3f563eb765c1caf
MD5 deedc34643c1ff0569ba458b55f5fd1d
BLAKE2b-256 1f0510dd3b599c8dec5caad32b62cce23a75e6aa0ba047c322b9d278bcf56ad2

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.3-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.3-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 c307a5c245abb841408765ea3747e1d720580ba609ebda28eefb80749997b578
MD5 f31eb9ffe6e5c24ca46665f73c73343c
BLAKE2b-256 5ff5881cfb30620737e1f8422a81383062c0df425795e60a7084dd1fa39451b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e3db0c2839a0f556b4f2b75060b55b90fd0b3449e1d2a4f4b30d7d90f6085cf1
MD5 f256a8ad9e7c9ed91c247c198a311793
BLAKE2b-256 5b8ee5b366cacabe5e70122155a7602d1d730372a77ecf12ee8104fd5fbd5eba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9a20e373577d650541f821b2eaff770ed2a7f3d89952a4d8ef8bede1406854b1
MD5 cad958c486dfcbb394182a2297559fe0
BLAKE2b-256 77a5b93c79818bbfa43adba6e228faa0807ac26598d0d65f62c243669d76c143

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 101e9350014347225a1c7c5d73c875d4075ce00b477395d19f7f7ced1fa8f8ff
MD5 735df2711781f49ac9e51ca7d42a86ee
BLAKE2b-256 3b70e905c3c8341dc013cd4f1d6412ecdd2de2b27ecd5b6e083fe631a21562ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 4ebd468bd87a689279e0eed00fbdd0200fbc2d7ad1d753043758a5141a23ad85
MD5 acf9bc3d746ae36df93b2817e84eab41
BLAKE2b-256 07f368ab80e11b135de6760007751f0f914e668796b9cf0927163f43761b3d05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6864d1349fec3a76d0058ada0e1972e486b681fab24bf5be6a16630c57087125
MD5 76398376dfe4d692dd275db629c41d97
BLAKE2b-256 a6c7869c8c8f0f03f37af4b4e8c9646334bb1f6361ecf765cdd8f83d53a69c66

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.3-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.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 4f732896a12e4c6a1cfba35c5d2ee9da8eff7d9b35660a58c2edf68f89085954
MD5 e66fd3c04c2221272229b9d698d6436b
BLAKE2b-256 cb4c01e1dfafa7e418b2aeaab7f870f327a6b087ebb0edb65a9e98e961bc6f54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bc566a75ab907188f823a7ebd03a9b92dd9e34e0681f97c1799fdb89de7ac0cc
MD5 014f75975a56e6abfd80efb49f29b0f4
BLAKE2b-256 3f9cd24acb2c95f173b41bf293286d566fddf35bc82af9897961a29572396479

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ea7e29166b8186836a358c84f90bd14e0470839f0acd98819e847d4c7b995dad
MD5 b5617a3fef322c2e666299eb72949fa2
BLAKE2b-256 bb6a3bc30c7cb104ff8b6504764b0cdd94e52c6fd5604ffd8937f7f3280c5941

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7d74fe384a719ef4ff8b0e5665bf726361e76d14298b7f46f82e012d00b9e1b6
MD5 a79445655270b7f1b2d691a510286546
BLAKE2b-256 8be583ed624b4ff5d5fff77d71c81f1b5062ea8430b1f04d6e2dfd46ec7ee1ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 09d123ca25b81568907cd93bb7c1e2dbf1d8fb2f2f7c5e21f1cbfd4b73805c2f
MD5 7bffefef55885bd3c22d90ab1d372724
BLAKE2b-256 76ba16fd28b97fd3ec6121caaf0d996263f7f4de7ac2667a2685a459f82efa1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f3338d60bcf10f4ef28af11214eeee4d831c95b13ba3f44549ad908fb7cae29e
MD5 d3d5b7811f5d09b98e75fda3fdab9d21
BLAKE2b-256 713235b3d5f302bc8b490ea34d6c071f612dbaa685fc3fb26c315c06e973810d

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.3-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.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 45c8764443e15f9f45252822d83b6133a4bf80c991455a1f195190f047874113
MD5 657656ba003e96f1795d5902426cf301
BLAKE2b-256 c03766453831f9d5beee08b039ecb006594f501167a85f7e6c3382b8e80f863f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9e41c7b4a0db1fb3fe263c4135a2a852e430cf4a136ef1fb2dcb0d2356195e53
MD5 0d6a2f429bb59b72c979c2cd8ba2cddd
BLAKE2b-256 a8cdee4140e972a64222393926d86c7c9529530d040444b5d8911b5ea8c45df6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1fdc8747440cdc09b8843acd72f74ff4332068f7fc6655350098d28723b5979b
MD5 923e7937bcd321c41598293fcb3fbc2c
BLAKE2b-256 adfb970edbcd8bdabcab263a9f8940cbc82a38a788ded64d015b6ea722b0702c

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