tasker-sequential
v1.0.0
Published
Deployment-agnostic task execution engine with automatic suspend/resume
Downloads
21
Readme
Gmail Search Task Runner
A Gmail search task runner built on Supabase Edge Functions with automatic suspend/resume execution for infinite length tasks.
Overview
This system implements a sophisticated task execution engine that can handle long-running Gmail searches across multiple Google Workspace domains without timeouts or memory issues. The core innovation is an automatic suspend/resume mechanism that breaks up work call by call, enabling infinite length task execution.
Key Features
- Automatic Suspend/Resume: Tasks automatically suspend on external calls and resume with results
- HTTP-Based Stack Processing: No polling - pure HTTP chain reaction for task orchestration
- Infinite Length Tasks: Break up work call by call to handle unlimited task complexity
- Real Testing Conditions: No mocks or simulations - only real working conditions
- Causality Preservation: Parent tasks receive child results before making subsequent calls
- Concurrent Gmail Search: Process 98+ users across multiple domains automatically
Architecture
Core Components
Task Execution Engine
supabase/functions/tasks/- Main task execution service that submits tasks and triggers stack processingsupabase/functions/deno-executor/- Deno runtime with automatic suspend/resume for external callssupabase/functions/simple-stack-processor/- Sequential FIFO processor that chains HTTP calls (no polling)
Service Wrappers
supabase/functions/wrappedgapi/- Google API integration with service account authenticationsupabase/functions/wrappedkeystore/- Key-value store for credentials (Google API keys, admin emails)supabase/functions/wrappedsupabase/- Database operations proxy
Task Code
taskcode/endpoints/comprehensive-gmail-search.js- Main Gmail search task implementationcomprehensive-gmail-search-cli.js- CLI tool for testing the Gmail search
Suspension and Resume Mechanism
The core innovation is the automatic suspend/resume capability:
- External Call Detection:
__callHostTool__(serviceName, methodPath, args)triggers suspension - Child Stack Run Creation: External calls create child stack runs for API operations
- Parent Suspension: Parent tasks marked
suspended_waiting_childuntil children complete - Task Suspension:
TASK_SUSPENDEDerror immediately stops task execution - Child Processing: simple-stack-processor handles external API calls
- Automatic Resume: Child completion triggers parent resume with results via HTTP chain
- Causality Preservation: Parents receive child results before making subsequent calls
This enables infinite length tasks by breaking up work call by call without timeouts or memory issues.
Getting Started
Prerequisites
- Node.js 18+
- Supabase CLI
- Google Workspace admin account with API access
Installation
- Clone the repository
git clone <repository-url>
cd tasker- Install dependencies
npm install- Start Supabase
supabase start
npm run serve- Configure Google API credentials
# Add your Google service account key and admin email to keystore
# See CLAUDE.md for detailed setup instructions- Publish the Gmail search task
npm run publish:taskQuick Test
Run a simple Gmail search test:
npm run test:gmail-simpleOr use the CLI directly:
node comprehensive-gmail-search-cli.js --maxUsersPerDomain 2 --maxResultsPerUser 1Usage
Running Gmail Searches
Simple Test (2 users, 1 result each):
npm run test:gmail-simpleFull Test (98 users, 300 results each):
npm run test:gmailCustom Search:
node comprehensive-gmail-search-cli.js \
--gmailSearchQuery "subject:important" \
--maxUsersPerDomain 10 \
--maxResultsPerUser 50Development Commands
Start Infrastructure:
supabase start # Start local Supabase
npm run serve # Start edge functions serverTask Publishing:
npm run publish:task # Publish comprehensive Gmail search task to databaseDebugging:
npm run debug:db # Check database state
npm run debug:logs # View recent logs
npm run debug:clear # Clear database tablesHow It Works
Task Execution Flow
- Submission: CLI calls
/functions/v1/tasks/execute - Processing: Task service creates task_run and triggers simple-stack-processor
- Execution: deno-executor runs task code with
__callHostTool__for external calls - Suspension: External calls throw
TASK_SUSPENDEDerror with suspension data - Child Creation: deno-executor creates child stack_run and marks parent
suspended_waiting_child - Child Processing: simple-stack-processor processes child stack_run for external API call
- Resume: Child completion triggers parent resume with results via HTTP chain
- Continuation: Parent task continues execution with child results
- Chaining: Process repeats for each external call, maintaining causality
Database Schema
Core Tables:
task_functions- Stores published task code and metadatatask_runs- Tracks task execution instances with suspension statestack_runs- Individual operation calls in task execution chainkeystore- Credentials storage (Google API keys, admin emails)
Important: Never reset the database. Clear tables individually:
DELETE FROM stack_runs WHERE id > 0;
DELETE FROM task_runs WHERE id > 0;
# Keep task_functions and keystore intactDevelopment Principles
Performance Requirements:
- Never wait more than 5 seconds for any step to run
- Use concurrently for running server and client together
- Client waits for server before running
Testing Principles:
- Never use mocks or fake data - only test with real working conditions
- Use MCP REPL tool instead of curl for debugging Deno functions
- Always check CLI output properly
Stack Processing Rules:
- Stack processor uses HTTP chaining, not polling
- Each process starts the next and exits immediately (fire-and-forget)
- Sequential processing with database locks
- External calls via
__callHostTool__create child stack runs and suspend parent - Parent tasks marked
suspended_waiting_childuntil children complete - Suspension mechanism preserves causality
Documentation
CLAUDE.md- Comprehensive development guide and architecture documentationdev-tools/README.md- Development tools and debugging guide- See function-specific documentation in each
supabase/functions/directory
