6 Commits

Author SHA1 Message Date
eust-w
e1c381486d 🐛 Keep long model streams alive and retry rejected model requests
The proxy aborted every upstream call 120 seconds after it started, even
while the model was still streaming, so a long reasoning turn ended as an
unknown outcome that an admin had to reconcile. Calls now stop only when
no bytes arrive for 2 minutes, or after 10 minutes in total, inside the
15 minutes after which the reaper treats a request as lost. The recorded
reason says which limit stopped it.

A rejected request (a 429, an invalid request, or one stopped before
upstream I/O) was stored and replayed for every retry of the same body,
so one rate limit stalled the run for the rest of its lease. Rejections
use no tokens, so a retry is now sent again; completed responses are
still replayed and unknown outcomes still wait for reconciliation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 04:04:27 +08:00
eust-w
b4ece6057c fix: let the console build, and stop runs that cannot afford the next model request
Building the web image showed that `next build` failed.
- The console imported runtime values from the contracts entry point.
- Turbopack cannot follow the NodeNext `.js` imports inside that entry,
  which also carries zod and every schema into the browser.
- Only `next dev` had ever run before, and the console used to import
  types only.

The fix:
- The executor catalog moves to an entry without imports, exported as
  @wishforge/contracts/providers. The console takes its values from
  there.
- providerBaseUrl moves to its own module.
- A test keeps value imports of the entry point out of the console.

With the console's default budget of 50,000 tokens, every Codex run
stopped after one model request:
- The proxy reserves one token per request byte, and a Codex request is
  already about 50 KB.
- The executor then reported a bare 429 as a provider failure.

The fix:
- A request the remaining budget cannot cover now puts the run into the
  `budget` wait, with what it needs and what remains.
- The console defaults to 300,000 tokens and explains the reservation.

The run page also marked the stage a successful run ended in as not yet
done; it now shows it as complete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 05:20:27 +08:00
eust-w
3eb8ea03bf feat: run models through an operator's OpenAI- or Anthropic-compatible gateway
The model proxy always forwarded to api.openai.com and development runs gave
Codex no base URL or model, so a company model gateway could not be used.

- WF_OPENAI_BASE_URL points the production proxy (and development Codex runs)
  at an OpenAI-compatible gateway with the Responses API; WF_ANTHROPIC_BASE_URL
  gives Claude Code an Anthropic-compatible one as ANTHROPIC_BASE_URL. Both are
  operator settings in the provider catalog, HTTPS without credentials
  (loopback HTTP outside production); an invalid gateway disables the proxy.
- Development credentials now carry the run's model, so WF_CODEX_DEFAULT_MODEL
  selects a model the gateway serves.
- tests/integration/real-model.test.ts (WF_REAL_MODEL_INTEGRATION=1, key from
  WF_TEST_MODEL_API_KEY) runs one wish through the real Codex executor, the
  verifier and integration into a local repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 22:28:33 +08:00
eust-w
1d75b03430 feat: register executors in one catalog and add Claude Code (FR-D1)
Adding an executor touched the contracts, the API's availability check, the
worker and the console separately. Now it is an adapter plus one entry in
@wishforge/contracts' providerCatalog (name, executable variable, whether the
model proxy isolates its credentials) and one in the worker's
providerRegistry; the API, the console's options and MCP's submit_wish read
the catalog, and a test checks every entry is registered with the worker.

The CodeBuddy adapter already parsed Claude-Code-style stream-json, so it is
now a StreamJsonCliAdapter with a dialect per CLI. Claude Code runs headless
with --verbose and --permission-mode bypassPermissions inside the per-run
sandbox and receives only ANTHROPIC_* credentials (WF_CLAUDE_BIN). Like
CodeBuddy it is development-only until the model proxy supports it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 20:23:05 +08:00
eust-w
b38db08eeb docs: align documentation with the code and write it in Chinese
Operations, development and architecture docs, the reference pages and the
component READMEs were rewritten against the code: every documented variable
exists, and the settings operators need (runtime image, Git service, listen
addresses, Runner targets, single-tenant gateway and provisioner bindings) are
documented.

Gaps the docs used to present as working are now stated as such: IDE
workspaces do not clone the project yet (FR-H2), and in Kubernetes mode
dependency installs and image builds have no network path until an egress
proxy and builder access exist. The Kubernetes README describes what the
provisioner creates, what the Runner needs in a target namespace, and the
cluster acceptance that is still outstanding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 18:01:39 +08:00
eust-w
86649af4d6 docs: rewrite architecture and restructure documentation
- docs/architecture.md replaces system-design.md: component map,
  run state machine with an explicit waiting-reason catalogue, key
  sequences (dispatch, execute/verify/repair, integrate, release,
  IDE launch, lessons), data model, API surface, identity and trust
  model, isolation modes (host for local development, kata for
  production), deployment topology, ADRs, known limitations and a
  requirement-to-test verification matrix.
- docs/development.md: local setup, one-command start, first wish,
  IDE, MCP and the test matrix (integration toggles are explicit).
- docs/operations.md: production prerequisites, explicit deployment
  mode, component configuration, Kubernetes provisioner, tenants and
  quotas, IDE gateway routing and lifecycle, delivery, monitoring,
  backup/restore, incident handling and known risks. Merges the former
  observability, recovery, billing-entitlements and runbook documents.
- Contract documents move to docs/reference/; evidence narratives that
  pointed at machine-local /private/tmp files are removed and the UI
  reference is rewritten for the target console.
- Delete docs for removed scope: workspace snapshot handoff and private
  application access.
- README rewritten as a concise entry point.

The documents describe the target state that the following
implementation commits realise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 13:29:46 +08:00