diff --git a/README.md b/README.md index c75056dc..1a1d8bd0 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package-lock.json b/package-lock.json index 151fc6a5..b353f702 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4097,6 +4097,10 @@ "resolved": "packages/app", "link": true }, + "node_modules/factorize-docs": { + "resolved": "packages/docs", + "link": true + }, "node_modules/factorize-marketing": { "resolved": "packages/marketing", "link": true @@ -5893,6 +5897,10 @@ "wrangler": "^4.44.0" } }, + "packages/docs": { + "name": "factorize-docs", + "version": "0.1.0" + }, "packages/marketing": { "name": "factorize-marketing", "version": "0.1.0", diff --git a/packages/app/src/ui.ts b/packages/app/src/ui.ts index aba3200a..64ebcdea 100644 --- a/packages/app/src/ui.ts +++ b/packages/app/src/ui.ts @@ -47,6 +47,7 @@ export const landingPage = (viewer: Viewer) => shell("Factorize: Software Factor

Create a multiplayer software factory with Linear, Exe.dev and Herdr

Create Job + Read the docs Host it Yourself
diff --git a/packages/docs/README.md b/packages/docs/README.md new file mode 100644 index 00000000..75e45709 --- /dev/null +++ b/packages/docs/README.md @@ -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. diff --git a/packages/docs/api/authentication.mdx b/packages/docs/api/authentication.mdx new file mode 100644 index 00000000..60731090 --- /dev/null +++ b/packages/docs/api/authentication.mdx @@ -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 `. 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. diff --git a/packages/docs/api/discovery.mdx b/packages/docs/api/discovery.mdx new file mode 100644 index 00000000..00212c2e --- /dev/null +++ b/packages/docs/api/discovery.mdx @@ -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. diff --git a/packages/docs/api/openapi.mdx b/packages/docs/api/openapi.mdx new file mode 100644 index 00000000..2768ff0c --- /dev/null +++ b/packages/docs/api/openapi.mdx @@ -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. diff --git a/packages/docs/api/reference.mdx b/packages/docs/api/reference.mdx new file mode 100644 index 00000000..4f6fb72c --- /dev/null +++ b/packages/docs/api/reference.mdx @@ -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`. diff --git a/packages/docs/concepts.mdx b/packages/docs/concepts.mdx new file mode 100644 index 00000000..42f7a2f5 --- /dev/null +++ b/packages/docs/concepts.mdx @@ -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. diff --git a/packages/docs/docs.json b/packages/docs/docs.json new file mode 100644 index 00000000..7b0530a1 --- /dev/null +++ b/packages/docs/docs.json @@ -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"] } + ] + } +} diff --git a/packages/docs/index.mdx b/packages/docs/index.mdx new file mode 100644 index 00000000..2fdfdcc3 --- /dev/null +++ b/packages/docs/index.mdx @@ -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. + + + Create and invoke your first job + Every public REST operation + + +The public documentation origin is `https://docs.factorize.sh`; replace `https://app.factorize.sh` in examples with your deployment origin when self-hosting. diff --git a/packages/docs/integrations/oauth.mdx b/packages/docs/integrations/oauth.mdx new file mode 100644 index 00000000..d40eeeb7 --- /dev/null +++ b/packages/docs/integrations/oauth.mdx @@ -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. diff --git a/packages/docs/integrations/triggers.mdx b/packages/docs/integrations/triggers.mdx new file mode 100644 index 00000000..7891af81 --- /dev/null +++ b/packages/docs/integrations/triggers.mdx @@ -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. diff --git a/packages/docs/llms-full.txt b/packages/docs/llms-full.txt new file mode 100644 index 00000000..11e869e8 --- /dev/null +++ b/packages/docs/llms-full.txt @@ -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:`. diff --git a/packages/docs/llms.txt b/packages/docs/llms.txt new file mode 100644 index 00000000..f78f7c8f --- /dev/null +++ b/packages/docs/llms.txt @@ -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. diff --git a/packages/docs/logo-dark.svg b/packages/docs/logo-dark.svg new file mode 100644 index 00000000..d43696f2 --- /dev/null +++ b/packages/docs/logo-dark.svg @@ -0,0 +1 @@ +Factorize diff --git a/packages/docs/logo-light.svg b/packages/docs/logo-light.svg new file mode 100644 index 00000000..248aa64d --- /dev/null +++ b/packages/docs/logo-light.svg @@ -0,0 +1 @@ +Factorize diff --git a/packages/docs/mcp/overview.mdx b/packages/docs/mcp/overview.mdx new file mode 100644 index 00000000..a3f8b997 --- /dev/null +++ b/packages/docs/mcp/overview.mdx @@ -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. diff --git a/packages/docs/mcp/tools.mdx b/packages/docs/mcp/tools.mdx new file mode 100644 index 00000000..e9b85f8e --- /dev/null +++ b/packages/docs/mcp/tools.mdx @@ -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. diff --git a/packages/docs/openapi.yaml b/packages/docs/openapi.yaml new file mode 100644 index 00000000..8db343b0 --- /dev/null +++ b/packages/docs/openapi.yaml @@ -0,0 +1,52 @@ +openapi: 3.1.0 +info: + title: Factorize API + version: 1.0.0 + description: Versioned Factorize REST API. See the hosted docs for examples and OAuth discovery. +servers: + - url: https://app.factorize.sh +security: [{ bearerAuth: [] }] +components: + securitySchemes: + bearerAuth: { type: http, scheme: bearer, bearerFormat: OAuth2 } + schemas: + Error: { type: object, required: [error], properties: { error: { type: object, required: [code, message], properties: { code: { type: string }, message: { type: string } } } } } + JobInput: + type: object + required: [name, slug, promptTemplate, executionTargetId] + additionalProperties: false + properties: + name: { type: string, minLength: 1, maxLength: 120 } + slug: { type: string, pattern: '^[a-z][a-z0-9_-]{0,29}$' } + promptTemplate: { type: string, minLength: 1, maxLength: 50000 } + concurrencyLimit: { type: integer, minimum: 1, maximum: 50, default: 1 } + executionTargetId: { type: string, minLength: 1 } + model: { type: string, maxLength: 120 } + effort: { type: string, maxLength: 40 } + triggers: { type: array, maxItems: 50, items: { type: object } } + RunPage: { type: object, required: [items], properties: { items: { type: array, items: { type: object } }, nextCursor: { type: string, nullable: true } } } +paths: + /api/health: { get: { summary: Worker health check, security: [], responses: { '200': { description: OK, content: { application/json: { example: { ok: true } } } } } } } + /api/v1/exe-connections: { get: { summary: List exe connections, responses: { '200': { description: Safe metadata } } } } + /api/v1/github-installations: { get: { summary: List GitHub installations, responses: { '200': { description: Installations } } } } + /api/v1/execution-targets: { get: { summary: List execution targets, responses: { '200': { description: Targets } } } } + /api/v1/job-trigger-availability: { get: { summary: List available trigger kinds, responses: { '200': { description: Availability } } } } + /api/v1/integrations/cloudflare-tail: { get: { summary: List Tail integrations, responses: { '200': { description: Integrations } } } } + /api/v1/jobs: + get: { summary: List jobs, responses: { '200': { description: Jobs } } } + post: { summary: Create job, requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/JobInput' } } } }, responses: { '201': { description: Created } } } + /api/v1/jobs/{jobId}: + parameters: [{ name: jobId, in: path, required: true, schema: { type: string } }] + get: { summary: Get job, responses: { '200': { description: Job } } } + put: { summary: Replace job, requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/JobInput' } } } }, responses: { '200': { description: Updated } } } + delete: { summary: Delete job, responses: { '200': { description: Deleted } } } + /api/v1/jobs/{jobId}/enable: { post: { summary: Enable job, responses: { '200': { description: Enabled } } } } + /api/v1/jobs/{jobId}/disable: { post: { summary: Disable job, responses: { '200': { description: Disabled } } } } + /api/v1/jobs/{jobId}/invocations: { post: { summary: Invoke job, responses: { '202': { description: Accepted } } } } + /api/v1/jobs/{jobId}/events: { get: { summary: List webhook activity, responses: { '200': { description: Activity } } } } + /api/v1/job-handlers/test: { post: { summary: Test webhook handler, responses: { '200': { description: Decision } } } } + /api/v1/runs: + get: { summary: List runs, parameters: [{ name: jobId, in: query, schema: { type: string } }, { name: state, in: query, schema: { type: string } }, { name: contextQuery, in: query, schema: { type: string } }, { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100 } }, { name: cursor, in: query, schema: { type: string } }], responses: { '200': { description: Paginated runs, content: { application/json: { schema: { $ref: '#/components/schemas/RunPage' } } } } } } + /api/v1/runs/{runId}: { get: { summary: Get run, responses: { '200': { description: Run } } } } + /api/v1/runs/{runId}/stop: { post: { summary: Stop run, responses: { '200': { description: Stopped } } } } + /api/v1/schedules/preview: { post: { summary: Preview schedule, responses: { '200': { description: Next occurrence } } } } diff --git a/packages/docs/package.json b/packages/docs/package.json new file mode 100644 index 00000000..c16dbf35 --- /dev/null +++ b/packages/docs/package.json @@ -0,0 +1,10 @@ +{ + "name": "factorize-docs", + "private": true, + "version": "0.1.0", + "scripts": { + "dev": "mint dev", + "validate": "node scripts/validate.mjs", + "deploy": "mint deploy" + } +} diff --git a/packages/docs/quickstart.mdx b/packages/docs/quickstart.mdx new file mode 100644 index 00000000..ad2ae976 --- /dev/null +++ b/packages/docs/quickstart.mdx @@ -0,0 +1,34 @@ +--- +title: Quickstart +description: Configure authentication and create a job end to end. +--- + +## Prerequisites + +You need a Cloudflare Worker deployment, a Linear OAuth application, an exe.dev VM with Herdr and an agent, and an HTTPS API token restricted to the exact SSH destination used by the VM. Set `APP_ORIGIN`, OAuth credentials, `LINEAR_WEBHOOK_SIGNING_SECRET`, `CREDENTIAL_ENCRYPTION_KEY`, and `SESSION_SIGNING_SECRET`. + +Sign in to the dashboard, connect the VM, choose an execution target, and create a job. Use `list_execution_targets` or `GET /api/v1/execution-targets` before submitting `executionTargetId`. + +## First API call + +```bash +curl -H "Authorization: Bearer $FACTORIZE_ACCESS_TOKEN" "$APP_ORIGIN/api/v1/jobs" +``` + +Create a manual job: + +```bash +curl -X POST "$APP_ORIGIN/api/v1/jobs" \ + -H "Authorization: Bearer $FACTORIZE_ACCESS_TOKEN" -H 'content-type: application/json' \ + -d '{"name":"Review changes","slug":"review-changes","promptTemplate":"Review: {{trigger-1.prompt}}","executionTargetId":"TARGET_ID","triggers":[{"kind":"manual","config":{}}]}' +``` + +Invoke it with a reusable idempotency key: + +```bash +curl -X POST "$APP_ORIGIN/api/v1/jobs/JOB_ID/invocations" \ + -H "Authorization: Bearer $FACTORIZE_ACCESS_TOKEN" -H 'content-type: application/json' \ + -d '{"prompt":"Review the latest commit","idempotencyKey":"review-2026-09-17"}' +``` + +The response is `202`. Query `/runs` and then `/runs/RUN_ID`; stop an active run with `/runs/RUN_ID/stop`. diff --git a/packages/docs/scripts/validate.mjs b/packages/docs/scripts/validate.mjs new file mode 100644 index 00000000..53a819b5 --- /dev/null +++ b/packages/docs/scripts/validate.mjs @@ -0,0 +1,11 @@ +import { readFile } from "node:fs/promises"; +import { resolve } from "node:path"; + +const root = resolve(import.meta.dirname, ".."); +const api = await readFile(resolve(root, "openapi.yaml"), "utf8"); +const worker = await readFile(resolve(root, "../app/src/protected-api.ts"), "utf8"); +const expected = ["exe-connections", "github-installations", "execution-targets", "job-trigger-availability", "integrations/cloudflare-tail", "jobs", "job-handlers/test", "runs", "schedules/preview"]; +const missing = expected.filter(path => !api.includes(path) || !worker.includes(path)); +for (const file of ["docs.json", "llms.txt", "llms-full.txt"]) await readFile(resolve(root, file)); +if (missing.length) throw new Error(`Documentation route inventory is stale: ${missing.join(", ")}`); +console.log(`Validated ${expected.length} route families, Mintlify config, and LLM exports.`);