Repository navigation
feat: platform-agnostic orchestrator + crypto-payments example - #8
Merged
Merged
Conversation
Task 1 deliverable on the analysis branch. Assesses decoupling the orchestrator from Cloudflare Dynamic Workers so it can run on any host against any concurrent-capable LLM backend (Anthropic, OpenAI, DeepSeek, open-source/self-hosted). - docs/platform-agnostic-feasibility.md: verdict (yes-with-constraints), Cloudflare coupling map, target ports-and-adapters architecture (AgentRuntime, LlmProvider, StateStore), concurrency implications per backend, phased migration plan, risks, effort estimate. - docs/adr/0001..0004: runtime/compute abstraction, LLM provider abstraction, payment provider abstraction (example), state & observability portability. Verified against source by an independent review agent. Co-authored-by: Cursor <cursoragent@cursor.com>
…nAI-compatible) Phase B of the platform-agnostic refactor (ADR-0002). Extracts the hardcoded two-provider switch in the Cloudflare LLM binding into a runtime-neutral provider layer usable both inside Workers and in the local Node runtime. - src/providers/llm/: LlmProvider port, AnthropicProvider, OpenAiCompatibleProvider (powers OpenAI, DeepSeek, and any self-hosted/open-source OpenAI-compatible endpoint), a registry factory, a shared withRetry helper, and a per-model pricing table. - src/bindings/llm.ts now delegates provider selection to createLlmProvider and retry/backoff to withRetry (single source of truth). Wire format, headers, error strings, and return shape are preserved; existing llm.test.ts passes unchanged. - Adds 429 to the retryable set (fixes a prior duplicated-529 typo that made 429 non-retryable). - Tests: registry/adapter wire-format, pricing prefix matching, retry semantics. 20 new assertions, all green. Reviewed by an independent review agent (APPROVE-WITH-NITS; nits fixed: withRetry adoption, baseUrl trailing-slash normalization, usage optional chaining, pricing token-boundary matching). Co-authored-by: Cursor <cursoragent@cursor.com>
…runtime Phases A/C/D of the platform-agnostic refactor (ADR-0001, ADR-0004). Adds a runtime-neutral orchestration engine and a local execution path that runs concurrent multi-agent orchestration with no Cloudflare account (only an LLM API key). Core (src/core): - Ports: StateStore, AgentRuntime. - Orchestrator engine: dependency-wave scheduling with a bounded Semaphore, self-heal retries (cost accumulated across attempts), failed-dependency skipping, review/cost flow. Injectable decompose. - InMemoryStateStore, pure state-machine (transition table + cost aggregation), decomposeTask. Runtime (src/runtime): - EgressPolicy: domain allowlist + credential injection + guardedFetch, the shared implementation of the Cloudflare HttpGateway policy. - LocalRuntime: runs agents in-process against injected capability bindings (in-memory FS + provider-layer LLM), egress enforced via guardedFetch threaded into the provider (fetchImpl). Agents (src/agents/runners.ts): in-process codegen/test/review logic, the runtime-neutral counterpart of the embedded Dynamic Worker sources. Local server (src/local): env-driven config, LogHub (SSE fan-out), node:http REST + SSE server exposing the same API surface, plus a `dev:local`/`start:local` entry via tsx. Tooling: add ts-node (required by jest.config.ts but previously missing) and tsx (local runtime). 48 new unit tests; full suite unchanged at the pre-existing 9 env-flaky failures. Reviewed by an independent review agent across two rounds (REQUEST-CHANGES -> APPROVE-WITH-NITS); all must-fix items resolved: egress wiring, self-heal cost accounting, revise result-clearing, failed-dependency skipping, and scheduler concurrency tests. Co-authored-by: Cursor <cursoragent@cursor.com>
Streamlined payment service demonstrating the same ports-and-adapters pattern as the orchestrator's LLM layer: one PaymentProvider port with interchangeable Stripe, PayPal, Coinbase Commerce, and Mock adapters selected purely by configuration. - Webhook signatures verified per provider (timing-safe HMAC-SHA256; Stripe replay tolerance; PayPal server-side verification) before any event data is trusted. - Currency-aware money handling in integer minor units (JPY/crypto safe). - Node HTTP server exposes health/charge/status/webhook endpoints; error paths avoid leaking upstream provider responses. - Tests (Node test runner via tsx) cover provider selection, charge mapping, money conversion, and valid/tampered/replayed webhooks. Reviewed by the review-agent quality gate (APPROVE); tsc --noEmit clean, 15/15 tests passing. Co-authored-by: Cursor <cursoragent@cursor.com>
Encapsulates the engineering standards used throughout this work: plan-first, respect conventions, a per-change quality gate (typecheck/tests/security), a design/architecture review checklist, and a mandatory independent review-agent workflow with blocking findings. Co-authored-by: Cursor <cursoragent@cursor.com>
Summarize the platform-agnostic feasibility outcome and Task 2 implementation (runtime/LLM/state ports, local Node runtime, crypto-payments example), and add a GitHub Actions quality gate (typecheck + tests + npm audit) scoped to the new example. Documents known pre-existing root typecheck/test issues as follow-ups. Co-authored-by: Cursor <cursoragent@cursor.com>
Node's built-in test runner only expands glob patterns (src/**/*.test.ts) from Node 21+. On Node 20 the pattern was treated as a literal path, so `npm test` failed with "Could not find .../src/**/*.test.ts". Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converts the Cloudflare-only Dynamic Workers orchestrator into a
platform-agnostic, ports-and-adapters architecture (backward compatible with
the existing Cloudflare deploy) and adds a new modular crypto-payments example.
src/providers/llm/): Anthropic + OpenAI-compatible(OpenAI/DeepSeek/Ollama/self-hosted), selected by a registry, with pricing and
retry helpers and an injectable
fetchImplfor egress control.bindings/llm.tsnow delegates here without changing its public contract.
src/core/): pure state machine, taskdecomposition, bounded-concurrency semaphore, cost-accurate self-heal, and an
in-memory
StateStore— no Cloudflare primitives.src/runtime/,src/local/):EgressPolicy(domain allowlist + credential injection),
LocalRuntime, and a Node HTTPserver with SSE log streaming (
npm run dev:local).examples/crypto-payments/: onePaymentProviderport withswappable Stripe / PayPal / Coinbase / Mock adapters selected purely via
PAYMENT_PROVIDER. Signature-verified webhooks (timing-safe HMAC; Stripereplay tolerance; PayPal server-side verify), currency-aware integer money,
and error paths that don't leak upstream responses.
docs/platform-agnostic-feasibility.md, ADRs 0001–0004,docs/technical-summary.md.review-agent gate, and a CI quality gate for the example
(
.github/workflows/crypto-payments-ci.yml).Test plan
examples/crypto-payments:npm run typecheckclean;npm test15/15 passingnpm audit)Notes / known pre-existing issues (out of scope)
npm run typecheckis red because the roottsconfig.jsonincludes*.test.tswithout Jest types (tests still compile via ts-jest). Follow-up:exclude tests from root
tscor add atsconfig.test.json-based script.WebSocketPairshims /Node 24 fake-timer flakiness — environmental, not caused by this change.
Made with Cursor