@foldrun/core 24.13.0 → 25.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,7 +50,7 @@ export function approveLinkToken(tenant, workspace, runId, link) {
50
50
  * install's public origin. `decision=reject` pre-selects; a GET never
51
51
  * decides. */
52
52
  export function approveLinkPath(tenant, workspace, runId, link) {
53
- return `/api/approve/${tenant}/${workspace}/${runId}?token=${approveLinkToken(tenant, workspace, runId, link)}`;
53
+ return `/v1/approve/${tenant}/${workspace}/${runId}?token=${approveLinkToken(tenant, workspace, runId, link)}`;
54
54
  }
55
55
  const same = (a, b) => a.length === b.length && crypto.timingSafeEqual(Buffer.from(a), Buffer.from(b));
56
56
  /**
@@ -419,7 +419,7 @@ const PROTECTED_BASH = [
419
419
  * A web address, which names a place on a server rather than in the workspace.
420
420
  *
421
421
  * The protected-path patterns match a bare `runs/`, so an agent calling the
422
- * platform's own API — `curl https://…/api/workspaces/x/runs/<id>` — was told
422
+ * platform's own API — `curl https://…/v1/workspaces/x/runs/<id>` — was told
423
423
  * it was reading the run journal. The weekly retros read their week through
424
424
  * that API and were refused on 9 Oct 2026. Only http(s): a `file://` URL is a
425
425
  * path, and stays checked.
@@ -8,11 +8,12 @@ export declare function hostEnvAllowed(name: string): boolean;
8
8
  export declare function hostSafeEnv(from?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
9
9
  /**
10
10
  * Where this install's own API answers, for a step to call: `FOLDRUN_API_URL`
11
- * when the operator set it, else `FOLDRUN_PUBLIC_URL` + `/api`. Undefined on a
12
- * laptop with neither.
11
+ * when the operator set it, else the API host (`FOLDRUN_PUBLIC_API_URL`) or
12
+ * the install's own address (`FOLDRUN_PUBLIC_URL`), + `/v1` (23 Nov 2026:
13
+ * every route is /v1). Undefined on a laptop with none.
13
14
  *
14
15
  * A desk that reads its own run history used to write the host into its
15
- * files (`https://dev.foldrun.io/api`), so the same workspace pointed at the
16
+ * files (`https://dev.foldrun.io/api`, an address since retired), so the same workspace pointed at the
16
17
  * wrong server the day it moved. Now a script reads `$FOLDRUN_API_URL` and an
17
18
  * `apis:` entry writes `base: ${FOLDRUN_API_URL}`.
18
19
  */
@@ -53,11 +53,12 @@ export function hostSafeEnv(from = process.env) {
53
53
  }
54
54
  /**
55
55
  * Where this install's own API answers, for a step to call: `FOLDRUN_API_URL`
56
- * when the operator set it, else `FOLDRUN_PUBLIC_URL` + `/api`. Undefined on a
57
- * laptop with neither.
56
+ * when the operator set it, else the API host (`FOLDRUN_PUBLIC_API_URL`) or
57
+ * the install's own address (`FOLDRUN_PUBLIC_URL`), + `/v1` (23 Nov 2026:
58
+ * every route is /v1). Undefined on a laptop with none.
58
59
  *
59
60
  * A desk that reads its own run history used to write the host into its
60
- * files (`https://dev.foldrun.io/api`), so the same workspace pointed at the
61
+ * files (`https://dev.foldrun.io/api`, an address since retired), so the same workspace pointed at the
61
62
  * wrong server the day it moved. Now a script reads `$FOLDRUN_API_URL` and an
62
63
  * `apis:` entry writes `base: ${FOLDRUN_API_URL}`.
63
64
  */
@@ -65,8 +66,8 @@ export function platformApiUrl(from = process.env) {
65
66
  const explicit = from.FOLDRUN_API_URL?.trim();
66
67
  if (explicit)
67
68
  return explicit.replace(/\/+$/, "");
68
- const origin = from.FOLDRUN_PUBLIC_URL?.trim();
69
- return origin ? `${origin.replace(/\/+$/, "")}/api` : undefined;
69
+ const origin = from.FOLDRUN_PUBLIC_API_URL?.trim() || from.FOLDRUN_PUBLIC_URL?.trim();
70
+ return origin ? `${origin.replace(/\/+$/, "")}/v1` : undefined;
70
71
  }
71
72
  /** The install's own addresses an `apis:` base may name. Not secrets: they
72
73
  * are printed in the prompt as the tool's base URL. */
package/dist/src/mail.js CHANGED
@@ -157,7 +157,7 @@ export function unsubscribeLinks(claim, now = Date.now()) {
157
157
  if (!base)
158
158
  return null;
159
159
  const token = encodeURIComponent(unsubscribeToken(claim, now));
160
- return { page: `${base}/unsubscribe?token=${token}`, oneClick: `${base}/api/unsubscribe?token=${token}` };
160
+ return { page: `${base}/unsubscribe?token=${token}`, oneClick: `${base}/v1/unsubscribe?token=${token}` };
161
161
  }
162
162
  /** The RFC 8058 pair, for a mail whose category may be turned off. */
163
163
  export function unsubscribeHeaders(claim, now = Date.now()) {
@@ -27,9 +27,8 @@ export declare const ACCOUNT_MODEL_SECRETS: {
27
27
  * reader (getSecret without a workspace). */
28
28
  export declare function accountModelBlock(read: (name: string) => string | null): Record<string, unknown> | undefined;
29
29
  /** A Claude login token (`claude setup-token`, sk-ant-oat…), not an API key.
30
- * Anthropic's terms do not let a third-party product run customers on
31
- * claude.ai logins, so on a hosted platform only the operator's own
32
- * accounts may; a customer's key must be an API key. */
30
+ * An account may set one as its model key — its own claude.ai subscription —
31
+ * the same as any provider key. */
33
32
  export declare function isClaudeLoginToken(value: string | null | undefined): boolean;
34
33
  /**
35
34
  * The variables a step's own model call is made with: the credential, the
@@ -60,7 +60,7 @@ export function credentialLine(c) {
60
60
  //
61
61
  // An account brings its own model key without writing a provider: block:
62
62
  // three secrets in the ACCOUNT vault (set from Settings → Models, the API's
63
- // /api/account/model, or `foldrun account model set`). A provider: block at any
63
+ // /v1/account/model, or `foldrun account model set`). A provider: block at any
64
64
  // level still wins; this is what a step falls to when none names one, before
65
65
  // the platform's own credential.
66
66
  /** Why a step or a call that names its own model endpoint (`provider:`)
@@ -93,9 +93,8 @@ export function accountModelBlock(read) {
93
93
  return block;
94
94
  }
95
95
  /** A Claude login token (`claude setup-token`, sk-ant-oat…), not an API key.
96
- * Anthropic's terms do not let a third-party product run customers on
97
- * claude.ai logins, so on a hosted platform only the operator's own
98
- * accounts may; a customer's key must be an API key. */
96
+ * An account may set one as its model key — its own claude.ai subscription —
97
+ * the same as any provider key. */
99
98
  export function isClaudeLoginToken(value) {
100
99
  return typeof value === "string" && /^sk-ant-oat\d*-/.test(value.trim());
101
100
  }
@@ -9,7 +9,7 @@ import { accountDir, workspaceDir, parseProvider, providerEnvFor } from "./store
9
9
  import { readAgentsMd } from "./runner.js";
10
10
  import { getSecret } from "./secrets.js";
11
11
  import { platform, hostUrlProblem } from "./platform.js";
12
- import { accountModelBlock, isClaudeLoginToken, OWN_KEYS_OFF } from "./model-credential.js";
12
+ import { accountModelBlock, OWN_KEYS_OFF } from "./model-credential.js";
13
13
  import { providerPreset } from "./providers.js";
14
14
  import { startTranslator, translatorSpecFor } from "./translator.js";
15
15
  import { supplyProviderBlock } from "./model-supply.js";
@@ -85,9 +85,6 @@ export function accountModelEnv(tenant, workspace, platformEnv) {
85
85
  const token = sub(spec.token);
86
86
  if (token.includes("${"))
87
87
  throw new ModelKeyError("the provider's token secret is not set — `foldrun secrets` sets it", 422);
88
- if (!platform.platformKeyAllowed(tenant) && isClaudeLoginToken(token)) {
89
- throw new ModelKeyError("model key: a Claude login token (sk-ant-oat…) cannot be used here — use an API key from your provider", 422);
90
- }
91
88
  const headers = Object.fromEntries(Object.entries(spec.headers).map(([k, v]) => [k, sub(v)]));
92
89
  const preset = providerPreset(spec.name);
93
90
  return {
@@ -8,7 +8,7 @@
8
8
  //
9
9
  // The roles:
10
10
  // client an agent reaches Google, Slack, a bank — foldrun holds the token
11
- // server an AI app signs in to /api/mcp — foldrun issues the token
11
+ // server an AI app signs in to /v1/mcp — foldrun issues the token
12
12
  const core = (file, test) => ({ repo: "foldrun-core", file, test });
13
13
  const platform = (file, test) => ({ repo: "foldrun-platform", file, test });
14
14
  const web = (file, test) => ({ repo: "foldrun-web", file, test });
@@ -110,10 +110,10 @@ export const OAUTH_CAPABILITIES = [
110
110
  id: "client.ciba", role: "client", title: "Client-initiated backchannel authentication", spec: "OpenID CIBA",
111
111
  status: "not-needed", note: "No provider an agent needs uses it.",
112
112
  },
113
- // ------------------------------------------------------------ server (/api/mcp)
113
+ // ------------------------------------------------------------ server (/v1/mcp)
114
114
  {
115
115
  id: "server.authorization-code-pkce", role: "server", title: "Authorization code with PKCE (S256)", spec: "OAuth 2.1, MCP authorization",
116
- status: "supported", note: "How claude.ai and other AI apps sign in to /api/mcp.",
116
+ status: "supported", note: "How claude.ai and other AI apps sign in to /v1/mcp.",
117
117
  proof: [web("tests/mcp-oauth.test.ts", "the code: PKCE, once, for its own app and redirect"), web("tests/mcp-sdk-oauth.test.ts", "the MCP SDK: 401 → discovery → registration")],
118
118
  },
119
119
  {
@@ -138,8 +138,8 @@ export const OAUTH_CAPABILITIES = [
138
138
  },
139
139
  {
140
140
  id: "server.resource-indicators", role: "server", title: "Resource indicators", spec: "RFC 8707",
141
- status: "supported", note: "Tokens are bound to /api/mcp.",
142
- proof: [web("tests/mcp-oauth.test.ts", "the access token opens /api/mcp and its tools")],
141
+ status: "supported", note: "Tokens are bound to /v1/mcp.",
142
+ proof: [web("tests/mcp-oauth.test.ts", "the access token opens /v1/mcp and its tools")],
143
143
  },
144
144
  {
145
145
  id: "server.iss-parameter", role: "server", title: "Issuer in the authorization response", spec: "RFC 9207",
@@ -148,7 +148,7 @@ export const OAUTH_CAPABILITIES = [
148
148
  },
149
149
  {
150
150
  id: "server.revocation", role: "server", title: "Revocation endpoint", spec: "RFC 7009",
151
- status: "supported", note: "`POST /api/mcp/oauth/revoke`: an app ends its own connection.",
151
+ status: "supported", note: "`POST /v1/mcp/oauth/revoke`: an app ends its own connection.",
152
152
  proof: [web("tests/mcp-oauth.test.ts", "revocation (RFC 7009): advertised")],
153
153
  },
154
154
  {
@@ -522,7 +522,7 @@ export declare function userAgentDrift(ua: string | undefined, chrome: string |
522
522
  * `check` prints these as warnings and the deploy reports them beside its
523
523
  * outward-gate warnings. `opts.chrome` / `opts.chromium`: the runner image's
524
524
  * Google Chrome and Playwright Chromium versions, when known
525
- * (FOLDRUN_RUNNER_ENGINES on the platform, /api/version from the CLI); an
525
+ * (FOLDRUN_RUNNER_ENGINES on the platform, /v1/version from the CLI); an
526
526
  * engine whose version is unknown is not compared.
527
527
  */
528
528
  export declare function webWarnings(front: Record<string, unknown>, opts?: {
@@ -1151,7 +1151,7 @@ export function userAgentDrift(ua, chrome, where, browser = "Chrome") {
1151
1151
  * `check` prints these as warnings and the deploy reports them beside its
1152
1152
  * outward-gate warnings. `opts.chrome` / `opts.chromium`: the runner image's
1153
1153
  * Google Chrome and Playwright Chromium versions, when known
1154
- * (FOLDRUN_RUNNER_ENGINES on the platform, /api/version from the CLI); an
1154
+ * (FOLDRUN_RUNNER_ENGINES on the platform, /v1/version from the CLI); an
1155
1155
  * engine whose version is unknown is not compared.
1156
1156
  */
1157
1157
  export function webWarnings(front, opts = {}) {
@@ -22,7 +22,7 @@ import { eventUrl } from "./webhook.js";
22
22
  import { runStepInContainer, resolveResources, memoryGiB, heldCores, killRunSandboxes, classDisk } from "./run-container.js";
23
23
  import { readResources, hasOverride, anyMemoryMi } from "./resources.js";
24
24
  import { hostSafeEnv, platformApiUrl } from "./host-env.js";
25
- import { resolveModelCredential, credentialLine, accountModelBlock, isClaudeLoginToken, isModelEnvName, DECLARED_ENV_PREFIX, OWN_KEYS_OFF } from "./model-credential.js";
25
+ import { resolveModelCredential, credentialLine, accountModelBlock, isModelEnvName, DECLARED_ENV_PREFIX, OWN_KEYS_OFF } from "./model-credential.js";
26
26
  import { parseJudge } from "./judge-verdict.js";
27
27
  import { validateSchema, describeSchemaErrors, looksLikeSchema } from "./json-schema.js";
28
28
  import { EGRESS_ENV, MODEL_KEY_NAME, addGrant, grantModelKey, hostOf, placeholderNames, proxyModelEnv, unsubstitute } from "./egress.js";
@@ -2494,7 +2494,6 @@ conversation) {
2494
2494
  // before a sandbox is rented, with what to do about it — not run on the
2495
2495
  // operator's key, and not failed later by a provider.
2496
2496
  if (!platform.platformKeyAllowed(tenant)) {
2497
- const own = Object.values(providerSecrets).concat(Object.values(providerEnv));
2498
2497
  if (primaryOnPlatform) {
2499
2498
  push("error", `no model key: this account runs on its own API key, and none is set. Add one in Settings → Models ` +
2500
2499
  `(or \`foldrun account model set <provider> --key …\`), or write a provider: block in AGENTS.md`);
@@ -2502,12 +2501,6 @@ conversation) {
2502
2501
  save();
2503
2502
  return;
2504
2503
  }
2505
- if (own.some((v) => isClaudeLoginToken(v))) {
2506
- push("error", "model key: a Claude login token (sk-ant-oat…) cannot be used here — use an API key from your provider");
2507
- step.status = "failed";
2508
- save();
2509
- return;
2510
- }
2511
2504
  }
2512
2505
  // A step in core's own Docker container (self-hosting) has no machine
2513
2506
  // login to fall back to: with no credential at all it could only fail at
@@ -340,8 +340,8 @@ on a server, use the HTTP API — every route takes the same API key
340
340
  session, and refuses without one.
341
341
 
342
342
  \`\`\`sh
343
- export FOLDRUN_TOKEN=... FOLDRUN_URL=https://your-server WS=my-workspace
344
- api() { p=$1; shift; curl -sS -H "authorization: Bearer $FOLDRUN_TOKEN" "$FOLDRUN_URL/api/$p" "$@"; }
343
+ export FOLDRUN_TOKEN=... FOLDRUN_URL=https://your-api-server WS=my-workspace
344
+ api() { p=$1; shift; curl -sS -H "authorization: Bearer $FOLDRUN_TOKEN" "$FOLDRUN_URL/v1/$p" "$@"; }
345
345
 
346
346
  api workspaces/$WS/runs # recent runs, newest first
347
347
  api workspaces/$WS/runs/<id> # the full trail of one
@@ -349,7 +349,7 @@ api workspaces/$WS/runs/<id>/stream # follow a live one (SSE)
349
349
  api workspaces/$WS/flows/<flow>/run -X POST # start one
350
350
  \`\`\`
351
351
 
352
- All of it, \`/api/workspaces/<workspace>\` unless noted:
352
+ All of it, \`/v1/workspaces/<workspace>\` unless noted:
353
353
 
354
354
  | Route | Methods | For |
355
355
  |---|---|---|
@@ -385,21 +385,21 @@ All of it, \`/api/workspaces/<workspace>\` unless noted:
385
385
  | \`/check\` | GET | what \`foldrun check\` says about the deployed copy, as findings with rule ids (\`?security=1\`) |
386
386
  | \`/assistant\` | POST | ask the assistant, or have it write agents, flows, tools and skills — from the docs only; proposals come back, nothing is written |
387
387
 
388
- Account-level, outside \`/workspaces\`: \`/api/secrets\`, \`/api/keys\`, \`/api/schedule\`,
389
- \`/api/approvals\`, \`/api/issues\` (what went wrong, open until resolved), \`/api/usage\`, \`/api/library/<kind>\`, \`/api/team\`, \`/api/billing\`,
390
- \`/api/me/notifications\` (what mail you get; a key acts for whoever minted it),
391
- \`/api/me/inbox\` (what waits on you: gates, questions, issues, proposed fixes, your failed runs),
392
- \`/api/mcp\` (this account as MCP tools for an AI app such as Claude Desktop or Cursor — an API key; \`foldrun mcp\` serves the same over stdio, \`foldrun docs mcp\`),
393
- \`/api/account/backups\` (snapshots, restore requests), \`/api/me/onboarding\` (getting started),
394
- \`/api/healthz\` and \`/api/version\` (open), \`/api/changelog\` (release notes)
395
- and \`/api/metrics\` (Prometheus). Outside \`/api\`: \`/a2a/<account>/<ws>/flows/<flow>\`
388
+ Account-level, outside \`/workspaces\`: \`/v1/secrets\`, \`/v1/keys\`, \`/v1/schedule\`,
389
+ \`/v1/approvals\`, \`/v1/issues\` (what went wrong, open until resolved), \`/v1/account/usage\`, \`/v1/library/<kind>\`, \`/v1/team\`, \`/v1/billing\`,
390
+ \`/v1/me/notifications\` (what mail you get; a key acts for whoever minted it),
391
+ \`/v1/me/inbox\` (what waits on you: gates, questions, issues, proposed fixes, your failed runs),
392
+ \`/v1/mcp\` (this account as MCP tools for an AI app such as Claude Desktop or Cursor — an API key; \`foldrun mcp\` serves the same over stdio, \`foldrun docs mcp\`),
393
+ \`/v1/account/backups\` (snapshots, restore requests), \`/v1/me/onboarding\` (getting started),
394
+ \`/v1/healthz\` and \`/v1/version\` (open), \`/v1/changelog\` (release notes)
395
+ and \`/v1/metrics\` (Prometheus). Outside \`/v1\`: \`/a2a/<account>/<ws>/flows/<flow>\`
396
396
  (a published flow's agent card and A2A 1.0 JSON-RPC endpoint — an A2A key only, \`foldrun docs a2a\`).
397
397
 
398
398
  Every call answers — and the CLI sends — \`Foldrun-Version: YYYY-MM-DD\` (dated API
399
399
  versions; an account pin in Settings → API keys → API), \`X-RateLimit-*\` headers (a \`429\`
400
400
  carries \`Retry-After\`), and writes that start work take an \`Idempotency-Key\`
401
401
  (a retry with the same key replays the first answer). The whole surface as
402
- OpenAPI 3.1: \`/api/openapi.json\` (open), or \`foldrun api spec --out openapi.json\`.
402
+ OpenAPI 3.1: \`/v1/openapi.json\` (open), or \`foldrun api spec --out openapi.json\`.
403
403
 
404
404
  Debugging a failed run is usually: \`runs\` to find it, \`runs/<id>\` to read which
405
405
  step failed and what it cost, fix the markdown, \`deploy\`, then \`rerun\`.
package/dist/src/store.js CHANGED
@@ -2515,7 +2515,7 @@ export function writeWorkspaceFile(tenant, workspace, rel, content, meta = {}) {
2515
2515
  // recursive, so until 30 Oct 2026 a write to a name that did not exist
2516
2516
  // created that workspace — with workspace:write alone, past the
2517
2517
  // workspace:manage role and the plan's workspace count that POST
2518
- // /api/workspaces, deploy and import apply. Those create through
2518
+ // /v1/workspaces, deploy and import apply. Those create through
2519
2519
  // saveWorkspace / applyImport, not through here.
2520
2520
  if (!fs.existsSync(dir))
2521
2521
  throw Object.assign(new Error(`project ${workspace} not found`), { status: 404 });
@@ -75,7 +75,7 @@ export function webhookToken(tenant, workspace, flow) {
75
75
  return crypto.createHmac("sha256", installKey()).update(identity).digest("hex").slice(0, 32);
76
76
  }
77
77
  export function webhookPath(tenant, workspace, flow) {
78
- return `/api/hooks/${tenant}/${workspace}/${flow}?token=${webhookToken(tenant, workspace, flow)}`;
78
+ return `/v1/hooks/${tenant}/${workspace}/${flow}?token=${webhookToken(tenant, workspace, flow)}`;
79
79
  }
80
80
  // ---------- one-click approval ----------
81
81
  /**
@@ -119,7 +119,7 @@ export function eventToken(tenant, workspace, runId, gate) {
119
119
  * knows its origin, a path otherwise. With `gate`, that step's own URL
120
120
  * (`&step=<index>`); the route finds the park's moment on the record. */
121
121
  export function eventUrl(tenant, workspace, runId, gate) {
122
- const p = `/api/events/${tenant}/${workspace}/${runId}?token=${eventToken(tenant, workspace, runId, gate)}${gate ? `&step=${gate.step}` : ""}`;
122
+ const p = `/v1/events/${tenant}/${workspace}/${runId}?token=${eventToken(tenant, workspace, runId, gate)}${gate ? `&step=${gate.step}` : ""}`;
123
123
  const base = publicUrl();
124
124
  return base ? `${base}${p}` : p;
125
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldrun/core",
3
- "version": "24.13.0",
3
+ "version": "25.0.0",
4
4
  "description": "Agents are just folders. The format, the runner, the checks.",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "type": "module",
package/src/approvals.ts CHANGED
@@ -107,7 +107,7 @@ export function approveLinkPath(
107
107
  runId: string,
108
108
  link: { step: number; expiresAt: number; approver?: string | null },
109
109
  ): string {
110
- return `/api/approve/${tenant}/${workspace}/${runId}?token=${approveLinkToken(tenant, workspace, runId, link)}`;
110
+ return `/v1/approve/${tenant}/${workspace}/${runId}?token=${approveLinkToken(tenant, workspace, runId, link)}`;
111
111
  }
112
112
 
113
113
  const same = (a: string, b: string) => a.length === b.length && crypto.timingSafeEqual(Buffer.from(a), Buffer.from(b));
package/src/confine.ts CHANGED
@@ -480,7 +480,7 @@ const PROTECTED_BASH: { re: RegExp; writeOnly: boolean; reason: string }[] = [
480
480
  * A web address, which names a place on a server rather than in the workspace.
481
481
  *
482
482
  * The protected-path patterns match a bare `runs/`, so an agent calling the
483
- * platform's own API — `curl https://…/api/workspaces/x/runs/<id>` — was told
483
+ * platform's own API — `curl https://…/v1/workspaces/x/runs/<id>` — was told
484
484
  * it was reading the run journal. The weekly retros read their week through
485
485
  * that API and were refused on 9 Oct 2026. Only http(s): a `file://` URL is a
486
486
  * path, and stays checked.
package/src/host-env.ts CHANGED
@@ -57,19 +57,20 @@ export function hostSafeEnv(from: NodeJS.ProcessEnv = process.env): NodeJS.Proce
57
57
 
58
58
  /**
59
59
  * Where this install's own API answers, for a step to call: `FOLDRUN_API_URL`
60
- * when the operator set it, else `FOLDRUN_PUBLIC_URL` + `/api`. Undefined on a
61
- * laptop with neither.
60
+ * when the operator set it, else the API host (`FOLDRUN_PUBLIC_API_URL`) or
61
+ * the install's own address (`FOLDRUN_PUBLIC_URL`), + `/v1` (23 Nov 2026:
62
+ * every route is /v1). Undefined on a laptop with none.
62
63
  *
63
64
  * A desk that reads its own run history used to write the host into its
64
- * files (`https://dev.foldrun.io/api`), so the same workspace pointed at the
65
+ * files (`https://dev.foldrun.io/api`, an address since retired), so the same workspace pointed at the
65
66
  * wrong server the day it moved. Now a script reads `$FOLDRUN_API_URL` and an
66
67
  * `apis:` entry writes `base: ${FOLDRUN_API_URL}`.
67
68
  */
68
69
  export function platformApiUrl(from: NodeJS.ProcessEnv = process.env): string | undefined {
69
70
  const explicit = from.FOLDRUN_API_URL?.trim();
70
71
  if (explicit) return explicit.replace(/\/+$/, "");
71
- const origin = from.FOLDRUN_PUBLIC_URL?.trim();
72
- return origin ? `${origin.replace(/\/+$/, "")}/api` : undefined;
72
+ const origin = from.FOLDRUN_PUBLIC_API_URL?.trim() || from.FOLDRUN_PUBLIC_URL?.trim();
73
+ return origin ? `${origin.replace(/\/+$/, "")}/v1` : undefined;
73
74
  }
74
75
 
75
76
  /** The install's own addresses an `apis:` base may name. Not secrets: they
package/src/mail.ts CHANGED
@@ -197,7 +197,7 @@ export function unsubscribeLinks(claim: Omit<UnsubscribeClaim, "expiresAt">, now
197
197
  const base = publicUrl();
198
198
  if (!base) return null;
199
199
  const token = encodeURIComponent(unsubscribeToken(claim, now));
200
- return { page: `${base}/unsubscribe?token=${token}`, oneClick: `${base}/api/unsubscribe?token=${token}` };
200
+ return { page: `${base}/unsubscribe?token=${token}`, oneClick: `${base}/v1/unsubscribe?token=${token}` };
201
201
  }
202
202
 
203
203
  /** The RFC 8058 pair, for a mail whose category may be turned off. */
@@ -75,7 +75,7 @@ export function credentialLine(c: ModelCredential): { type: "info" | "error"; te
75
75
  //
76
76
  // An account brings its own model key without writing a provider: block:
77
77
  // three secrets in the ACCOUNT vault (set from Settings → Models, the API's
78
- // /api/account/model, or `foldrun account model set`). A provider: block at any
78
+ // /v1/account/model, or `foldrun account model set`). A provider: block at any
79
79
  // level still wins; this is what a step falls to when none names one, before
80
80
  // the platform's own credential.
81
81
 
@@ -109,9 +109,8 @@ export function accountModelBlock(read: (name: string) => string | null): Record
109
109
  }
110
110
 
111
111
  /** A Claude login token (`claude setup-token`, sk-ant-oat…), not an API key.
112
- * Anthropic's terms do not let a third-party product run customers on
113
- * claude.ai logins, so on a hosted platform only the operator's own
114
- * accounts may; a customer's key must be an API key. */
112
+ * An account may set one as its model key — its own claude.ai subscription —
113
+ * the same as any provider key. */
115
114
  export function isClaudeLoginToken(value: string | null | undefined): boolean {
116
115
  return typeof value === "string" && /^sk-ant-oat\d*-/.test(value.trim());
117
116
  }
package/src/model-env.ts CHANGED
@@ -10,7 +10,7 @@ import { accountDir, workspaceDir, parseProvider, providerEnvFor } from "./store
10
10
  import { readAgentsMd } from "./runner.ts";
11
11
  import { getSecret } from "./secrets.ts";
12
12
  import { platform, hostUrlProblem } from "./platform.ts";
13
- import { accountModelBlock, isClaudeLoginToken, OWN_KEYS_OFF } from "./model-credential.ts";
13
+ import { accountModelBlock, OWN_KEYS_OFF } from "./model-credential.ts";
14
14
  import { providerPreset } from "./providers.ts";
15
15
  import { startTranslator, translatorSpecFor, type TranslatorSpec } from "./translator.ts";
16
16
  import { supplyProviderBlock, type SupplyAnswer } from "./model-supply.ts";
@@ -100,9 +100,6 @@ export function accountModelEnv(
100
100
  text.replace(/\$\{([A-Z][A-Z0-9_]*)\}/g, (whole, name) => getSecret(tenant, name, workspace)?.value ?? whole);
101
101
  const token = sub(spec.token);
102
102
  if (token.includes("${")) throw new ModelKeyError("the provider's token secret is not set — `foldrun secrets` sets it", 422);
103
- if (!platform.platformKeyAllowed(tenant) && isClaudeLoginToken(token)) {
104
- throw new ModelKeyError("model key: a Claude login token (sk-ant-oat…) cannot be used here — use an API key from your provider", 422);
105
- }
106
103
  const headers = Object.fromEntries(Object.entries(spec.headers).map(([k, v]) => [k, sub(v)]));
107
104
  const preset = providerPreset(spec.name);
108
105
  return {
@@ -8,7 +8,7 @@
8
8
  //
9
9
  // The roles:
10
10
  // client an agent reaches Google, Slack, a bank — foldrun holds the token
11
- // server an AI app signs in to /api/mcp — foldrun issues the token
11
+ // server an AI app signs in to /v1/mcp — foldrun issues the token
12
12
 
13
13
  export type OAuthRole = "client" | "server";
14
14
  export type OAuthStatus = "supported" | "planned" | "refused" | "not-needed";
@@ -136,10 +136,10 @@ export const OAUTH_CAPABILITIES: OAuthCapability[] = [
136
136
  id: "client.ciba", role: "client", title: "Client-initiated backchannel authentication", spec: "OpenID CIBA",
137
137
  status: "not-needed", note: "No provider an agent needs uses it.",
138
138
  },
139
- // ------------------------------------------------------------ server (/api/mcp)
139
+ // ------------------------------------------------------------ server (/v1/mcp)
140
140
  {
141
141
  id: "server.authorization-code-pkce", role: "server", title: "Authorization code with PKCE (S256)", spec: "OAuth 2.1, MCP authorization",
142
- status: "supported", note: "How claude.ai and other AI apps sign in to /api/mcp.",
142
+ status: "supported", note: "How claude.ai and other AI apps sign in to /v1/mcp.",
143
143
  proof: [web("tests/mcp-oauth.test.ts", "the code: PKCE, once, for its own app and redirect"), web("tests/mcp-sdk-oauth.test.ts", "the MCP SDK: 401 → discovery → registration")],
144
144
  },
145
145
  {
@@ -164,8 +164,8 @@ export const OAUTH_CAPABILITIES: OAuthCapability[] = [
164
164
  },
165
165
  {
166
166
  id: "server.resource-indicators", role: "server", title: "Resource indicators", spec: "RFC 8707",
167
- status: "supported", note: "Tokens are bound to /api/mcp.",
168
- proof: [web("tests/mcp-oauth.test.ts", "the access token opens /api/mcp and its tools")],
167
+ status: "supported", note: "Tokens are bound to /v1/mcp.",
168
+ proof: [web("tests/mcp-oauth.test.ts", "the access token opens /v1/mcp and its tools")],
169
169
  },
170
170
  {
171
171
  id: "server.iss-parameter", role: "server", title: "Issuer in the authorization response", spec: "RFC 9207",
@@ -174,7 +174,7 @@ export const OAUTH_CAPABILITIES: OAuthCapability[] = [
174
174
  },
175
175
  {
176
176
  id: "server.revocation", role: "server", title: "Revocation endpoint", spec: "RFC 7009",
177
- status: "supported", note: "`POST /api/mcp/oauth/revoke`: an app ends its own connection.",
177
+ status: "supported", note: "`POST /v1/mcp/oauth/revoke`: an app ends its own connection.",
178
178
  proof: [web("tests/mcp-oauth.test.ts", "revocation (RFC 7009): advertised")],
179
179
  },
180
180
  {
package/src/providers.ts CHANGED
@@ -1470,7 +1470,7 @@ export function userAgentDrift(ua: string | undefined, chrome: string | null | u
1470
1470
  * `check` prints these as warnings and the deploy reports them beside its
1471
1471
  * outward-gate warnings. `opts.chrome` / `opts.chromium`: the runner image's
1472
1472
  * Google Chrome and Playwright Chromium versions, when known
1473
- * (FOLDRUN_RUNNER_ENGINES on the platform, /api/version from the CLI); an
1473
+ * (FOLDRUN_RUNNER_ENGINES on the platform, /v1/version from the CLI); an
1474
1474
  * engine whose version is unknown is not compared.
1475
1475
  */
1476
1476
  export function webWarnings(front: Record<string, unknown>, opts: { chrome?: string | null; chromium?: string | null } = {}): string[] {
package/src/runner.ts CHANGED
@@ -24,7 +24,7 @@ import { eventUrl } from "./webhook.ts";
24
24
  import { runStepInContainer, resolveResources, memoryGiB, heldCores, killRunSandboxes, classDisk, type StepTiming } from "./run-container.ts";
25
25
  import { readResources, hasOverride, anyMemoryMi } from "./resources.ts";
26
26
  import { hostSafeEnv, platformApiUrl } from "./host-env.ts";
27
- import { resolveModelCredential, credentialLine, accountModelBlock, isClaudeLoginToken, isModelEnvName, DECLARED_ENV_PREFIX, OWN_KEYS_OFF } from "./model-credential.ts";
27
+ import { resolveModelCredential, credentialLine, accountModelBlock, isModelEnvName, DECLARED_ENV_PREFIX, OWN_KEYS_OFF } from "./model-credential.ts";
28
28
  import { parseJudge } from "./judge-verdict.ts";
29
29
  import { validateSchema, describeSchemaErrors, looksLikeSchema } from "./json-schema.ts";
30
30
  import { EGRESS_ENV, MODEL_KEY_NAME, addGrant, grantModelKey, hostOf, placeholderNames, proxyModelEnv, unsubstitute, type EgressGrant } from "./egress.ts";
@@ -2694,7 +2694,6 @@ async function runStepBody(
2694
2694
  // before a sandbox is rented, with what to do about it — not run on the
2695
2695
  // operator's key, and not failed later by a provider.
2696
2696
  if (!platform.platformKeyAllowed(tenant)) {
2697
- const own = Object.values(providerSecrets).concat(Object.values(providerEnv));
2698
2697
  if (primaryOnPlatform) {
2699
2698
  push(
2700
2699
  "error",
@@ -2705,12 +2704,6 @@ async function runStepBody(
2705
2704
  save();
2706
2705
  return;
2707
2706
  }
2708
- if (own.some((v) => isClaudeLoginToken(v))) {
2709
- push("error", "model key: a Claude login token (sk-ant-oat…) cannot be used here — use an API key from your provider");
2710
- step.status = "failed";
2711
- save();
2712
- return;
2713
- }
2714
2707
  }
2715
2708
  // A step in core's own Docker container (self-hosting) has no machine
2716
2709
  // login to fall back to: with no credential at all it could only fail at
package/src/starter.ts CHANGED
@@ -356,8 +356,8 @@ on a server, use the HTTP API — every route takes the same API key
356
356
  session, and refuses without one.
357
357
 
358
358
  \`\`\`sh
359
- export FOLDRUN_TOKEN=... FOLDRUN_URL=https://your-server WS=my-workspace
360
- api() { p=$1; shift; curl -sS -H "authorization: Bearer $FOLDRUN_TOKEN" "$FOLDRUN_URL/api/$p" "$@"; }
359
+ export FOLDRUN_TOKEN=... FOLDRUN_URL=https://your-api-server WS=my-workspace
360
+ api() { p=$1; shift; curl -sS -H "authorization: Bearer $FOLDRUN_TOKEN" "$FOLDRUN_URL/v1/$p" "$@"; }
361
361
 
362
362
  api workspaces/$WS/runs # recent runs, newest first
363
363
  api workspaces/$WS/runs/<id> # the full trail of one
@@ -365,7 +365,7 @@ api workspaces/$WS/runs/<id>/stream # follow a live one (SSE)
365
365
  api workspaces/$WS/flows/<flow>/run -X POST # start one
366
366
  \`\`\`
367
367
 
368
- All of it, \`/api/workspaces/<workspace>\` unless noted:
368
+ All of it, \`/v1/workspaces/<workspace>\` unless noted:
369
369
 
370
370
  | Route | Methods | For |
371
371
  |---|---|---|
@@ -401,21 +401,21 @@ All of it, \`/api/workspaces/<workspace>\` unless noted:
401
401
  | \`/check\` | GET | what \`foldrun check\` says about the deployed copy, as findings with rule ids (\`?security=1\`) |
402
402
  | \`/assistant\` | POST | ask the assistant, or have it write agents, flows, tools and skills — from the docs only; proposals come back, nothing is written |
403
403
 
404
- Account-level, outside \`/workspaces\`: \`/api/secrets\`, \`/api/keys\`, \`/api/schedule\`,
405
- \`/api/approvals\`, \`/api/issues\` (what went wrong, open until resolved), \`/api/usage\`, \`/api/library/<kind>\`, \`/api/team\`, \`/api/billing\`,
406
- \`/api/me/notifications\` (what mail you get; a key acts for whoever minted it),
407
- \`/api/me/inbox\` (what waits on you: gates, questions, issues, proposed fixes, your failed runs),
408
- \`/api/mcp\` (this account as MCP tools for an AI app such as Claude Desktop or Cursor — an API key; \`foldrun mcp\` serves the same over stdio, \`foldrun docs mcp\`),
409
- \`/api/account/backups\` (snapshots, restore requests), \`/api/me/onboarding\` (getting started),
410
- \`/api/healthz\` and \`/api/version\` (open), \`/api/changelog\` (release notes)
411
- and \`/api/metrics\` (Prometheus). Outside \`/api\`: \`/a2a/<account>/<ws>/flows/<flow>\`
404
+ Account-level, outside \`/workspaces\`: \`/v1/secrets\`, \`/v1/keys\`, \`/v1/schedule\`,
405
+ \`/v1/approvals\`, \`/v1/issues\` (what went wrong, open until resolved), \`/v1/account/usage\`, \`/v1/library/<kind>\`, \`/v1/team\`, \`/v1/billing\`,
406
+ \`/v1/me/notifications\` (what mail you get; a key acts for whoever minted it),
407
+ \`/v1/me/inbox\` (what waits on you: gates, questions, issues, proposed fixes, your failed runs),
408
+ \`/v1/mcp\` (this account as MCP tools for an AI app such as Claude Desktop or Cursor — an API key; \`foldrun mcp\` serves the same over stdio, \`foldrun docs mcp\`),
409
+ \`/v1/account/backups\` (snapshots, restore requests), \`/v1/me/onboarding\` (getting started),
410
+ \`/v1/healthz\` and \`/v1/version\` (open), \`/v1/changelog\` (release notes)
411
+ and \`/v1/metrics\` (Prometheus). Outside \`/v1\`: \`/a2a/<account>/<ws>/flows/<flow>\`
412
412
  (a published flow's agent card and A2A 1.0 JSON-RPC endpoint — an A2A key only, \`foldrun docs a2a\`).
413
413
 
414
414
  Every call answers — and the CLI sends — \`Foldrun-Version: YYYY-MM-DD\` (dated API
415
415
  versions; an account pin in Settings → API keys → API), \`X-RateLimit-*\` headers (a \`429\`
416
416
  carries \`Retry-After\`), and writes that start work take an \`Idempotency-Key\`
417
417
  (a retry with the same key replays the first answer). The whole surface as
418
- OpenAPI 3.1: \`/api/openapi.json\` (open), or \`foldrun api spec --out openapi.json\`.
418
+ OpenAPI 3.1: \`/v1/openapi.json\` (open), or \`foldrun api spec --out openapi.json\`.
419
419
 
420
420
  Debugging a failed run is usually: \`runs\` to find it, \`runs/<id>\` to read which
421
421
  step failed and what it cost, fix the markdown, \`deploy\`, then \`rerun\`.
package/src/store.ts CHANGED
@@ -3017,7 +3017,7 @@ export function writeWorkspaceFile(
3017
3017
  // recursive, so until 30 Oct 2026 a write to a name that did not exist
3018
3018
  // created that workspace — with workspace:write alone, past the
3019
3019
  // workspace:manage role and the plan's workspace count that POST
3020
- // /api/workspaces, deploy and import apply. Those create through
3020
+ // /v1/workspaces, deploy and import apply. Those create through
3021
3021
  // saveWorkspace / applyImport, not through here.
3022
3022
  if (!fs.existsSync(dir)) throw Object.assign(new Error(`project ${workspace} not found`), { status: 404 });
3023
3023
  const p = path.join(dir, assertEditablePath(rel));
package/src/webhook.ts CHANGED
@@ -93,7 +93,7 @@ export function webhookToken(tenant: string, workspace: string, flow: string): s
93
93
  }
94
94
 
95
95
  export function webhookPath(tenant: string, workspace: string, flow: string): string {
96
- return `/api/hooks/${tenant}/${workspace}/${flow}?token=${webhookToken(tenant, workspace, flow)}`;
96
+ return `/v1/hooks/${tenant}/${workspace}/${flow}?token=${webhookToken(tenant, workspace, flow)}`;
97
97
  }
98
98
 
99
99
  // ---------- one-click approval ----------
@@ -149,7 +149,7 @@ export function eventToken(tenant: string, workspace: string, runId: string, gat
149
149
  * knows its origin, a path otherwise. With `gate`, that step's own URL
150
150
  * (`&step=<index>`); the route finds the park's moment on the record. */
151
151
  export function eventUrl(tenant: string, workspace: string, runId: string, gate?: EventGate): string {
152
- const p = `/api/events/${tenant}/${workspace}/${runId}?token=${eventToken(tenant, workspace, runId, gate)}${gate ? `&step=${gate.step}` : ""}`;
152
+ const p = `/v1/events/${tenant}/${workspace}/${runId}?token=${eventToken(tenant, workspace, runId, gate)}${gate ? `&step=${gate.step}` : ""}`;
153
153
  const base = publicUrl();
154
154
  return base ? `${base}${p}` : p;
155
155
  }