Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ GitHub Actions installs the single root lockfile and runs `npm run check` on eve

## REST API and OAuth

Read the complete, implementation-accurate API and MCP documentation at [docs.factorize.sh](https://docs.factorize.sh), including the checked-in [OpenAPI definition](packages/docs/openapi.yaml).

API clients use OAuth 2.1 authorization code flow with PKCE S256 or the OAuth 2.0 Device Authorization Grant for headless environments. Factorize publishes authorization-server and protected-resource discovery metadata, supports Client ID Metadata Documents, and retains dynamic client registration at `/oauth/register` for older clients. Access tokens last one hour and may be refreshed for up to 30 days; RFC 7009 revocation is advertised by discovery metadata.

Available scopes are `flows:read`, `flows:write`, `runs:read`, and `runs:write`. The resource owner must sign in through the normal Linear-backed Factorize session and explicitly approve the requested scopes. Factorize rechecks owner membership and session version on every service call.
Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/app/src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const landingPage = (viewer: Viewer) => shell("Factorize: Software Factor
<p class="mx-auto mt-6 max-w-2xl text-lg leading-8 text-slate-600 dark:text-slate-400">Create a multiplayer software factory with <a href="https://linear.app/" target="_blank" rel="noreferrer" class="underline decoration-slate-400/60 underline-offset-4 transition hover:text-slate-700 dark:decoration-slate-500/60 dark:hover:text-slate-200">Linear</a>, <a href="https://exe.dev/" target="_blank" rel="noreferrer" class="underline decoration-slate-400/60 underline-offset-4 transition hover:text-slate-700 dark:decoration-slate-500/60 dark:hover:text-slate-200">Exe.dev</a> and <a href="https://herdr.dev/" target="_blank" rel="noreferrer" class="underline decoration-slate-400/60 underline-offset-4 transition hover:text-slate-700 dark:decoration-slate-500/60 dark:hover:text-slate-200">Herdr</a></p>
<div class="mt-9 flex flex-wrap justify-center gap-3">
<a href="/jobs/new" class="inline-flex rounded-xl bg-slate-950 px-6 py-3.5 text-sm font-semibold text-white shadow-lg transition hover:bg-slate-800 dark:bg-white dark:text-slate-950 dark:hover:bg-slate-200">Create Job</a>
<a href="https://docs.factorize.sh" target="_blank" rel="noreferrer" class="inline-flex rounded-xl border border-stone-300 bg-white px-6 py-3.5 text-sm font-semibold text-slate-950 shadow-sm transition hover:bg-stone-100 dark:border-slate-700 dark:bg-slate-900 dark:text-white dark:hover:bg-slate-800">Read the docs</a>
<a href="https://github.com/GenerationSoftware/factorize" target="_blank" rel="noreferrer" class="inline-flex items-center gap-2 rounded-xl border border-stone-300 bg-white px-6 py-3.5 text-sm font-semibold text-slate-950 shadow-sm transition hover:bg-stone-100 dark:border-slate-700 dark:bg-slate-900 dark:text-white dark:hover:bg-slate-800"><svg aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" class="h-5 w-5"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82A7.66 7.66 0 0 1 8 4.73c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/></svg>Host it Yourself</a>
</div>
<section class="mx-auto mt-24 max-w-3xl text-left" aria-labelledby="how-it-works-title">
Expand Down
5 changes: 5 additions & 0 deletions packages/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Factorize documentation

This is an independently previewable and publishable [Mintlify](https://mintlify.com) package. Install the Mintlify CLI, run `npm run dev --workspace=factorize-docs`, and open the local URL. Run `npm run validate --workspace=factorize-docs` in CI; it checks the route inventory against the Worker and verifies the LLM exports. Publish with `npm run deploy --workspace=factorize-docs` from a configured Mintlify project.

`openapi.yaml`, `llms.txt`, and `llms-full.txt` are checked-in artifacts so API clients and LLMs can consume the contract without rendering the site.
27 changes: 27 additions & 0 deletions packages/docs/api/authentication.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Authentication and scopes
description: OAuth 2.1, device authorization, and access-token rules.
---

Protected API and MCP requests use `Authorization: Bearer <token>`. Browser users may also use their signed Factorize session cookie. Access is tenant-bound; owner membership and session version are rechecked on every service call.

## Scopes

| Scope | Allows |
| --- | --- |
| `flows:read` | Jobs, targets, connections, integrations, trigger availability |
| `flows:write` | Create/update/delete/enable/disable jobs; test handlers |
| `runs:read` | List/get runs and webhook activity |
| `runs:write` | Invoke and stop runs |

Authorization-code clients must use PKCE S256. Implicit and plain PKCE are disabled. Access tokens last 1 hour; refresh tokens can last 30 days. RFC 7009 revocation is advertised by discovery.

## Device flow

1. Register a public client at `POST /oauth/register` with `grant_types` containing `urn:ietf:params:oauth:grant-type:device_code` and `token_endpoint_auth_method: none`.
2. POST form data to `/oauth/device_authorization` with `client_id`, `scope`, and optional `resource`.
3. Send the user to `/device?user_code=...` and poll `/oauth/token` with the device code.

Device codes expire after 10 minutes and polling is rate limited. The token endpoint returns `authorization_pending`, `slow_down`, `access_denied`, or `expired_token` as appropriate.

Never send Linear, exe.dev, or connection credentials to an API client. Tokens are revocable and responses omit stored secrets.
11 changes: 11 additions & 0 deletions packages/docs/api/discovery.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: OAuth discovery
description: Endpoints and metadata for OAuth-aware clients.
---

At the deployment origin, clients can retrieve:

* `/.well-known/oauth-authorization-server` — issuer, authorization, token, registration, revocation, and device endpoints plus supported grants/scopes.
* `/.well-known/oauth-protected-resource` — resource `APP_ORIGIN/mcp`, authorization server, header bearer authentication, and supported scopes.

The authorization endpoint is `/authorize`, token endpoint `/oauth/token`, dynamic registration endpoint `/oauth/register`, and device endpoint `/oauth/device_authorization`. Client ID Metadata Documents are enabled. MCP clients should use `APP_ORIGIN/mcp`; they can discover OAuth automatically and complete browser PKCE consent.
12 changes: 12 additions & 0 deletions packages/docs/api/openapi.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: OpenAPI definition
description: Download the machine-readable Factorize REST contract.
---

The checked-in definition is [`openapi.yaml`](https://github.com/GenerationSoftware/factorize/blob/main/packages/docs/openapi.yaml). It covers every `/api/v1` operation, bearer security, scopes, request schemas, pagination, and the common error envelope.

```bash
curl -O https://raw.githubusercontent.com/GenerationSoftware/factorize/main/packages/docs/openapi.yaml
```

Run `npm run validate --workspace=factorize-docs` before publishing. The validator checks that the route inventory in the Worker and the OpenAPI paths remain synchronized.
39 changes: 39 additions & 0 deletions packages/docs/api/reference.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: REST API reference
description: Complete implementation-accurate operation inventory.
---

All paths are relative to `APP_ORIGIN` and require a bearer token or browser owner session. Errors use `{ "error": { "code": "...", "message": "..." } }`; malformed JSON/schema input returns `400 invalid_request`, missing resources `404 not_found`, invalid/revoked tokens `401 invalid_token`, and missing scopes `403 insufficient_scope`.

`GET /api/health` is the unauthenticated liveness check and returns `{ "ok": true }`.

## Discovery and read operations

| Method | Path | Scope | Result |
| --- | --- | --- | --- |
| GET | `/api/v1/exe-connections` | flows:read | Safe exe connection metadata |
| GET | `/api/v1/github-installations` | flows:read | GitHub App installations |
| GET | `/api/v1/execution-targets` | flows:read | Non-secret target metadata/capabilities |
| GET | `/api/v1/job-trigger-availability` | flows:read | Currently available trigger kinds |
| GET | `/api/v1/integrations/cloudflare-tail` | flows:read | Tail integrations and reference counts |
| GET | `/api/v1/jobs` | flows:read | Jobs with `currentRuns`, `maxConcurrency`, triggers |
| GET | `/api/v1/jobs/{jobId}` | flows:read | One job |
| GET | `/api/v1/jobs/{jobId}/events?limit=50` | runs:read | Webhook activity; limit 1–100 |
| GET | `/api/v1/runs/{runId}` | runs:read | Full prompt, context, invocation, execution, output, activity |

## Writes and runs

| Method | Path | Scope | Notes |
| --- | --- | --- | --- |
| POST | `/api/v1/jobs` | flows:write | Create; returns `201` |
| PUT | `/api/v1/jobs/{jobId}` | flows:write | Replace configuration |
| DELETE | `/api/v1/jobs/{jobId}` | flows:write | Deletes job and queued invocation history |
| POST | `/api/v1/jobs/{jobId}/enable` | flows:write | Enable |
| POST | `/api/v1/jobs/{jobId}/disable` | flows:write | Disable |
| POST | `/api/v1/job-handlers/test` | flows:write | Isolated synchronous test; no run |
| POST | `/api/v1/jobs/{jobId}/invocations` | runs:write | Manual invocation; returns `202` |
| GET | `/api/v1/runs?jobId=&state=&contextQuery=&limit=&cursor=` | runs:read | `{items,nextCursor}`; limit 1–100 |
| POST | `/api/v1/runs/{runId}/stop` | runs:write | Stop an active run |
| POST | `/api/v1/schedules/preview` | flows:read | `{nextRunAt}` for `{cron,timezone}` |

Job creation requires `name` (1–120), `slug` (lowercase, up to 30), `promptTemplate` (1–50,000), `executionTargetId`, and optional `model`, `effort`, `concurrencyLimit`, and `triggers`. Manual invocation accepts `prompt` (default empty) and an optional unique `idempotencyKey` (1–200; never prefix it with reserved `manual:`). Run states are `queued`, `starting`, `running`, `recovering`, `done`, `blocked`, `failed`, and `ignored`.
12 changes: 12 additions & 0 deletions packages/docs/concepts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Jobs, triggers, and runs
description: The durable execution model and prompt contract.
---

A Job contains a prompt template, execution target, model/effort options, concurrency limit (1–50), and up to 50 triggers. Every job has a server-generated manual trigger. A Run is a queued or executing instance. Automatic webhook, schedule, and lifecycle signals coalesce; manual invocations never coalesce.

Templates are Mustache and render only against the firing trigger's stable slug, such as `{{trigger-1.issue.title}}`. Missing paths become empty strings. Run inspection returns the complete persisted `context`, rendered `prompt`, `invocation.trigger_id`, execution metadata, output, and activity.

Trigger kinds are `manual`, `schedule`, `webhook`, and `jobLifecycle`. Webhooks support Linear, ClickUp, GitHub, and Cloudflare Tail. A webhook handler is one synchronous `function handler(webhook)` declaration: `false` rejects, `true` keeps the default payload, and a JSON object replaces it. It runs after authentication/scoping in an isolated Worker with no network or bindings.

See the repository's [trigger context contract](https://github.com/GenerationSoftware/factorize/blob/main/docs/job-trigger-context.md) for the reflection paths exposed with every trigger.
16 changes: 16 additions & 0 deletions packages/docs/docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://mintlify.com/docs.json",
"name": "Factorize",
"theme": "mint",
"colors": { "primary": "#e5a400", "light": "#fff8e1", "dark": "#17130a" },
"favicon": "/favicon.ico",
"logo": { "light": "/logo-light.svg", "dark": "/logo-dark.svg" },
"navigation": {
"groups": [
{ "group": "Start", "pages": ["index", "quickstart", "concepts"] },
{ "group": "REST API", "pages": ["api/authentication", "api/discovery", "api/openapi", "api/reference"] },
{ "group": "MCP", "pages": ["mcp/overview", "mcp/tools"] },
{ "group": "Integrations", "pages": ["integrations/triggers", "integrations/oauth"] }
]
}
}
13 changes: 13 additions & 0 deletions packages/docs/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Factorize documentation
description: Automate coding-agent jobs from Linear, GitHub, ClickUp, schedules, and MCP.
---

Factorize turns authenticated provider events into jobs on your own exe.dev VM. Jobs have explicit triggers, concurrency limits, durable run history, and a scoped REST/MCP API.

<CardGroup cols={2}>
<Card title="Get started" icon="rocket" href="/quickstart">Create and invoke your first job</Card>
<Card title="API reference" icon="brackets-curly" href="/api/reference">Every public REST operation</Card>
</CardGroup>

The public documentation origin is `https://docs.factorize.sh`; replace `https://app.factorize.sh` in examples with your deployment origin when self-hosting.
8 changes: 8 additions & 0 deletions packages/docs/integrations/oauth.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Provider OAuth and boundaries
description: Configure Linear and optional ClickUp connections.
---

Linear is the required dashboard identity and webhook provider. Register `/auth/linear/callback`, configure issue and issue-label webhooks at `/webhooks/linear`, and store the client credentials and signing secret as Worker secrets. ClickUp is optional: register `/auth/clickup/callback`; connecting it automatically registers its task webhook. GitHub uses an installed GitHub App, while exe.dev and Cloudflare Tail connections are configured in Settings.

Provider credentials are encrypted at rest in the tenant Durable Object. Public REST/MCP APIs expose only safe metadata. Owner membership and session version are enforced at the shared service boundary.
10 changes: 10 additions & 0 deletions packages/docs/integrations/triggers.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Trigger configuration
description: Configure schedules, provider webhooks, and lifecycle triggers.
---

Schedule config is `{cron, timezone}`. Webhook config supports `linear` (`projectId`, non-empty `matchRules`), `clickup` (`listId`, rules), `github` (`installationId`, `repositoryId`, and rules or event/action), and `cloudflareTail` (`integrationId`). Match rule types are `owner`, `creator`, `status`, `label`, and `assignee`, each with a `targetId`.

Lifecycle config is `{sourceJobIds, states}`, where states are `succeeded`, `failed`, or `stopped`. Triggers have stable server-generated slugs (`trigger-1`, `trigger-2`, …); use them in Mustache templates. Disabled triggers do not fire.

Linear webhooks require a fresh HMAC timestamp/signature and configured OAuth subscription. ClickUp uses its OAuth connection and signed webhook. GitHub uses the connected App installation. Cloudflare Tail sends sanitized, signed delivery data to the generated destination.
19 changes: 19 additions & 0 deletions packages/docs/llms-full.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Factorize full documentation

Factorize creates durable coding-agent Jobs on a user's exe.dev VM. A Job has a prompt template, execution target, concurrency limit, and stable-slugged manual, schedule, webhook, or lifecycle triggers. Runs are queued, scoped to a tenant, and inspectable through REST or MCP.

## Authentication

Use OAuth 2.1 authorization code with PKCE S256 or RFC 8628 device authorization. Scopes are flows:read, flows:write, runs:read, and runs:write. Access tokens last one hour; refresh tokens last up to 30 days. Owner membership, session version, tenant binding, and revocation are checked on service calls.

## REST

The API is rooted at `/api/v1`. Read operations list connections, installations, targets, trigger availability, Tail integrations, jobs, job events, and runs. Write operations create/replace/delete/enable/disable jobs, test handlers, invoke jobs, stop runs, and preview schedules. Run lists return `{items,nextCursor}` and accept `jobId`, `state`, `contextQuery`, `limit` (1–100), and `cursor`.

## MCP

Connect to `APP_ORIGIN/mcp` using Streamable HTTP. Tools mirror the REST surface: connection/target discovery, job CRUD and enablement, manual invocation, run inspection/filtering/stopping, webhook activity, and isolated handler testing. Tool output is structured JSON plus text; secrets are omitted.

## Triggers

Webhooks support Linear, ClickUp, GitHub, and Cloudflare Tail. Schedule config is `{cron,timezone}`. Lifecycle config is `{sourceJobIds,states}` with succeeded, failed, or stopped. Templates address the firing trigger by slug, for example `{{trigger-1.issue.title}}`. Manual idempotency keys are client values and must not begin with `manual:`.
10 changes: 10 additions & 0 deletions packages/docs/llms.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Factorize

> Automate coding-agent jobs from provider events on your own exe.dev VM.

- [Quickstart](/quickstart): Configure Factorize and create a first job.
- [Concepts](/concepts): Jobs, triggers, runs, and the Mustache prompt contract.
- [REST authentication](/api/authentication): OAuth, scopes, and device authorization.
- [REST reference](/api/reference): Complete operation inventory and schemas.
- [MCP](/mcp/overview): Connect a remote MCP client.
- [MCP tools](/mcp/tools): Complete tool catalog.
1 change: 1 addition & 0 deletions packages/docs/logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/docs/logo-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions packages/docs/mcp/overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Remote MCP
description: Connect an MCP client to Factorize.
---

Use the single Streamable HTTP URL `APP_ORIGIN/mcp`. The endpoint is OAuth-protected and advertises protected-resource metadata. Compatible clients discover authorization, use PKCE S256, and request only the scopes they need. The server is stateless; each request is tenant-isolated.

```json
{ "mcpServers": { "factorize": { "url": "https://app.factorize.sh/mcp" } } }
```

Tool results contain MCP text plus structured JSON. Errors are reported as `code: message`. Credentials and signing secrets are never accepted or returned.
25 changes: 25 additions & 0 deletions packages/docs/mcp/tools.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: MCP tools
description: Every tool exposed at /mcp.
---

| Tool | Scope | Input |
| --- | --- | --- |
| `list_exe_connections` | flows:read | `{}` |
| `list_github_installations` | flows:read | `{}` |
| `list_execution_targets` | flows:read | `{}` |
| `list_cloudflare_tail_integrations` | flows:read | `{}` |
| `list_jobs` | flows:read | `{}` |
| `get_job` | flows:read | `{jobId}` |
| `list_runs` | runs:read | `jobId?`, `state?`, `contextQuery?`, `limit?`, `cursor?` |
| `get_run` | runs:read | `{runId}` |
| `list_job_webhook_activity` | runs:read | `{jobId, limit?}` |
| `create_job` | flows:write | Job create object |
| `update_job` | flows:write | Job object plus `jobId` |
| `delete_job` | flows:write | `{jobId}` |
| `enable_job` / `disable_job` | flows:write | `{jobId}` |
| `test_job_webhook_handler` | flows:write | `{handlerCode,payload}` |
| `invoke_job` | runs:write | `{jobId,prompt?,idempotencyKey?}` |
| `stop_run` | runs:write | `{runId}` |

`list_runs` uses case-insensitive literal substring matching for `contextQuery`; matching rows contain only a bounded excerpt. `get_run` contains the complete context and the reusable `invocation.idempotency_key`, while its internal `claim_key` must not be reused.
Loading