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 and tag: git tag v<version> && 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. 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-cp313-cp313-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13Windows x86

stitchflow_local_agent-0.3.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.16-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (9.1 MB view details)

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

stitchflow_local_agent-0.3.16-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-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-cp312-cp312-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

stitchflow_local_agent-0.3.16-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.16-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (9.3 MB view details)

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

stitchflow_local_agent-0.3.16-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-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-cp311-cp311-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

stitchflow_local_agent-0.3.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.16-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (9.5 MB view details)

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

stitchflow_local_agent-0.3.16-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-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-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7677c8e5d604a5049441433a962a6baef8e76f11381b7b1cd78ddffeaf54d084
MD5 4d2152979b414dc94b148fa23e730a43
BLAKE2b-256 06520cd8c30691a21987eb8658e1e333e7ab2896030a54abeaa0a29621ba728f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 59e6f942d8c7e46e7fb30c33df993cae0e2ee446ce887b1a15997e75f098686b
MD5 f06455bb3f5d34ae6fd48b22df7a0d5c
BLAKE2b-256 2e0f5f5fbb7c331058fc18d9e7e77f596f0c106c992a6add25ea1131ba2e418e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9f839c82765dfbb7141f9c9406e7333c275db3583949489b7775ee7a6e3b02ac
MD5 2b822a94805d36274f59859997bd9a03
BLAKE2b-256 9ae146c51ee7256a5f2b4de69d8a85e384f66a134cb807eb70ff9251a13296f4

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16-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-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 96bcd146961ef6e682de72427c9d6872e0b7fc48c8ad217d1272e9cdacb9af90
MD5 8094b48061ee8cdc5c40bf2cd3ebf2f1
BLAKE2b-256 296c827029f5023e094245d14cf180954a0dca862aed4a48e9968dc83160c663

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bc4cb3f4e5f6968aef5d3dee3ced3bcfa917049a5126f5b20aa7c6b32017d843
MD5 efbf5e30719c17cf68a24f284f4aaece
BLAKE2b-256 173e4e5b42986ee20476339281bbd2288f58303ad07ed170eb9b38311f40ba34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 49786fe55445985602e487639f55548571e76a7a698d59164b61bcdc4a7b1536
MD5 f7a88734cf25ba4b845aee3e917d9893
BLAKE2b-256 e55382b1df7cfd4d73597109a7b6c2cbcb1999860c2ad02c4c870cc5080e9dcd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a34bc3327eb3a997e80db22583474c215929274ec7666b1293b0d709c0bf402b
MD5 f85757f11089bdc91c3b51cb52e962df
BLAKE2b-256 b90a44241db6f34770392bf9bc92e52d9529f25c6ce043931d44340f154836b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 5ef09f522d4ed1e79acac5363b5e65207eb717af022e608c2ddf2df14ce8adfc
MD5 ee4241230ae95a17e937b73bc87fc6ca
BLAKE2b-256 eca4b9cf29a15392d3ee0842f3b607e803334375fb02fc5f58d3ac74b0fab1de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 64bd81c1ec0b9fd93915454176634971b1c6acaf5e78089919932353de80fad3
MD5 5b5ebb119f8cab0b22d2c26df7e13481
BLAKE2b-256 0a86d57e1a513ce90605225a2fd79208c854985ebb9726bd15d900a6645fab6b

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16-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-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 6eb1212832889b79a50d701b01f06b6c6e8a787e4a730e4edc580d2795657a7f
MD5 3eaa4442a672d951d7a8c023e769b10b
BLAKE2b-256 dbd57b58162f33a0058accd5d886a6735f6ea274096dd89ad55b3f1cf7df4346

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 54e42b9dd7ed2a1f17e164ae572edcca9620c5e3160cf82cac5fcc508c1754ca
MD5 4ddb39e45561f5a501730e3dbce3b1da
BLAKE2b-256 b6ed986e5007dee805196aa379a06f908c39aefaeb33ea74030ac62b2b39cb43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 af2de8b2ffb87e56627579d12cb7b8a77fe2f10e6e5acecf3718b3b803d3edf9
MD5 d5539c4d04be9b5cd157e3f651eef15e
BLAKE2b-256 dca64ccf1dd68eebe34979c34edb5d38ff3ba3d69a2091c2e8add45236d01e61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ff07e26418c12fc26b28acb50a889b74b9a15c5f4d8f805bc378e5077e29aad4
MD5 015ddc1a0a47995054478f830e1e6eb1
BLAKE2b-256 915b6085055e64ca784ea5389664d979b7663894b26e0ea22443fb3b58ba188f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 a0f563dd5b73658130d7ad7604edc5a8d5dce2c010cd744e445e58474439c6c2
MD5 3ec3329aba91eac08217a411b0c0a37d
BLAKE2b-256 7382919ae89d66304a4c5e8e04cde6a920bd6cfed2e0cd1e3786663cac5524ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0bb46a8bb9346b900832377ba294f1c6fec73e4aada407c4419da514611702b4
MD5 33a2744ce770e861df6a715d50730918
BLAKE2b-256 793c3c765c0ac67da3095c8c1f6c85282d6268e2ec5a6ac8037f1a24799e369f

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16-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-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 ffcdebb2edda6694f5f32e1e0b8f864a34c545830dee0693da72e8d76470459d
MD5 718331773868534c55f02d3946d6dfa5
BLAKE2b-256 9eb013fdce1911382816d8764adb3d5862f08f09489c66231228c20993752b84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 354710aa6d44e9cbad485115a919150efbec4644a0ce8308a21042895bc36633
MD5 248ccb4ff6a975e409075eca1b26a751
BLAKE2b-256 26b168d63febe4965893577710346d285999c063ad001bb17f919f2ccead5254

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3e70b6c15a237db28bc5a9685d03c8f881f68d2dae2cd810cb6049228a27fd26
MD5 9590d21ab2faf4645286404714a18cfe
BLAKE2b-256 f54e97464cfd3416fd5490b59744df37f8601719f95bb1c28c1c56d0181f9d71

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