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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13Windows x86

stitchflow_local_agent-0.3.17.9-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.9-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (10.9 MB view details)

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

stitchflow_local_agent-0.3.17.9-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.9-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.9-cp312-cp312-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

stitchflow_local_agent-0.3.17.9-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.9-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.9-cp312-cp312-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

stitchflow_local_agent-0.3.17.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

stitchflow_local_agent-0.3.17.9-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (11.4 MB view details)

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

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a96ffd043b654ecf490311970c17b65ebc0cc6b442d5de3297f199f53f43768a
MD5 11c0690f4dc7eec653983dd63aa1c243
BLAKE2b-256 6a7aaddd89e8a16d0926b308f156a44877f2dd5e7daafc0660142036622fc38c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 583ba248592ef50f84339ec355e9e1fbb10e9e2fc7db66f06a6da387b1f295f5
MD5 b633e0fdfe8a2f30bd7d3121ef2f1793
BLAKE2b-256 9b04dbf94f890e4cfdde775451aa4334d6c1531765a45e8e725f99d027ca5d84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd93995476eb28fa31db7611442dba7e7568635a143e7f3b5ade0356e66bd4c2
MD5 2f6a43287212e984c9a3f67760e6a3e1
BLAKE2b-256 a58997f9899f341ab86b507750324e888b97d0328c81f7b44d9973e4dd1a8bd7

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.17.9-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.9-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 692cc55d58eb403498050f6648943085c5ac32ffc8075d6e528f678731235f2b
MD5 d9a309219ee60add056678911e825174
BLAKE2b-256 81b81bb49567222faa49a54680bc0a25337293ecf94c3e6f9a2fa47b9e823971

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c080b679c33f7b2ce5052ba75383e6bb529fb132bdcb8c7b26e5ac4bc4c0254e
MD5 424285e937caead0a1084ea2dc91d093
BLAKE2b-256 3750a396a4bdc3c5ccebea2aa014bedec6762a08c9026a0e8db2c5e4fb2d496d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 46c5675a615d861ac873e2495a38bcb2845e6bc1c0276d821daed278820325a6
MD5 972b8d44bf4ca7f60bfe902fd44fff8e
BLAKE2b-256 91c8b0c6576bc16038422e09c50efb6f7baab12f0f9ee6fde86dd5f825cc00c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3d78535b68208f847a5820beee3a69dc97d36e46233d7c30cc598305bca14651
MD5 ff8ff32c3453c794f167906e6f13ab70
BLAKE2b-256 29a315efd9c91e3c8a14028a3d98d4b5982f8e2301f51571e55833cd05da1589

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 da4b6fb58abb1ec3fc221f59344ad83d6c4e36e14fc26be0b9038b99f479bef1
MD5 05f26ef9349952869913b1e70170372b
BLAKE2b-256 1ce9831af08ea7bc9e30591facc36c003c919c128aaf1b76932de832926e63df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e311b9d0c3102a692b9079471352fe9dcb416c8740dd99ef1615c78f3572d345
MD5 3b3202744606d60c387a5c7660358984
BLAKE2b-256 bcbe7417c7a4196631183f36b15397d5f5bb42dcfc87df10347bb8fb512b8c5a

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.17.9-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.9-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 f22b94a458fc771d08942130bae8fde5983b2fa6eb2753b61b15f35f199d7e54
MD5 bc915c36334d43753478d8a972704f1a
BLAKE2b-256 c209d0e663acdc6b4e8d70de32a235fc136811148f6e2af670e23c388315a234

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 300c009e5883d6e2c92f7a2320741f7656234fa9108b0869b283f21520a705dd
MD5 90a662b671fdee6a96a0343f6913f467
BLAKE2b-256 dcc54816f95691977b377693abed59b9f6e682bce9020c78c71eee8cf65bf417

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4f607af53c852772e67e8645f103afc8d119e7a57a4ff1f1c268dee16063e0cd
MD5 044a8e698177c4cc1101401f9dea996e
BLAKE2b-256 3500137ccd38f6dee6602aa8d5d254d9f8cd3ab629bb57a096e04b42be0e8807

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 289c77ebc322ab58daaf1eb922f0d2864e6cc9e2e80749108498b71690c8db03
MD5 a9b6247553585d0deb9b9227bd8b7d84
BLAKE2b-256 47216aaafae2cb178c43e5a9754e764b6e1da137731ab34ed0c031c0e631d9bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 89aeab3879c4c59977992226d3ac08661016832c87ea3a84fc577bd79550b3a6
MD5 b5415007f17a369395bc1e2612a4e4ba
BLAKE2b-256 7e0c2f8e20897c10eb69ddb0e517327b116a45a203efbec408a292d1bf209fae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 66244e0f07e4746355fac2f7274561b7fa656f49690503a4914e55249712f48e
MD5 101aa76b59c54a4de2d02eabc186ff65
BLAKE2b-256 74fc3da447718a455208b2d6b6b08cda74105d27c7415942662fa5e1a4fd46e9

See more details on using hashes here.

File details

Details for the file stitchflow_local_agent-0.3.17.9-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.9-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 526c533c067d253cbe414215f3494e2a50f765df7452d2aba902047cedbf75ba
MD5 d67b8aa9e47a356475283d923889c690
BLAKE2b-256 9e42a8aafeb61f2e04705af6bb81172f0114930bdffacc8cda3870930daf585f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e22329f59d44bbbf1ebb8b004b6f34d539160ec1b997fce1144f7ec21ce057f1
MD5 e14e81b116522094ea62f37c19fdff06
BLAKE2b-256 58248c9fd41c437bc05002fc333a89e54a2d4c108137d1d107d8c394fc6473cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stitchflow_local_agent-0.3.17.9-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b81504782ff26f9ae78e85f23d22a4f4d3adcd7fea59018d5cd692b11ecfc47b
MD5 fcf7a22357f79b730eeebc87bf1b00ef
BLAKE2b-256 4daa8c0db763aff6063fb7e446b9d486d5cae3ed5fdae8fc10485dfbd362ef75

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