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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ curl -X POST -H "Authorization: Bearer $FACTORIZE_ACCESS_TOKEN" \
https://app.factorize.sh/api/v1/runs/RUN_ID/stop
```

Connected GitHub App installation metadata, including the installation IDs used by GitHub Job triggers, is available without exposing credentials:

```bash
curl -H "Authorization: Bearer $FACTORIZE_ACCESS_TOKEN" \
https://app.factorize.sh/api/v1/github-installations
```

Job CRUD is available at `/jobs` and `/jobs/:id`; job metadata includes `currentRuns` and `maxConcurrency`. Run collections return `{ "items": [...], "nextCursor": "..." }`; pass `nextCursor` back as the `cursor` query parameter. Runs can be filtered by `jobId`, `state`, and `contextQuery`; context queries use case-insensitive literal substring matching and matching items contain a bounded `context_excerpt`, never the full context. `GET /runs/:runId` returns the complete structured trigger `context` and invocation metadata, including the firing `trigger_id`. The canonical Job prompt contract is documented in [docs/job-trigger-context.md](docs/job-trigger-context.md). Errors consistently use `{ "error": { "code": "...", "message": "..." } }`.

## MCP clients
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/flow-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class ApiService {
}

listExeConnections() { return this.call("flows:read", "/connections/status").then((value: any) => value.exeConnections ?? []); }
listGitHubInstallations() { return this.call("flows:read", "/github/installations"); }
listTailIntegrations() { return this.call("flows:read", "/connections/cloudflare-tail"); }
listRuns(query: URLSearchParams) { return this.call("runs:read", `/v1/runs?${query}`); }
getRun(runId: string) { return this.call("runs:read", `/v1/runs/${encodeURIComponent(runId)}`); }
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/protected-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function protectedApiFetch(request: Request, env: Env, auth: OAuthP
if (path === "/mcp") return mcp(request, service, env, ctx);
if (!path.startsWith("/api/v1")) return Response.json({ error: { code: "not_found", message: "Not found" } }, { status: 404 });
if (request.method === "GET" && path === "/api/v1/exe-connections") return Response.json(await service.listExeConnections());
if (request.method === "GET" && path === "/api/v1/github-installations") return Response.json(await service.listGitHubInstallations());
if (request.method === "GET" && path === "/api/v1/execution-targets") return Response.json(await service.listExecutionTargets());
if (request.method === "GET" && path === "/api/v1/job-trigger-availability") return Response.json(await service.listJobTriggerAvailability());
if (request.method === "POST" && path === "/api/v1/schedules/preview") return Response.json(await service.previewSchedule(await request.json()));
Expand Down Expand Up @@ -72,6 +73,7 @@ async function mcp(request: Request, service: ApiService, env: Env, ctx: Executi
catch (error) { const response = errorResponse(error), detail = await response.json() as any; throw new Error(`${detail.error?.code ?? "operation_failed"}: ${detail.error?.message ?? "Operation failed"}`); }
});
tool("list_exe_connections", "List safe metadata for saved exe.dev connections. API tokens are never returned.", z.object({}), () => service.listExeConnections());
tool("list_github_installations", "List connected GitHub App installations, including the installation IDs needed by GitHub Job triggers. Credentials are never returned.", z.object({}), () => service.listGitHubInstallations());
tool("list_runs", "List authoritative job runs by job ID, state, and an optional case-insensitive literal substring of triggered context. Automatic webhook, schedule, and lifecycle signals coalesce, so query runs and the provider API for authoritative work. Context matches include only a bounded excerpt.", listRunsSchema, (input: any) => service.listRuns(queryOf(input)));
tool("get_run", "Get a run with its full triggered context, invocation metadata, execution metadata, output, and activity. For manual invocations, invocation.idempotency_key is the client-reusable value; invocation.claim_key is internal.", runIdSchema, ({ runId }: any) => service.getRun(runId));
tool("stop_run", "Stop an active run", runIdSchema, ({ runId }: any) => service.stopRun(runId));
Expand Down
13 changes: 13 additions & 0 deletions packages/app/test/flow-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ describe("ApiService", () => {
await service.invokeJob("job-1", { prompt: "go", idempotencyKey: "client-1" });
expect(requests).toEqual(["POST /v1/jobs", "POST /v1/jobs/job-1/invocations"]);
});

it("lists safe GitHub installation metadata with the flow read scope", async () => {
const installations = [{ installationId: 123, accountLogin: "generation", accountType: "Organization", state: "active", updatedAt: "2026-09-17T00:00:00.000Z" }];
const service = new ApiService(environment(request => {
const path = new URL(request.url).pathname;
if (path === "/members/owner-a") return Response.json({ role: "owner", session_version: 4 });
if (path === "/github/installations") return Response.json(installations);
return new Response("Not found", { status: 404 });
}), auth);

await expect(service.listGitHubInstallations()).resolves.toEqual(installations);
expect(JSON.stringify(installations)).not.toMatch(/token|secret|credential/i);
});
});

describe("shared API schemas", () => {
Expand Down