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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13Windows x86

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 933a10be21efeb95792975005223892ad91fd3e4ad6e17e4716a2fb1b077650f
MD5 6762ff6584ff05df37dea5c8a91dbb82
BLAKE2b-256 a0ee54fdbf263789f2f55dd814136148ff2435f10c499bdbce2d9230b39880e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 e7f670ca18bc2c39850eac48c9baa06324fb4d07c8e4622c3a1544b949b8953c
MD5 0577dd88b30ea5442ffbb0bc7c951cc6
BLAKE2b-256 6150e4e38328b882ab6149466bfd09a43465a491777b3ce66cf456bfa57786c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e1ffd68df57cfa1160a0491233d2887217c43dc7daaa0550d9f1c7ad8d5092f7
MD5 422c3ff36effbdcc5ac8d91ffe32cedf
BLAKE2b-256 00d1be6de9b5b2c12a883629c2f03dd493138e060b22bbe92c66e445b3015161

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.2-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.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 84f416f179e4ce14b1a5c75526d7596aa4fb8abff735ececed5f537f8c0836bb
MD5 bd0bda2fb2e8753d12244c52396a124d
BLAKE2b-256 a013c1084b2913515029f69b0c3f118cc1ffb829f657c17160b42c8502a6b11a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 64168231f0c8872ca73cd6d2643cbef5071c7def9d3b9ea984a41dc2f187ca5d
MD5 0d6d8703fe312ec0cf0702902d9e06d8
BLAKE2b-256 7bb13fe77c81b53114d206a83742559a06d6ce03835fac265d932652a3ea1570

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b1e172b578024bb72ec1b1a3d3b515bfc2223349e397219f669b69c99ee9d26d
MD5 3390086322d6c19758b79660b81adc53
BLAKE2b-256 3e1b83c9b8adebaea692459fbf7d312a8ace4218fb70364d5a66f542ceb4945e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 20c6fdd5b6d543810c9a41cd4438429783775f4e706c3b9b4b61b090afc6df80
MD5 d3f05eed71a267d212fc18be9e2dde71
BLAKE2b-256 dbf48e810e749b1b037eee5876e69f013aea29c996d33e94db94ebad3c9fc4b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 e774f68ef294122538315f0f906592d6afffe3c9c13b37e6d54cd07601a760ed
MD5 657ba635fb2592a4cb346623fc455112
BLAKE2b-256 05c80e7527e475ac8b05eaa60d2c424d4d445027afcdeee28704f34ef036f8c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6b7d95ea21e5681cc5fd29d18da7efe643a63facbd9b076ba78f548db2cb9c87
MD5 77f2204a80040ccfe1e24cf6b903f2d9
BLAKE2b-256 5783935f607b80a7ba9ef548d0bf09172940eca1a194330b16362b650b5d8f80

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.2-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.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 9f5ffbb39987da87bdb5fab88c3f4bfbad47d4171905fbd5eef667adb05c720a
MD5 e1a0b052bd4e284dea15b76748ef9dab
BLAKE2b-256 1f507e1cc36d47c66133ea1406f0cafc352febc03edcaaaf84c3efa3354e995d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4e524ace1fe1205e87f3919c6b8ff634ba2f96dc6004e3114bb032de19d8217b
MD5 8d2332103acb6112768e5e647b540cd6
BLAKE2b-256 bebe1ce0b9f5bc611d94acefc73726b37b44ce0eee4fbc862cb0b5e6f54d2b27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 65be622a57e66756a14cc5e14962d11a7eccc21b69b1b238be250b56bab560b2
MD5 dd4cd5c32990648b03d1bcbf31d9fcbc
BLAKE2b-256 64ded29d3517df53202c9182948c775061d40c7cfe3d524a3c540a9aefdeecc9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9c54e6d7e89fd39a029612df0a8800b0d56317d20c658068b288168e28164b85
MD5 bd8cd1098a5f6b035f63e54753503072
BLAKE2b-256 d212dded0d67077fb0a78a811c26936353477346b76a2a28c04ef9d91df49f27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 2950cdf517b8c87aa39eb5853f5882870c1ac6777c195f2ded3f4cd003117798
MD5 c84e55ef22b9e649dbb6fc72bca7668a
BLAKE2b-256 e8a9cece302488e9b76f578becd31029c810bb4bdbb2f26add8ff49a7542206c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 688450f1d815ecd6f75777a1e785628128d20d0f95f7844774b8c543bd3c6c05
MD5 8feef352136befb452f7dcea78706cd3
BLAKE2b-256 bbcc2a2ff715f19162390eef24711271116033c1150c4a099b5432a26ac1a3e4

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.16.2-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.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 d3d4c028ec60f6fbf8617f109da8ab2383d4ceca0179fd8567112d5369dec2c1
MD5 bcffadde2029ab25c4d3a13b7f68bd6a
BLAKE2b-256 08953c1648f6a354a824d598f14883bd568fee717a9e39e4171513f4b8216c39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5019ed0ed74d24ea6e3822a60d6fed58fee52bbefabf07ccbcaa2d4e417e09e7
MD5 de3b3c5899ef85d079e4ccd0a463303d
BLAKE2b-256 d53024c3725ce794668baf3f4bc57d179f6c7b8b4fc645aacdcdaf0c0b894ae6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.16.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 449c7597e21b2a751fa8453336fdf396b8404a0b22643dd3b2455e1803c3def6
MD5 1cfa451dd61f8f3028da6de3544b587d
BLAKE2b-256 ec3a1c8d5490c24c6a55880eed33ed21b9773aa0ae2c924885163ff5eac77706

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