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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[![CI](https://github.com/GenerationSoftware/factorize/actions/workflows/ci.yml/badge.svg)](https://github.com/GenerationSoftware/factorize/actions/workflows/ci.yml)

Factorize hosts jobs for your coding agents. **Connect your agent → create a job → run it → inspect the result → automate it.**
Factorize hosts triggers for your coding agents. **Connect your agent → create a trigger → run it → inspect the result → automate it.**

Start at [app.factorize.sh](https://app.factorize.sh). Sign up with email and password, verify email, and connect an execution account in **Settings → Integrations**. You supply execution, repository/model access and any provider accounts; Factorize hosts job configuration, triggers, queues and run history.
Start at [app.factorize.sh](https://app.factorize.sh). Sign up with email and password, verify email, and configure an OpenAI-compatible model integration in **Settings → Integrations**. Your personal team owns skills, runs, Triggers, integrations and defaults. Pi runs in Factorize with PostgreSQL persistence. Enable an optional exe.dev or Fly workspace for agent tasks that need a VM; scripts always require one.

Connect a supported remote MCP client to:

Expand All @@ -14,11 +14,11 @@ https://app.factorize.sh/mcp

Follow [Connect your agent](https://docs.factorize.sh/mcp/overview) for Codex/Claude Code configuration and browser consent. Then ask:

> Show me my available execution integrations. Create a manual job called ‘Review recent changes’ using my repository’s target. Have it clone REPOSITORY_URL, review the latest commit and summarize any problems. Run it once and report the result.
> Inspect my team defaults. Create a manual Trigger named review-recent-changes with a required workspace. Have it clone REPOSITORY_URL, review the latest commit and summarize any problems. Run it once and report the result.

The conversational agent calls `list_execution_configs`, checks existing jobs, creates a job, invokes it with a stable idempotency key, and reads `get_run` until completion. Current exe.dev targets select an account/agent, not a repository: put the repository URL in the prompt. Browser-only signup, integration credentials, resource selection and consent are separate from MCP job management.
The conversational agent calls `get_team` and reflection, checks existing Triggers, creates a Trigger, invokes it with a stable idempotency key, and reads `get_run` until completion. Skills and hosted Pi use the same MCP environment. Put the repository URL in the prompt; a VM configuration does not bind a repository. Browser-only signup, integration credentials, resource selection and consent are separate from MCP trigger management.

Read [Your first job](https://docs.factorize.sh/quickstart), [safe editing and configuration replacement](https://docs.factorize.sh/work/jobs), and [stop/retry behavior](https://docs.factorize.sh/work/stop-retry). Add [schedules](https://docs.factorize.sh/recipes/scheduled-review), [Linear](https://docs.factorize.sh/recipes/linear-job), [GitHub](https://docs.factorize.sh/integrations/github), [ClickUp](https://docs.factorize.sh/integrations/clickup), or [job chaining](https://docs.factorize.sh/recipes/chaining) after a successful manual run.
Read [Your first trigger](https://docs.factorize.sh/quickstart), [safe editing and configuration replacement](https://docs.factorize.sh/work/triggers), and [stop/retry behavior](https://docs.factorize.sh/work/stop-retry). Add [schedules](https://docs.factorize.sh/recipes/scheduled-review), [Linear](https://docs.factorize.sh/recipes/linear-trigger), [GitHub](https://docs.factorize.sh/integrations/github), [ClickUp](https://docs.factorize.sh/integrations/clickup), or [trigger chaining](https://docs.factorize.sh/recipes/chaining) after a successful manual run.

MCP provides selected scoped operations, not every REST capability. REST contracts remain available in [OpenAPI](packages/docs/openapi.yaml) and [authentication reference](https://docs.factorize.sh/api/authentication). Credential management and trace replay require an interactive owner session. Agents can use the generated [llms.txt](packages/docs/llms.txt) and [llms-full.txt](packages/docs/llms-full.txt).

Expand Down
218 changes: 218 additions & 0 deletions TODO.md

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions docs/hosted-pi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Hosted Pi execution

Factorize bundles `@earendil-works/pi-agent-core` and `@earendil-works/pi-ai` at 1.5.2. The managed runtime runs in the Worker with Node compatibility, using the selected OpenAI Chat Completions adapter. Guest images do not install or launch managed agents. VM scripts retain their separate execution lifecycle. Worker identity, database, scheduler, and storage bindings are unchanged.

A model integration stores an OpenAI-compatible provider base URL and optional API key, encrypted by the existing managed credential repository. The model ID belongs to Team defaults or the Trigger/run override. Model and VM catalogs are independent. Optional context/output limits control the framework request and compaction threshold. A keyless integration sends no Authorization header. Credentials are resolved anew for each scheduler turn; they never enter agent messages.

PostgreSQL owns encrypted session checkpoints, a stream event journal, tool-call records, framework version, lease epochs, and turn/compaction counts. A scheduler tick runs one complete Pi turn, including its tool batch, then releases the lease and schedules continuation. The framework owns provider streaming, tool execution, message conversion and cancellation. Compaction uses a framework model call and retains the original journal. The public trace projection uses the same tenant-scoped trace table as historical traces.

Leases last 90 seconds and are renewed every five seconds during execution. Every session write checks the lease epoch and authoritative active run state. Cancellation invalidates access and aborts an active provider stream. A fresh worker restores the last complete checkpoint; partial streaming records remain in the journal. Finalization is idempotent after the completed-session boundary. Interrupted tool outcomes require explicit reconciliation rather than an assumed success.

Migration 0073 retains historical run configurations and trace bytes. It records retired Team/Trigger agent selections as configuration diagnostics and makes Pi canonical for future Trigger execution. Existing subscription credentials remain stored, but require replacement with a compatible provider URL/key before new managed runs. Retired device authorization and guest harness selection are absent from the public contract. Script runs remain VM workloads.

Local validation uses an actual bundled Pi and an isolated PostgreSQL database with a deterministic OpenAI-compatible HTTP server. It covers streaming, tools, compaction, provider errors, keyless requests, restart continuation, competing leases, cancellation, and scheduler launch without a guest backend. No live provider account or deployment is required.

Agent runs default to `requiresVm: false`. Scripts always require a VM. Direct
runs resolve an explicit VM configuration before the Team default; an explicit
configuration implies `requiresVm: true` unless the request contradicts it, which
is rejected. A required missing or unavailable configuration fails admission or
provisioning. An unused Team VM default does not affect a VM-free run. Triggers
copy their VM requirement/configuration at creation.

A remote workspace is provisioned separately from Pi. PostgreSQL stores a fenced
provisioning receipt, selected integration epoch, exact provider handle and an
encrypted random guest proof before work begins. Readiness and ownership are
verified before the first model turn and subsequent turns/commands. The MCP
`get_api_reflection` tool reports `agentHost: factorize` and a verified
`current_vm`, or null. `vm_exec` executes only in the active run's server-bound
workspace; it accepts a command and optional absolute cwd, never a VM identifier.
External identities without a bound run cannot use it. Workspace access does not
grant account-wide provider API access. Provider disconnection/reconnect cannot
restore an old workspace grant. Cleanup retains independent receipts through
cancellation, late provisioning, partial provider failures and run deletion.

exe.dev uses its documented HTTPS command API and NDJSON command stream with an
explicit exit status. Fly uses the Machines API and guest exec. Neither provider
installs or launches Pi or another managed agent in the guest.

`start_run` returns an admission receipt immediately. Hosted execution is driven
by a dedicated durable alarm per run, independent of the global admission and
maintenance alarm. PostgreSQL leases and epochs fence all model, MCP and journal
writes. A replacement worker resumes the last complete checkpoint; unfinished
stream tokens do not authorize tool effects.

Each tool call commits its validated arguments before execution and its encrypted
result before returning to Pi. Recovery reuses completed results and resolves
missing batch entries through the framework's tool runner. `start_run` and
`invoke_trigger` receive stable server-generated idempotency keys, including
when a response is interrupted. Read-only operations may retry. An unconfirmed
mutating operation (including a VM command) blocks with `pi_tool_uncertain`, its
call ID and a diagnostic. It is not repeated automatically. Canceling a blocked
run still removes its workspace. No endpoint silently resumes uncertain effects.

Media uses the pinned Pi content contract: text and images. Pi 1.5.2 does not
accept audio or video blocks. Factorize performs no decoding, resizing,
transcoding or MIME guessing; provider format/capability errors remain visible.
Reflection reports these capabilities. Uploads are capped at 32 MiB each and a
model turn at 16 MiB of decoded image bytes, bounding Worker memory use.

Use POST /api/v1/media/uploads with mediaType, byteSize, SHA-256 and an
idempotencyKey; PUT the raw bytes to its uploadUrl with the declared Content-Type.
Pass attachments: [{artifactId}] to start_run or POST /api/v1/runs. A run can have
up to 16 input images and can start with images alone. The dashboard Start run
form uses these same endpoints. Upload retries reuse the receipt and immutable
metadata; changing metadata under the same key conflicts. Streaming counts and
hashes bytes and commits only after R2 confirms the write. Independent upload
attempt receipts retain unadopted objects for cleanup.

MCP fetch_media accepts an authorized integration, relative GET path, optional
headers and idempotencyKey. It follows ordinary proxy authorization and returns
a media reference. read_media returns standard MCP image content. Hosted Pi
stores only references in checkpoints, tool journals and stream events, then
loads original bytes at the framework/provider boundary. Inputs and scratch
remain isolated by Team and active run; one run cannot choose another run's
scratch. No credentials are included in references. Uploaded/fetched media never
creates a published-output or artifact-promotion feature.

Media cleanup follows reachability. Input images and artifact references actually
included in the structured final result stay with the run's retained history.
There is no promotion endpoint: result references are retained automatically as
part of that result. Other media is scratch, protected throughout execution and
for one hour after termination. Unattached uploads expire after 24 hours. Deleting
run history removes its media links and makes otherwise unreferenced blobs
eligible for cleanup. Private proxy buffers used only by fetch_media expire as
soon as capture finishes.

Cleanup claims PostgreSQL leases before R2 deletion, stops new reads/attachments,
and retries partial failures. Independent object-attempt tombstones repeat
confirmed deletions for 24 hours to cover ambiguous or late writes. Active upload
leases and images shared with retained inputs/results remain protected. The
existing RUN_HISTORY_RETENTION_PAUSED setting also pauses media expiry. VM
resource finalization continues while history retention is paused.

Runs retain their editable display name. Source is the Trigger name captured at
admission, or manual for direct runs; it remains stable after rename/deletion.
Prompt shows an optional /skill name plus a bounded literal-context preview, or
the shortened script for script runs. Skill instructions remain part of the full
harness input, with a separate full context snapshot for detail clients. New
preview/context snapshots are encrypted; list reads are bounded to a page and do
not assemble full invocation/trace data. Historical runs retain their accepted
prompt and original resource snapshots.
Loading