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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13Windows x86

stitchflow_local_agent-0.3.17.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.17.5-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (10.8 MB view details)

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

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

Uploaded CPython 3.13macOS 11.0+ ARM64

stitchflow_local_agent-0.3.17.5-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.17.5-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

stitchflow_local_agent-0.3.17.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.17.5-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (11.0 MB view details)

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

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

Uploaded CPython 3.12macOS 11.0+ ARM64

stitchflow_local_agent-0.3.17.5-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.17.5-cp311-cp311-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

stitchflow_local_agent-0.3.17.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.17.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (11.3 MB view details)

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

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

Uploaded CPython 3.11macOS 11.0+ ARM64

stitchflow_local_agent-0.3.17.5-cp311-cp311-macosx_10_9_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 44ec52ad677041642ac969105c2bff2c85127d669bf59e703200cbb0dd20f158
MD5 64d2a6da01b633a586195673ee98e545
BLAKE2b-256 e2fdf54d06f098f3b8a53f5886146ab2a343d8c9b20697aaecbde2c0eb285300

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 4cb36eb8131418b15fa0f3d1c75855c02631e25bcf0d017ceddda00faa9ae4bc
MD5 c306cabf6a4335db14ba24387494dbec
BLAKE2b-256 4746e2416a8314ff3bb1fbb4bc12215e051a24484d1b4eb11d4ac87502fe9d4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e60886e9eb79f4f128817d5fad20d4176f29d08823df73bb2424b6a48348c2d1
MD5 a4819710f882fabeb0d20e81074ff6a9
BLAKE2b-256 9ce34845fdb67e3d81a93870d8c2ef595b696355c44c14c60656f51722b28322

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.17.5-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.17.5-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 9b990938c003a8206c08e626b71d74c136e46466fbb7c54e2c2a4588976ac9cb
MD5 37b224d14b7e82ed5e28ac894c111a70
BLAKE2b-256 0327fe58afac4f09090ec796e7cc55a5b092799ec31e1d6a41653caf5ce41344

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9c8d3742266af0fc5ded608478cc4b6c9aff9f08071df74ede5e6a51a28f0619
MD5 2f3bec97eee91a85a9316c41350e6714
BLAKE2b-256 275da9c238019832109809824139308e6c00ac82ce5f7e8c031228546a50e3d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8566d1f3b81010fd6c9b007c8c05dcc8c18ef5ade6367723f752944cac9c9666
MD5 d0e1eb7b9bb1284cff5b4d9eda38a6ef
BLAKE2b-256 df844a5014b76639c40bc05b032b2d9109bab4b2cdfd60cd428367cce3f98059

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cea92720ed17ecf3d63a686ea9094ce26df7a0c94eb6cecd9f39d3a2b8659ac5
MD5 2c0157f78e1257c541d460c0acad0f78
BLAKE2b-256 f1f9095597b889d51a3b412bbe3927eaad8775720eb88c62e9fd6a8c3a8132a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 b169ad3df9cfdba302df1f2dd1174908527c0a35d6d025470a8e2790fd712a0b
MD5 15da038b7bfdae876d1a3ea111180e1b
BLAKE2b-256 6fa6c46fbb5bb2e60103ad6e2e53f8d1fbba496903dfb0e736503196831a8fd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1ab8b5ac2af76a7455ac0ec34837198e3262c1550b215432e733a969d578284
MD5 4d63c036172e0a1d9765d2508f6726f6
BLAKE2b-256 8104eef5c45cd5f0522c2c0650c79f90536f0b5854e54423521247fdecdca357

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.17.5-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.17.5-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 b944980b476db7756e61b127f6f1f4e6f1f690fe157b3a7e0fa373fa7d0492de
MD5 607ac4c5444ae4fb81c85852da659967
BLAKE2b-256 3d24236892a8ec5be47fb39db555e756cb7c152e83b8251607955f9f042f6333

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a0ca2f8cfb06cf1c18bd459a7ed8671234e3a2ec7cd42f76181c3a55458410c3
MD5 bd5ec1ce4d9ac7687ab6df7ff3189a45
BLAKE2b-256 7d160815d7a5d0bf1edb751bc2b1f385f67c9b3fe46915047b772bd45721065e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0205ab340975963d6860d20fa56dcb35dfca16d90f4e09d5cc1600757cc3d79a
MD5 b708db1ff1f724ee3f7ded9d75fed616
BLAKE2b-256 dc89cd478f6a749f835c91970196cbab4f8468c58ed86e24a19c9630090268de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7432bea76437ebdfe9cd9f3c6bfa6e9c0c42eed80eeb319cd038dcdc69a41246
MD5 36593708f548cbf5187eae696ea4fe3c
BLAKE2b-256 7d0b771fd94efb0231be3f4099d9ff6fc7b093f3d9cb20075825ac3cb067ce3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 06dce21023ffe95c08a994db77f2813e6243ce241b72cb67d55fc17a2ed31106
MD5 0ab9d5626855339afd9cf047936ca75c
BLAKE2b-256 cf647bd4301ccb2bf8e4b9b4bf70821e68c67c975f4c4ba0215aca818825bccf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2fd8d683e1f0db309e633cfbdf1891ca99c69afaebd7661c4e8487a78dddab51
MD5 03044a649952c4f99d852078c6171a76
BLAKE2b-256 e3e023ab928e1b948d8cb3d87cc9ec327f41aba8ba5ed57038239ce1117153c7

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.17.5-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.17.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 056546d3efd3f8094918ffffbaa6f6570aa8c70fe6cfe42f0b9411661e6fd21d
MD5 d2d1163868e76712fb7fd83cc5996c1d
BLAKE2b-256 28cb96cf2e8c0d4285b29c7c89d84152b089f8f250c46b2c7738a52b882930b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aabfb5e54fd7f1ef3b6b4232e6d08ee9bc78296e91a0b8f5a5a54605cfaa513e
MD5 976b13061ed7225dbf5f7aefe69baefa
BLAKE2b-256 32da2b7dea796a3afc722d5be2fb80a6e8b78d93a498b0e719cb24aa3ef2c912

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.5-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d28862ea6e953b929acc31e96bcc2da828796ce638d4cfb9578eb36876de4173
MD5 4a224bff0fdde62b23b50cec2d70cc80
BLAKE2b-256 40bc6d4fff4aa26d9be399eef896f6db8b63b4465530b2078ccd0314f68c3c2b

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