An open-source, faster Devin alternative
TypeScript
review fixes (P2): decouple provisioner from Autumn guard + neutral Managed copy
Igor Zalutski99cc599148ac
diff --git a/cloudflare-workers/api-edge/src/index.ts b/cloudflare-workers/api-edge/src/index.tsindex 70bfce36..69580c0f 100644--- a/cloudflare-workers/api-edge/src/index.ts+++ b/cloudflare-workers/api-edge/src/index.ts@@ -2142,16 +2142,21 @@ export default {// key's spend → debit Autumn `model_spend` → push the markup-correct cap + halt.// Dormant unless OPENROUTER_PROVISIONING_KEY is set + managed keys exist.async scheduled(_event: ScheduledController, env: Env, ctx: ExecutionContext): Promise<void> {- if (!env.AUTUMN_SECRET_KEY) return;- ctx.waitUntil(- runAutumnMeter(env, Date.now()).catch((err) => console.error("autumn-meter: run failed", err)),- );- if (env.OPENROUTER_PROVISIONING_KEY) {+ // Autumn meter + the credit-debiting model meter are Autumn-specific.+ if (env.AUTUMN_SECRET_KEY) {ctx.waitUntil(- runModelMeter(env, Date.now()).catch((err) => console.error("model-meter: run failed", err)),+ runAutumnMeter(env, Date.now()).catch((err) => console.error("autumn-meter: run failed", err)),);- // Keep Managed an invariant: drain any org without a managed credential (backfill +- // new orgs from any create path + failed provisions). Idempotent, bounded per tick.+ if (env.OPENROUTER_PROVISIONING_KEY) {+ ctx.waitUntil(+ runModelMeter(env, Date.now()).catch((err) => console.error("model-meter: run failed", err)),+ );+ }+ }+ // Managed provisioning is OpenRouter-only (decoupled from billing) — it must run+ // even where Autumn is absent or disabled. Keeps Managed an invariant: drains any org+ // without a managed credential (backfill + new orgs from any path + failed provisions).+ if (env.OPENROUTER_PROVISIONING_KEY) {ctx.waitUntil(runManagedProvisioner(env).catch((err) => console.error("managed-provisioner: run failed", err)),);diff --git a/sdks/typescript/src/agents/agents.ts b/sdks/typescript/src/agents/agents.tsindex bf08fb22..973667a4 100644--- a/sdks/typescript/src/agents/agents.ts+++ b/sdks/typescript/src/agents/agents.ts@@ -10,7 +10,7 @@ export interface CreateAgentParams {runtime?: Runtime;/** Model provider key for the runtime (Anthropic for `claude`, OpenAI for `codex`), stored as a sealed credential. Mutually exclusive with `credential`. */key?: string;- /** Model source: `"managed"` (run via OpenComputer, billed to credits) or a `cred_…` id. Omit for the org default. Mutually exclusive with `key`. */+ /** Model source: `"managed"` (run via OpenComputer, no provider key) or a `cred_…` id. Omit for the org default. Mutually exclusive with `key`. */credential?: CredentialRef;limits?: Limits;}diff --git a/sdks/typescript/src/agents/types.ts b/sdks/typescript/src/agents/types.tsindex c7c898a4..20445ffb 100644--- a/sdks/typescript/src/agents/types.ts+++ b/sdks/typescript/src/agents/types.ts@@ -18,7 +18,7 @@ export type Runtime = "claude" | "codex" | (string & {});// checkable while still accepting any concrete id.export type CredentialId = `cred_${string}`;// How an agent picks its model source: the reserved "managed" sentinel (run via-// OpenComputer, billed to credits) or a specific BYO credential id. Omit/null to+// OpenComputer, no provider key) or a specific BYO credential id. Omit/null to// inherit the org default.export type CredentialRef = "managed" | CredentialId;diff --git a/web/src/pages/AgentDetail.tsx b/web/src/pages/AgentDetail.tsxindex e5a7982b..2e09bc3e 100644--- a/web/src/pages/AgentDetail.tsx+++ b/web/src/pages/AgentDetail.tsx@@ -33,7 +33,7 @@ import { getRuntime } from '@/lib/runtimes'// credential provider come from the agent's runtime (see @/lib/runtimes).const ORG_DEFAULT = '__default__' // no pinned credential → org default resolvesconst NEW_CRED = '__new__' // create one inline-const MANAGED = 'managed' // run via OpenComputer, billed to credits (token-billing §6.6)+const MANAGED = 'managed' // run via OpenComputer, no BYO key (token-billing §6.6)export default function AgentDetail() {const { agentId = '' } = useParams()@@ -180,7 +180,7 @@ export default function AgentDetail() {// Managed is always offered (every org carries a managed credential); it has no provider.const credOptions = [{ value: ORG_DEFAULT, label: 'Org default (no pinned credential)' },- { value: MANAGED, label: 'Managed · billed to credits' },+ { value: MANAGED, label: 'Managed · no key needed' },...providerCreds.map((c) => ({ value: c.id, label: credLabel(c.id) })),{ value: NEW_CRED, label: '+ New credential…' },]diff --git a/web/src/pages/Agents.tsx b/web/src/pages/Agents.tsxindex 737a6943..34d6a98e 100644--- a/web/src/pages/Agents.tsx+++ b/web/src/pages/Agents.tsx@@ -34,7 +34,8 @@ import {// Sentinels for the non-credential choices in the credential picker. The model// list + credential provider both follow the chosen runtime (see @/lib/runtimes).const NEW_CRED = '__new__'-// "Managed" model access: run via OpenComputer, billed to credits (no BYO key).+// "Managed" model access: run via OpenComputer with no BYO key. Billing varies by org+// (Autumn → credits; otherwise a fixed OpenRouter key cap), so the label stays neutral.// Sent to the API as the reserved credential value "managed" (token-billing §6.6).const MANAGED = 'managed'@@ -105,10 +106,10 @@ export default function Agents() {setNewCredKey('')}- // Build options: Managed (if available, billed to credits — no provider filter, it- // has no provider) + this runtime's provider creds + "New credential…".+ // Build options: Managed (always offered, no provider — runs without a BYO key) ++ // this runtime's provider creds + "New credential…".const credOptions = [- { value: MANAGED, label: 'Managed · billed to credits' },+ { value: MANAGED, label: 'Managed · no key needed' },...providerCreds.map((c) => ({value: c.id,label: `${c.name || 'Unnamed'}${c.last4 ? ` ·· ${c.last4}` : ''}${@@ -125,7 +126,7 @@ export default function Agents() {// - else → pin the chosen existing credential.let credentialId: string | undefinedif (credChoice === MANAGED) {- credentialId = MANAGED // run via OpenComputer, billed to credits — no key+ credentialId = MANAGED // run via OpenComputer, no BYO key} else if (credChoice === NEW_CRED) {const cred = await createCredential({key: newCredKey.trim(),