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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13Windows x86

stitchflow_local_agent-0.3.17.1-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.17.1-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.17.1-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.1-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.1-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

stitchflow_local_agent-0.3.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.17.1-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.17.1-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.1-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.1-cp311-cp311-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

stitchflow_local_agent-0.3.17.1-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.17.1-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.17.1-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.1-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.17.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 29ef7fc14c2939e4ed6029af34ed03187e805625e5f25bfbcc8964592a41fcc1
MD5 0ceae177b344f411bcfea4cf529fe64a
BLAKE2b-256 67e4f2e26709133d5f6f2a37695ed45f8e99f07b1f597d75731897f508e6a028

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 886e90028721b09bf3493233465aa727b48c5fa3f58fedff85af69c5df3c6b15
MD5 18030ae18379463dee977195ac262a7f
BLAKE2b-256 d87a612e83375f44ac5560937b44b97949ccf708e98bca4132bab17f9104d0de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ad24ee7c3ae2fd646f286a22cb53cba86b0771431ec689ef08e1a55c9349904d
MD5 2bef8cd5ade95b11caba40f6875142f2
BLAKE2b-256 5a48c292976b97d2c7e9891b8e9233a3d807457b8c7af1625815d008dad27d68

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.17.1-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.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 33e2bf270a7766b1ad57362103d6a9b59df489fbf11bbb756c802ca2860e1c09
MD5 c04dcf3fe7d22e65f8f2dd4a9bfdbb53
BLAKE2b-256 d45ace6f7db6af6cd55c40a1e3ad06a517c5d71f1e88837b3d2f9fd91f843bf3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 781170edcdcfe214ed317fc8f8e9cb761c0625056de656e97aeb3d190d6d74e1
MD5 3493d9d4aa48f527f07bb86808c0c27d
BLAKE2b-256 ca795fc65442fa5805300c5199f7f6603cff2ac6ca86bee9f8d0f1336bc11aa4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4c753f028b3f87d890be2459543dc4a32a0695f0b423186532b4785e49de0d5f
MD5 3ea1fcaf98b5d860a80c5a60880ba3f9
BLAKE2b-256 7ff9456d20cfe9fe7f598069cfee5e731695ca7aa0fd71cfdf1f673710aef236

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 47fdd8d09fd25aca606ec5a67e9344ef6714590ca4ba62fba8135f7d2b903fa3
MD5 4a19c68f4949f875c1d5aa56265715e9
BLAKE2b-256 f5e1a473e0aff357f1f2dcf62183089d306c3c3fef7d4866cc84d5fb8ca60eaf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 f352f206ed4a709ea167afbac09d912483abfb3fbfad93cf188e6e2034b16d52
MD5 4da91997594e01e772d35768b56d4a83
BLAKE2b-256 ffefb161dae5b4d82a243add196a0ea1d6dc345d5295687cf4c88f98fd7dafdc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dfcbb2361d38a9a91bac949bd2f4f3a17c3b2091f2f8c770a584facc98a732e0
MD5 ab9f86d8899942a42dfe580b5fc514c0
BLAKE2b-256 b7ed03d59986910e98dd6e67fcb35813cf9258b671776ded2f6a65701f4ca8d9

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.17.1-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.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 007c92e3b1dac4de9573f29d31a458f70b08ac4c882dfff3a77906ab4726be46
MD5 e021328568be3800064987715ffc2fa4
BLAKE2b-256 9e9e5e24cb97e86dfa2e2039f58117a96e924dd4f596f89bb504567341453b75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 460311b59a02a95ec89645d7c8a358a7612442d581f9e029856206a0a73a53cc
MD5 29c2ac46ab22edb64b2284c2745091a7
BLAKE2b-256 e4488275ae37e5abe71713513e62989df3d1b79555fe289868fd1ec6ef764334

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f3c2f7816938586f30818e3dde0b9301596c3665713083a03adc2ee6eea79806
MD5 01fdcdf49559f28618ad661b7dbab4ce
BLAKE2b-256 124c6f7757033cfc20f7cda5fc7d355fb3b20e610734db88e82405cc494fbebe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b43454c6da00d739514aea92018cf7f231154338bd71639c266a30a03d39e3e7
MD5 76cbc0210fe748577ba101fe9f0df4d7
BLAKE2b-256 a36778f364f735800b4bbb4829e300b87fb2c3177c5fb8b371e6343e014e4f4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 93989ef6b0890a59459b729c597ab1a8916c2c486ba36f86082b49a7a768f096
MD5 f7345325961327f3eb71068a67e5a20e
BLAKE2b-256 ff7f46a2fa19a5d2d0ca5e550709ae55f147481735e6831938e5cc1683d25a43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 09fabf5c76590f3c4cec649be92e8e278f3eb5085304b2856b43e3a290402854
MD5 9d589c73ed21135a805baef10c3458d8
BLAKE2b-256 c26fba74000ad073a3ac4c39dbd9a215e119fbc787c8fa5681475553e7efba44

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.17.1-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.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7e0ea014d15f06a6f822487a2ac37f32a4edfc6bfa5b49ed248f5d2d196d570b
MD5 d81dde06894d396412d96a0adc683241
BLAKE2b-256 8a3c2443bdf84261b57f65b3c20b5ad44f4bb80b73177f8ce34eecc019e86ace

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 55295db972da58274d860430b222b91db99ea1dae0f87bb7e6f33169e4cf5cd2
MD5 6e384e045af834e5fbfd87fc5eec96ba
BLAKE2b-256 08154a9877a755093562af95f135dbbcc249d8534fa4c9e8379aa587851c4239

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 466cefad83034fd20122080b62f7a69b91d31d179996ef29a47281339f964779
MD5 dd3817a93ed007091f49ea6de47a6bcf
BLAKE2b-256 2395fa9c7bbb7a97b831d0566b2d9e6ba3e9496c4c0ca9d1fb5a7e7a98b56f0d

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