The open-source agent harness - the runtime layer that turns an LLM into a working agent.
AGE-1733: add bearer ID-token support for auth (#138)
Heer Ambavidbd5992fdb86
diff --git a/.github/fern/generators.yml b/.github/fern/generators.ymlindex 65af56857..85bd8b05c 100644--- a/.github/fern/generators.yml+++ b/.github/fern/generators.yml@@ -7,8 +7,8 @@ readme:runtime that executes agent turns and streams them over Server-Sent Events.- The harness server has no built-in authentication, so point the client at- your own deployment's base URL.+ When auth is enabled on the server, pass an ID token via the optional `token`+ client option (`Authorization: Bearer`).# Fern keys this lookup on the stream flag, so the string form misses and fails.defaultEndpoint:method: POST@@ -56,6 +56,7 @@ groups:client: TrueForgenoSerdeLayer: falseomitUndefined: true+ optional-auth: truerequireBaseUrl: trueretainOriginalCasing: falseskipResponseValidation: truediff --git a/.github/fern/openapi/openapi.json b/.github/fern/openapi/openapi.jsonindex 7bc1a5f9d..4948d4399 100644--- a/.github/fern/openapi/openapi.json+++ b/.github/fern/openapi/openapi.json@@ -4041,10 +4041,18 @@],"type": "object"}+ },+ "securitySchemes": {+ "BearerAuth": {+ "bearerFormat": "JWT",+ "description": "ID token (`Authorization: Bearer <id_token>`). Required on protected routes. Browser sessions may use the HttpOnly `id_token` cookie instead.",+ "scheme": "bearer",+ "type": "http"+ }}},"info": {- "description": "HTTP API for the TrueForge agent server (`/api/v1`). Interactive docs are served at `/api/v1/docs` (OpenAPI JSON at `/api/v1/openapi.json`).\n\n**Authentication:** Standalone deployments (no OIDC) accept requests without credentials — middleware stamps a local default user. When OIDC is configured, browser login sets an httpOnly `id_token` cookie; protected routes read that cookie (not `Authorization: Bearer`). There is no built-in API-key scheme; pass custom headers only if your reverse proxy or IdP layer requires them.\n\nCovers DB-backed sessions, the agent registry, settings catalogs, and model/MCP/skill/sandbox providers.",+ "description": "HTTP API for the TrueForge agent server (`/api/v1`). Interactive docs are served at `/api/v1/docs` (OpenAPI JSON at `/api/v1/openapi.json`).\n\n**Authentication:** Standalone deployments (no OIDC) accept requests without credentials — middleware stamps a local default user. When OIDC is configured, protected routes require a valid `id_token` cookie or `Authorization: Bearer` ID token. There is no built-in API-key scheme; pass custom headers only if your reverse proxy or IdP layer requires them.\n\nCovers DB-backed sessions, the agent registry, settings catalogs, and model/MCP/skill/sandbox providers.","title": "TrueForge API","version": "0.1.0"},@@ -4426,7 +4434,7 @@},"/api/v1/auth/me": {"get": {- "description": "Returns the authenticated caller identity. When OIDC is configured this requires a valid session cookie (401 otherwise). Without OIDC, returns the default anonymous identity.",+ "description": "Returns the authenticated caller identity. When auth is enabled this requires a valid `id_token` cookie or `Authorization: Bearer` ID token (401 otherwise). When auth is disabled, returns the default identity.","responses": {"200": {"content": {@@ -4446,7 +4454,7 @@}}},- "description": "OIDC is configured and the request has no valid session cookie."+ "description": "Auth is enabled and the request has no valid cookie or Bearer ID token."}},"summary": "Current session",@@ -6697,5 +6705,10 @@}}},+ "security": [+ {+ "BearerAuth": []+ }+ ],"webhooks": {}}diff --git a/README.md b/README.mdindex 0ede8176b..176939b1d 100644--- a/README.md+++ b/README.md@@ -70,12 +70,12 @@ docker compose up --buildThen open [http://localhost:8791](http://localhost:8791).-| Configuration | Default | Description |-| ----------------------------------------------------------- | ----------------------- | --------------------------------------------------------------------- |-| `POSTGRES_USER` / `POSTGRES_PASSWORD` / `POSTGRES_DB` | `harness` (from `.env`) | Postgres credentials, read from `packages/server/.env`. |-| `PUBLIC_BASE_URL` | `http://localhost:8791` | Public origin, used for MCP OAuth callbacks. |-| Host ports | `8791`, `5433`, `6380` | App, Postgres, and Redis - offset so they don't clash with local dev. |-| `OIDC_ISSUER_URL` / `OIDC_CLIENT_ID` / `OIDC_CLIENT_SECRET` | unset | Optional: connect an identity provider. Unset = local admin identity. |+| Configuration | Default | Description |+| ----------------------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------ |+| `POSTGRES_USER` / `POSTGRES_PASSWORD` / `POSTGRES_DB` | `harness` (from `.env`) | Postgres credentials, read from `packages/server/.env`. |+| `PUBLIC_BASE_URL` | `http://localhost:8791` | Public origin, used for MCP OAuth callbacks. |+| Host ports | `8791`, `5433`, `6380` | App, Postgres, and Redis - offset so they don't clash with local dev. |+| `OIDC_ISSUER_URL` / `OIDC_CLIENT_ID` / `OIDC_CLIENT_SECRET` | unset | Optional IdP. Unset = local admin. When set, APIs accept the ID token via cookie or `Authorization: Bearer`. |Every environment variable is documented in [`packages/server/.env.example`](packages/server/.env.example).diff --git a/docs/api/use-agent.mdx b/docs/api/use-agent.mdxindex ef5829d7c..8f2812014 100644--- a/docs/api/use-agent.mdx+++ b/docs/api/use-agent.mdx@@ -25,12 +25,12 @@ const client = new TrueForge({baseUrl: process.env.TRUEFORGE_BASE_URL ?? 'http://localhost:8790',// Raise for long-running SSE turns (default is 60s).timeoutInSeconds: 600,- // Optional: pass whatever your deployment uses for auth.- // headers: { Authorization: `Bearer ${process.env.TRUEFORGE_TOKEN}` },+ // Optional: ID token when auth is enabled on the server.+ // token: process.env.TRUEFORGE_TOKEN,});```-The harness has no built-in API-key auth. Point `baseUrl` at your deployment (standalone default: `http://localhost:8790`). Pass `headers` when your reverse proxy or OIDC layer requires them.+When auth is enabled, pass `token` (Bearer ID token). When auth is disabled, omit it.## Create a sessiondiff --git a/docs/openapi.json b/docs/openapi.jsonindex 7bc1a5f9d..59b48eb5a 100644--- a/docs/openapi.json+++ b/docs/openapi.json@@ -4041,10 +4041,18 @@],"type": "object"}+ },+ "securitySchemes": {+ "BearerAuth": {+ "bearerFormat": "JWT",+ "description": "ID token (`Authorization: Bearer <id_token>`). Required on protected routes. Browser sessions may use the HttpOnly `id_token` cookie instead.",+ "scheme": "bearer",+ "type": "http"+ }}},"info": {- "description": "HTTP API for the TrueForge agent server (`/api/v1`). Interactive docs are served at `/api/v1/docs` (OpenAPI JSON at `/api/v1/openapi.json`).\n\n**Authentication:** Standalone deployments (no OIDC) accept requests without credentials — middleware stamps a local default user. When OIDC is configured, browser login sets an httpOnly `id_token` cookie; protected routes read that cookie (not `Authorization: Bearer`). There is no built-in API-key scheme; pass custom headers only if your reverse proxy or IdP layer requires them.\n\nCovers DB-backed sessions, the agent registry, settings catalogs, and model/MCP/skill/sandbox providers.",+ "description": "HTTP API for the TrueForge agent server (`/api/v1`). Interactive docs are served at `/api/v1/docs` (OpenAPI JSON at `/api/v1/openapi.json`).\n\n**Authentication:** Standalone deployments (no OIDC) accept requests without credentials — middleware stamps a local default user. When OIDC is configured, protected routes require a valid `id_token` cookie or `Authorization: Bearer` ID token. There is no built-in API-key scheme; pass custom headers only if your reverse proxy or IdP layer requires them.\n\nCovers DB-backed sessions, the agent registry, settings catalogs, and model/MCP/skill/sandbox providers.","title": "TrueForge API","version": "0.1.0"},@@ -4426,7 +4434,7 @@},"/api/v1/auth/me": {"get": {- "description": "Returns the authenticated caller identity. When OIDC is configured this requires a valid session cookie (401 otherwise). Without OIDC, returns the default anonymous identity.",+ "description": "Returns the authenticated caller identity. When auth is enabled this requires a valid `id_token` cookie or `Authorization: Bearer` ID token (401 otherwise). When auth is disabled, returns the default identity.","responses": {"200": {"content": {@@ -4446,7 +4454,7 @@}}},- "description": "OIDC is configured and the request has no valid session cookie."+ "description": "Auth is enabled and the request has no valid cookie or Bearer ID token."}},"summary": "Current session",@@ -6697,5 +6705,11 @@}}},+ "security": [+ {+ "BearerAuth": []+ },+ {}+ ],"webhooks": {}}diff --git a/packages/frontend/src/authSession.ts b/packages/frontend/src/authSession.tsindex aa3e2bd54..040087b3f 100644--- a/packages/frontend/src/authSession.ts+++ b/packages/frontend/src/authSession.ts@@ -24,7 +24,7 @@ export function resetOidcSessionCacheForTests(): void {/*** True when the current session is a browser OIDC login (`type: "oidc-connected"`).- * When OIDC is configured, unauthenticated callers get HTTP 401 from `/me`.+ * When auth is enabled, unauthenticated callers get HTTP 401 from `/me`.*/export async function isOidcConnectedSession(client: TrueForge = harnessClient): Promise<boolean> {const session = await client.auth.me();@@ -39,7 +39,7 @@ export async function logout(client: TrueForge = harnessClient): Promise<void> {/*** Pre-boot gate: GET `/me` without the 401→login redirect.- * Any failure (e.g. OIDC configured but no session cookie yet) is treated as+ * Any failure (e.g. auth enabled but no session cookie yet) is treated as* unauthenticated so the app can render the welcome / "Let's Get Started" screen* rather than bouncing to login before the user asks for it.*/diff --git a/packages/frontend/src/harnessClient.ts b/packages/frontend/src/harnessClient.tsindex c7037df3e..bd5568dc4 100644--- a/packages/frontend/src/harnessClient.ts+++ b/packages/frontend/src/harnessClient.ts@@ -28,7 +28,7 @@ export const harnessClient = createHarnessClient();/*** Client for the pre-boot session probe. Unlike {@link harnessClient} it does NOT* redirect on 401, so the welcome gate can observe the unauthenticated state- * (OIDC configured but no session cookie yet) and render "Let's Get Started"+ * (auth enabled but no session cookie yet) and render "Let's Get Started"* instead of bouncing straight to the login flow.*/export const harnessProbeClient = new TrueForge({diff --git a/packages/sdk/.fern/metadata.json b/packages/sdk/.fern/metadata.jsonindex 98867912b..e715f9984 100644--- a/packages/sdk/.fern/metadata.json+++ b/packages/sdk/.fern/metadata.json@@ -21,12 +21,16 @@},"noSerdeLayer": false,"omitUndefined": true,+ "optional-auth": true,"requireBaseUrl": true,"retainOriginalCasing": false,"skipResponseValidation": true,"streamType": "web","useDefaultRequestParameterValues": true},+ "originGitCommit": "af97db7768c8ccbd876506483e5e3074a7475728",+ "originGitCommitIsDirty": true,+ "invokedBy": "ci","requestedVersion": "0.0.0","ciProvider": "github","sdkVersion": "0.0.0"diff --git a/packages/sdk/README.md b/packages/sdk/README.mdindex 53694c064..e821b7d19 100644--- a/packages/sdk/README.md+++ b/packages/sdk/README.md@@ -5,7 +5,7 @@TypeScript client for the TrueFoundry agent harness server: a self-hosted runtime that executes agent turns and streams them over Server-Sent Events.-The harness server has no built-in authentication, so point the client at your own deployment's base URL.+When auth is enabled on the server, pass an ID token via the optional `token` client option (`Authorization: Bearer`).## Table of Contents@@ -48,7 +48,7 @@ Instantiate and use the client with the following:```typescriptimport { TrueForge } from "trueforge-sdk";-const client = new TrueForge({ baseUrl: "YOUR_BASE_URL" });+const client = new TrueForge({ baseUrl: "YOUR_BASE_URL", token: "YOUR_TOKEN" });const response = await client.sessions.createTurnStream("session_id", {});for await (const item of response) {console.log(item);@@ -96,7 +96,7 @@ The SDK uses async iterators, so you can consume the responses using a `for awai```typescriptimport { TrueForge } from "trueforge-sdk";-const client = new TrueForge({ baseUrl: "YOUR_BASE_URL" });+const client = new TrueForge({ baseUrl: "YOUR_BASE_URL", token: "YOUR_TOKEN" });const response = await client.sessions.createTurnStream("session_id", {});for await (const item of response) {console.log(item);diff --git a/packages/sdk/reference.md b/packages/sdk/reference.mdindex 54596205c..c792c263c 100644--- a/packages/sdk/reference.md+++ b/packages/sdk/reference.md@@ -392,7 +392,7 @@ await client.auth.logout();<dl><dd>-Returns the authenticated caller identity. When OIDC is configured this requires a valid session cookie (401 otherwise). Without OIDC, returns the default anonymous identity.+Returns the authenticated caller identity. When auth is enabled this requires a valid `id_token` cookie or `Authorization: Bearer` ID token (401 otherwise). When auth is disabled, returns the default identity.</dd></dl></dd>diff --git a/packages/sdk/src/BaseClient.ts b/packages/sdk/src/BaseClient.tsindex d0450871c..872f0d3c1 100644--- a/packages/sdk/src/BaseClient.ts+++ b/packages/sdk/src/BaseClient.ts@@ -1,9 +1,16 @@// This file was auto-generated by Fern from our API Definition.+import { BearerAuthProvider } from "./auth/BearerAuthProvider.js";import { mergeHeaders } from "./core/headers.js";import * as core from "./core/index.js";-export interface BaseClientOptions {+export type AuthOption =+ | false+ | core.AuthProvider["getAuthRequest"]+ | core.AuthProvider+ | BearerAuthProvider.AuthOptions;++export type BaseClientOptions = {environment?: core.Supplier<string>;/** Specify a custom URL to connect the client to. */baseUrl: core.Supplier<string>;@@ -20,7 +27,9 @@ export interface BaseClientOptions {logging?: core.logging.LogConfig | core.logging.Logger;/** Default options for SSE stream reconnection behavior. Has no effect on non-resumable endpoints. */stream?: { reconnectionEnabled?: boolean; maxReconnectionAttempts?: number };-}+ /** Override auth. Pass false to disable, a function returning auth headers, an AuthProvider, or auth options. */+ auth?: AuthOption;+} & BearerAuthProvider.AuthOptions;export interface BaseRequestOptions {/** The maximum time to wait for a response in seconds. */@@ -41,8 +50,14 @@ export interface BaseRequestOptions {export type NormalizedClientOptions<T extends BaseClientOptions = BaseClientOptions> = T & {logging: core.logging.Logger;+ authProvider?: core.AuthProvider;};+export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions> =+ NormalizedClientOptions<T> & {+ authProvider: core.AuthProvider;+ };+export function normalizeClientOptions<T extends BaseClientOptions = BaseClientOptions>(options: T,): NormalizedClientOptions<T> {@@ -64,3 +79,38 @@ export function normalizeClientOptions<T extends BaseClientOptions = BaseClientOheaders,} as NormalizedClientOptions<T>;}++export function normalizeClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions>(+ options: T,+): NormalizedClientOptionsWithAuth<T> {+ const normalized = normalizeClientOptions(options) as NormalizedClientOptionsWithAuth<T>;++ if (options.auth === false) {+ normalized.authProvider = new core.NoOpAuthProvider();+ return normalized;+ }+ if (options.auth != null) {+ if (typeof options.auth === "function") {+ normalized.authProvider = { getAuthRequest: options.auth };+ return normalized;+ }+ if (core.isAuthProvider(options.auth)) {+ normalized.authProvider = options.auth;+ return normalized;+ }+ Object.assign(normalized, options.auth);+ }++ const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);+ normalized.authProvider ??= new BearerAuthProvider(normalizedWithNoOpAuthProvider);+ return normalized;+}++function withNoOpAuthProvider<T extends BaseClientOptions = BaseClientOptions>(+ options: NormalizedClientOptions<T>,+): NormalizedClientOptionsWithAuth<T> {+ return {+ ...options,+ authProvider: new core.NoOpAuthProvider(),+ };+}diff --git a/packages/sdk/src/Client.ts b/packages/sdk/src/Client.tsindex dd368becc..55c0591c9 100644--- a/packages/sdk/src/Client.ts+++ b/packages/sdk/src/Client.ts@@ -9,7 +9,7 @@ import { SessionsClient } from "./api/resources/sessions/client/Client.js";import { SettingsClient } from "./api/resources/settings/client/Client.js";import { SkillsClient } from "./api/resources/skills/client/Client.js";import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "./BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "./BaseClient.js";import * as core from "./core/index.js";export declare namespace TrueForge {@@ -19,7 +19,7 @@ export declare namespace TrueForge {}export class TrueForge {- protected readonly _options: NormalizedClientOptions<TrueForge.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<TrueForge.Options>;protected _agents: AgentsClient | undefined;protected _auth: AuthClient | undefined;protected _server: ServerClient | undefined;@@ -30,7 +30,7 @@ export class TrueForge {protected _settings: SettingsClient | undefined;constructor(options: TrueForge.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}public get agents(): AgentsClient {@@ -90,6 +90,7 @@ export class TrueForge {maxRetries: this._options.maxRetries,fetch: this._options.fetch,logging: this._options.logging,+ getAuthHeaders: async () => (await this._options.authProvider.getAuthRequest()).headers,},requestOptions,);diff --git a/packages/sdk/src/api/resources/agents/client/Client.ts b/packages/sdk/src/api/resources/agents/client/Client.tsindex 1bc84ca96..671bb13bd 100644--- a/packages/sdk/src/api/resources/agents/client/Client.ts+++ b/packages/sdk/src/api/resources/agents/client/Client.ts@@ -1,7 +1,7 @@// This file was auto-generated by Fern from our API Definition.import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";import { mergeHeaders } from "../../../../core/headers.js";import * as core from "../../../../core/index.js";import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js";@@ -17,10 +17,10 @@ export declare namespace AgentsClient {}export class AgentsClient {- protected readonly _options: NormalizedClientOptions<AgentsClient.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<AgentsClient.Options>;constructor(options: AgentsClient.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}/**@@ -42,7 +42,12 @@ export class AgentsClient {private async __list(requestOptions?: AgentsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.ListAgentsResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -127,7 +132,12 @@ export class AgentsClient {request: TrueForge.AgentWriteRequest,requestOptions?: AgentsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.CreateAgentResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -238,7 +248,12 @@ export class AgentsClient {agent_id: string,requestOptions?: AgentsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetAgentResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -313,7 +328,12 @@ export class AgentsClient {agent_id: string,requestOptions?: AgentsClient.RequestOptions,): Promise<core.WithRawResponse<void>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -391,7 +411,12 @@ export class AgentsClient {request: TrueForge.UpdateAgentRequest,requestOptions?: AgentsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.PutAgentResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??diff --git a/packages/sdk/src/api/resources/auth/client/Client.ts b/packages/sdk/src/api/resources/auth/client/Client.tsindex 59dbccdbd..7d595a9b1 100644--- a/packages/sdk/src/api/resources/auth/client/Client.ts+++ b/packages/sdk/src/api/resources/auth/client/Client.ts@@ -1,7 +1,7 @@// This file was auto-generated by Fern from our API Definition.import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";import { mergeHeaders } from "../../../../core/headers.js";import * as core from "../../../../core/index.js";import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";@@ -16,10 +16,10 @@ export declare namespace AuthClient {}export class AuthClient {- protected readonly _options: NormalizedClientOptions<AuthClient.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<AuthClient.Options>;constructor(options: AuthClient.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}/**@@ -38,7 +38,12 @@ export class AuthClient {}private async __logout(requestOptions?: AuthClient.RequestOptions): Promise<core.WithRawResponse<void>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -70,7 +75,7 @@ export class AuthClient {}/**- * Returns the authenticated caller identity. When OIDC is configured this requires a valid session cookie (401 otherwise). Without OIDC, returns the default anonymous identity.+ * Returns the authenticated caller identity. When auth is enabled this requires a valid `id_token` cookie or `Authorization: Bearer` ID token (401 otherwise). When auth is disabled, returns the default identity.** @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.*@@ -88,7 +93,12 @@ export class AuthClient {private async __me(requestOptions?: AuthClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.MeResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??diff --git a/packages/sdk/src/api/resources/mcpServers/client/Client.ts b/packages/sdk/src/api/resources/mcpServers/client/Client.tsindex 5e64836eb..42d60a36d 100644--- a/packages/sdk/src/api/resources/mcpServers/client/Client.ts+++ b/packages/sdk/src/api/resources/mcpServers/client/Client.ts@@ -1,7 +1,7 @@// This file was auto-generated by Fern from our API Definition.import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";import { mergeHeaders } from "../../../../core/headers.js";import * as core from "../../../../core/index.js";import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";@@ -16,10 +16,10 @@ export declare namespace McpServersClient {}export class McpServersClient {- protected readonly _options: NormalizedClientOptions<McpServersClient.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<McpServersClient.Options>;constructor(options: McpServersClient.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}/**@@ -43,7 +43,12 @@ export class McpServersClient {private async __list(requestOptions?: McpServersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.ListAvailableMcpServersResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -132,7 +137,12 @@ export class McpServersClient {const _queryParams: Record<string, unknown> = {redirect_url: redirectUrl,};- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -263,7 +273,12 @@ export class McpServersClient {name: string,requestOptions?: McpServersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.PutMcpServerResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??diff --git a/packages/sdk/src/api/resources/models/client/Client.ts b/packages/sdk/src/api/resources/models/client/Client.tsindex 3598c4f7e..d31832c29 100644--- a/packages/sdk/src/api/resources/models/client/Client.ts+++ b/packages/sdk/src/api/resources/models/client/Client.ts@@ -1,7 +1,7 @@// This file was auto-generated by Fern from our API Definition.import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";import { mergeHeaders } from "../../../../core/headers.js";import * as core from "../../../../core/index.js";import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";@@ -16,10 +16,10 @@ export declare namespace ModelsClient {}export class ModelsClient {- protected readonly _options: NormalizedClientOptions<ModelsClient.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<ModelsClient.Options>;constructor(options: ModelsClient.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}/**@@ -41,7 +41,12 @@ export class ModelsClient {private async __list(requestOptions?: ModelsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.ListModelsResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??diff --git a/packages/sdk/src/api/resources/server/client/Client.ts b/packages/sdk/src/api/resources/server/client/Client.tsindex 8553b3fed..3d730045b 100644--- a/packages/sdk/src/api/resources/server/client/Client.ts+++ b/packages/sdk/src/api/resources/server/client/Client.ts@@ -1,7 +1,7 @@// This file was auto-generated by Fern from our API Definition.import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";import { mergeHeaders } from "../../../../core/headers.js";import * as core from "../../../../core/index.js";import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";@@ -16,10 +16,10 @@ export declare namespace ServerClient {}export class ServerClient {- protected readonly _options: NormalizedClientOptions<ServerClient.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<ServerClient.Options>;constructor(options: ServerClient.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}/**@@ -43,7 +43,12 @@ export class ServerClient {private async __getCapabilities(requestOptions?: ServerClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetCapabilitiesResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??diff --git a/packages/sdk/src/api/resources/sessions/client/Client.ts b/packages/sdk/src/api/resources/sessions/client/Client.tsindex 6f1ffe540..6aa0601c4 100644--- a/packages/sdk/src/api/resources/sessions/client/Client.ts+++ b/packages/sdk/src/api/resources/sessions/client/Client.ts@@ -1,7 +1,7 @@// This file was auto-generated by Fern from our API Definition.import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";import { mergeHeaders } from "../../../../core/headers.js";import * as core from "../../../../core/index.js";import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js";@@ -17,10 +17,10 @@ export declare namespace SessionsClient {}export class SessionsClient {- protected readonly _options: NormalizedClientOptions<SessionsClient.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<SessionsClient.Options>;constructor(options: SessionsClient.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}/**@@ -61,7 +61,9 @@ export class SessionsClient {end_timestamp: endTimestamp != null ? endTimestamp?.toISOString() : undefined,agent_id: agentId,};+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,this._options?.headers,requestOptions?.headers,);@@ -164,7 +166,12 @@ export class SessionsClient {request: TrueForge.CreateSessionRequest,requestOptions?: SessionsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetSessionResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -276,7 +283,12 @@ export class SessionsClient {session_id: string,requestOptions?: SessionsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetSessionResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -362,7 +374,12 @@ export class SessionsClient {session_id: string,requestOptions?: SessionsClient.RequestOptions,): Promise<core.WithRawResponse<void>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -442,7 +459,12 @@ export class SessionsClient {request: TrueForge.UpdateSessionRequest = {},requestOptions?: SessionsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetSessionResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -574,7 +596,12 @@ export class SessionsClient {request: TrueForge.CancelSessionRequest = {},requestOptions?: SessionsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.CancelSessionResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -697,7 +724,9 @@ export class SessionsClient {last_turn_id: lastTurnId,limit,};+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,this._options?.headers,requestOptions?.headers,);@@ -827,7 +856,9 @@ export class SessionsClient {limit,page_token: pageToken,};+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,this._options?.headers,requestOptions?.headers,);@@ -947,7 +978,12 @@ export class SessionsClient {request: TrueForge.CreateTurnSessionsStreamRequest,requestOptions?: SessionsClient.RequestOptions,): Promise<core.WithRawResponse<core.Stream<TrueForge.TurnStreamingEvent>>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)<ReadableStream>({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -1109,7 +1145,12 @@ export class SessionsClient {request: TrueForge.CreateTurnSessionsRequest,requestOptions?: SessionsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetTurnResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -1254,7 +1295,12 @@ export class SessionsClient {turn_id: string,requestOptions?: SessionsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetTurnResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -1358,7 +1404,12 @@ export class SessionsClient {const _queryParams: Record<string, unknown> = {path,};- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)<core.BinaryResponse>({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -1520,7 +1571,9 @@ export class SessionsClient {}): undefined,};+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,this._options?.headers,requestOptions?.headers,);@@ -1644,7 +1697,12 @@ export class SessionsClient {const _queryParams: Record<string, unknown> = {after_sequence_number: afterSequenceNumber,};- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)<ReadableStream>({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??diff --git a/packages/sdk/src/api/resources/settings/client/Client.ts b/packages/sdk/src/api/resources/settings/client/Client.tsindex 7ef35f49a..f932bd78f 100644--- a/packages/sdk/src/api/resources/settings/client/Client.ts+++ b/packages/sdk/src/api/resources/settings/client/Client.ts@@ -1,7 +1,7 @@// This file was auto-generated by Fern from our API Definition.import type { BaseClientOptions } from "../../../../BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";import { McpServersClient } from "../resources/mcpServers/client/Client.js";import { ModelProvidersClient } from "../resources/modelProviders/client/Client.js";import { SandboxProvidersClient } from "../resources/sandboxProviders/client/Client.js";@@ -12,14 +12,14 @@ export declare namespace SettingsClient {}export class SettingsClient {- protected readonly _options: NormalizedClientOptions<SettingsClient.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<SettingsClient.Options>;protected _mcpServers: McpServersClient | undefined;protected _modelProviders: ModelProvidersClient | undefined;protected _sandboxProviders: SandboxProvidersClient | undefined;protected _skills: SkillsClient | undefined;constructor(options: SettingsClient.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}public get mcpServers(): McpServersClient {diff --git a/packages/sdk/src/api/resources/settings/resources/mcpServers/client/Client.ts b/packages/sdk/src/api/resources/settings/resources/mcpServers/client/Client.tsindex ce986df8c..de8af6ed6 100644--- a/packages/sdk/src/api/resources/settings/resources/mcpServers/client/Client.ts+++ b/packages/sdk/src/api/resources/settings/resources/mcpServers/client/Client.ts@@ -1,7 +1,7 @@// This file was auto-generated by Fern from our API Definition.import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../../../BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js";import { mergeHeaders } from "../../../../../../core/headers.js";import * as core from "../../../../../../core/index.js";import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js";@@ -17,10 +17,10 @@ export declare namespace McpServersClient {}export class McpServersClient {- protected readonly _options: NormalizedClientOptions<McpServersClient.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<McpServersClient.Options>;constructor(options: McpServersClient.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}/**@@ -45,7 +45,12 @@ export class McpServersClient {private async __list(requestOptions?: McpServersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.ListMcpServersResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -138,7 +143,12 @@ export class McpServersClient {request: TrueForge.settings.McpServerManifest,requestOptions?: McpServersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.PutMcpServerResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -239,7 +249,12 @@ export class McpServersClient {private async __catalog(requestOptions?: McpServersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetMcpServerCatalogResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -333,7 +348,12 @@ export class McpServersClient {name: string,requestOptions?: McpServersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetMcpServerResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -419,7 +439,12 @@ export class McpServersClient {name: string,requestOptions?: McpServersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.ListMcpServerToolsResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??diff --git a/packages/sdk/src/api/resources/settings/resources/modelProviders/client/Client.ts b/packages/sdk/src/api/resources/settings/resources/modelProviders/client/Client.tsindex 5b6782fa0..4bb2e0fe8 100644--- a/packages/sdk/src/api/resources/settings/resources/modelProviders/client/Client.ts+++ b/packages/sdk/src/api/resources/settings/resources/modelProviders/client/Client.ts@@ -1,7 +1,7 @@// This file was auto-generated by Fern from our API Definition.import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../../../BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js";import { mergeHeaders } from "../../../../../../core/headers.js";import * as core from "../../../../../../core/index.js";import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js";@@ -17,10 +17,10 @@ export declare namespace ModelProvidersClient {}export class ModelProvidersClient {- protected readonly _options: NormalizedClientOptions<ModelProvidersClient.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<ModelProvidersClient.Options>;constructor(options: ModelProvidersClient.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}/**@@ -45,7 +45,12 @@ export class ModelProvidersClient {private async __list(requestOptions?: ModelProvidersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.ListModelProvidersResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -149,7 +154,12 @@ export class ModelProvidersClient {request: TrueForge.ModelProvider,requestOptions?: ModelProvidersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.PutModelProviderResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -241,7 +251,12 @@ export class ModelProvidersClient {private async __catalog(requestOptions?: ModelProvidersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetModelProviderCatalogResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??diff --git a/packages/sdk/src/api/resources/settings/resources/sandboxProviders/client/Client.ts b/packages/sdk/src/api/resources/settings/resources/sandboxProviders/client/Client.tsindex 8c5f5d629..edc2ea4d3 100644--- a/packages/sdk/src/api/resources/settings/resources/sandboxProviders/client/Client.ts+++ b/packages/sdk/src/api/resources/settings/resources/sandboxProviders/client/Client.ts@@ -1,7 +1,7 @@// This file was auto-generated by Fern from our API Definition.import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../../../BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js";import { mergeHeaders } from "../../../../../../core/headers.js";import * as core from "../../../../../../core/index.js";import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js";@@ -17,10 +17,10 @@ export declare namespace SandboxProvidersClient {}export class SandboxProvidersClient {- protected readonly _options: NormalizedClientOptions<SandboxProvidersClient.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<SandboxProvidersClient.Options>;constructor(options: SandboxProvidersClient.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}/**@@ -44,7 +44,12 @@ export class SandboxProvidersClient {private async __get(requestOptions?: SandboxProvidersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetSandboxProviderResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -137,7 +142,12 @@ export class SandboxProvidersClient {request: TrueForge.DaytonaSandboxProvider,requestOptions?: SandboxProvidersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.PutSandboxProviderResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -229,7 +239,12 @@ export class SandboxProvidersClient {private async __catalog(requestOptions?: SandboxProvidersClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetSandboxProviderCatalogResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??diff --git a/packages/sdk/src/api/resources/settings/resources/skills/client/Client.ts b/packages/sdk/src/api/resources/settings/resources/skills/client/Client.tsindex 0452de378..e39d079c7 100644--- a/packages/sdk/src/api/resources/settings/resources/skills/client/Client.ts+++ b/packages/sdk/src/api/resources/settings/resources/skills/client/Client.ts@@ -1,7 +1,7 @@// This file was auto-generated by Fern from our API Definition.import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../../../BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js";import { mergeHeaders } from "../../../../../../core/headers.js";import * as core from "../../../../../../core/index.js";import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js";@@ -17,10 +17,10 @@ export declare namespace SkillsClient {}export class SkillsClient {- protected readonly _options: NormalizedClientOptions<SkillsClient.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<SkillsClient.Options>;constructor(options: SkillsClient.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}/**@@ -45,7 +45,12 @@ export class SkillsClient {private async __list(requestOptions?: SkillsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.ListConfiguredSkillsResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -140,7 +145,12 @@ export class SkillsClient {request: TrueForge.SkillManifest,requestOptions?: SkillsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.PutSkillResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??@@ -227,7 +237,12 @@ export class SkillsClient {private async __catalog(requestOptions?: SkillsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.GetSkillCatalogResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??diff --git a/packages/sdk/src/api/resources/skills/client/Client.ts b/packages/sdk/src/api/resources/skills/client/Client.tsindex 60ee6c9ff..4fc7f8f48 100644--- a/packages/sdk/src/api/resources/skills/client/Client.ts+++ b/packages/sdk/src/api/resources/skills/client/Client.ts@@ -1,7 +1,7 @@// This file was auto-generated by Fern from our API Definition.import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";-import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../BaseClient.js";+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";import { mergeHeaders } from "../../../../core/headers.js";import * as core from "../../../../core/index.js";import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";@@ -16,10 +16,10 @@ export declare namespace SkillsClient {}export class SkillsClient {- protected readonly _options: NormalizedClientOptions<SkillsClient.Options>;+ protected readonly _options: NormalizedClientOptionsWithAuth<SkillsClient.Options>;constructor(options: SkillsClient.Options) {- this._options = normalizeClientOptions(options);+ this._options = normalizeClientOptionsWithAuth(options);}/**@@ -43,7 +43,12 @@ export class SkillsClient {private async __list(requestOptions?: SkillsClient.RequestOptions,): Promise<core.WithRawResponse<TrueForge.ListAvailableSkillsResponse>> {- const _headers: core.Fetcher.Args["headers"] = mergeHeaders(this._options?.headers, requestOptions?.headers);+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(+ _authRequest.headers,+ this._options?.headers,+ requestOptions?.headers,+ );const _response = await (this._options.fetcher ?? core.fetcher)({url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??diff --git a/packages/sdk/src/auth/BearerAuthProvider.ts b/packages/sdk/src/auth/BearerAuthProvider.tsnew file mode 100644index 000000000..03a15c229--- /dev/null+++ b/packages/sdk/src/auth/BearerAuthProvider.ts@@ -0,0 +1,44 @@+// This file was auto-generated by Fern from our API Definition.++import * as core from "../core/index.js";++const TOKEN_PARAM = "token" as const;++export class BearerAuthProvider implements core.AuthProvider {+ private readonly options: BearerAuthProvider.Options;++ constructor(options: BearerAuthProvider.Options) {+ this.options = options;+ }++ public static canCreate(options: Partial<BearerAuthProvider.Options>): boolean {+ return options?.[TOKEN_PARAM] != null;+ }++ public async getAuthRequest({+ endpointMetadata,+ }: {+ endpointMetadata?: core.EndpointMetadata;+ } = {}): Promise<core.AuthRequest> {+ const token = await core.Supplier.get(this.options[TOKEN_PARAM]);+ if (token == null) {+ return { headers: {} };+ }++ return {+ headers: { Authorization: `Bearer ${token}` },+ };+ }+}++export namespace BearerAuthProvider {+ export const AUTH_SCHEME = "BearerAuth" as const;+ export const AUTH_CONFIG_ERROR_MESSAGE: string =+ `Please provide '${TOKEN_PARAM}' when initializing the client` as const;+ export type Options = AuthOptions;+ export type AuthOptions = { [TOKEN_PARAM]?: core.Supplier<core.BearerToken> };++ export function createInstance(options: Options): core.AuthProvider {+ return new BearerAuthProvider(options);+ }+}diff --git a/packages/sdk/src/auth/index.ts b/packages/sdk/src/auth/index.tsnew file mode 100644index 000000000..0ecb12b79--- /dev/null+++ b/packages/sdk/src/auth/index.ts@@ -0,0 +1 @@+export { BearerAuthProvider } from "./BearerAuthProvider.js";diff --git a/packages/sdk/src/core/auth/AuthProvider.ts b/packages/sdk/src/core/auth/AuthProvider.tsnew file mode 100644index 000000000..c9478669f--- /dev/null+++ b/packages/sdk/src/core/auth/AuthProvider.ts@@ -0,0 +1,15 @@+import type { EndpointMetadata } from "../fetcher/EndpointMetadata.js";+import type { AuthRequest } from "./AuthRequest.js";++export interface AuthProvider {+ getAuthRequest(arg?: { endpointMetadata?: EndpointMetadata }): Promise<AuthRequest>;+}++export function isAuthProvider(value: unknown): value is AuthProvider {+ return (+ typeof value === "object" &&+ value !== null &&+ "getAuthRequest" in value &&+ typeof value.getAuthRequest === "function"+ );+}diff --git a/packages/sdk/src/core/auth/AuthRequest.ts b/packages/sdk/src/core/auth/AuthRequest.tsnew file mode 100644index 000000000..f6218b422--- /dev/null+++ b/packages/sdk/src/core/auth/AuthRequest.ts@@ -0,0 +1,9 @@+/**+ * Request parameters for authentication requests.+ */+export interface AuthRequest {+ /**+ * The headers to be included in the request.+ */+ headers: Record<string, string>;+}diff --git a/packages/sdk/src/core/auth/BasicAuth.ts b/packages/sdk/src/core/auth/BasicAuth.tsnew file mode 100644index 000000000..f34fca5cc--- /dev/null+++ b/packages/sdk/src/core/auth/BasicAuth.ts@@ -0,0 +1,37 @@+import { base64Decode, base64Encode } from "../base64.js";++export interface BasicAuth {+ username?: string;+ password?: string;+}++const BASIC_AUTH_HEADER_PREFIX = /^Basic /i;++export const BasicAuth = {+ toAuthorizationHeader: (basicAuth: BasicAuth | undefined): string | undefined => {+ if (basicAuth == null) {+ return undefined;+ }+ const username = basicAuth.username ?? "";+ const password = basicAuth.password ?? "";+ if (username === "" && password === "") {+ return undefined;+ }+ const token = base64Encode(`${username}:${password}`);+ return `Basic ${token}`;+ },+ fromAuthorizationHeader: (header: string): BasicAuth => {+ const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, "");+ const decoded = base64Decode(credentials);+ const [username, ...passwordParts] = decoded.split(":");+ const password = passwordParts.length > 0 ? passwordParts.join(":") : undefined;++ if (username == null || password == null) {+ throw new Error("Invalid basic auth");+ }+ return {+ username,+ password,+ };+ },+};diff --git a/packages/sdk/src/core/auth/BearerToken.ts b/packages/sdk/src/core/auth/BearerToken.tsnew file mode 100644index 000000000..c44a06c38--- /dev/null+++ b/packages/sdk/src/core/auth/BearerToken.ts@@ -0,0 +1,20 @@+export type BearerToken = string;++const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i;++function toAuthorizationHeader(token: string | undefined): string | undefined {+ if (token == null) {+ return undefined;+ }+ return `Bearer ${token}`;+}++export const BearerToken: {+ toAuthorizationHeader: typeof toAuthorizationHeader;+ fromAuthorizationHeader: (header: string) => BearerToken;+} = {+ toAuthorizationHeader: toAuthorizationHeader,+ fromAuthorizationHeader: (header: string): BearerToken => {+ return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim() as BearerToken;+ },+};diff --git a/packages/sdk/src/core/auth/NoOpAuthProvider.ts b/packages/sdk/src/core/auth/NoOpAuthProvider.tsnew file mode 100644index 000000000..5b7acfd2b--- /dev/null+++ b/packages/sdk/src/core/auth/NoOpAuthProvider.ts@@ -0,0 +1,8 @@+import type { AuthProvider } from "./AuthProvider.js";+import type { AuthRequest } from "./AuthRequest.js";++export class NoOpAuthProvider implements AuthProvider {+ public getAuthRequest(): Promise<AuthRequest> {+ return Promise.resolve({ headers: {} });+ }+}diff --git a/packages/sdk/src/core/auth/index.ts b/packages/sdk/src/core/auth/index.tsnew file mode 100644index 000000000..77effd090--- /dev/null+++ b/packages/sdk/src/core/auth/index.ts@@ -0,0 +1,5 @@+export { type AuthProvider, isAuthProvider } from "./AuthProvider.js";+export type { AuthRequest } from "./AuthRequest.js";+export { BasicAuth } from "./BasicAuth.js";+export { BearerToken } from "./BearerToken.js";+export { NoOpAuthProvider } from "./NoOpAuthProvider.js";diff --git a/packages/sdk/src/core/base64.ts b/packages/sdk/src/core/base64.tsnew file mode 100644index 000000000..448a0db63--- /dev/null+++ b/packages/sdk/src/core/base64.ts@@ -0,0 +1,27 @@+function base64ToBytes(base64: string): Uint8Array {+ const binString = atob(base64);+ return Uint8Array.from(binString, (m) => m.codePointAt(0)!);+}++function bytesToBase64(bytes: Uint8Array): string {+ const binString = String.fromCodePoint(...bytes);+ return btoa(binString);+}++export function base64Encode(input: string): string {+ if (typeof Buffer !== "undefined") {+ return Buffer.from(input, "utf8").toString("base64");+ }++ const bytes = new TextEncoder().encode(input);+ return bytesToBase64(bytes);+}++export function base64Decode(input: string): string {+ if (typeof Buffer !== "undefined") {+ return Buffer.from(input, "base64").toString("utf8");+ }++ const bytes = base64ToBytes(input);+ return new TextDecoder().decode(bytes);+}diff --git a/packages/sdk/src/core/index.ts b/packages/sdk/src/core/index.tsindex 3e14a6db2..45475e705 100644--- a/packages/sdk/src/core/index.ts+++ b/packages/sdk/src/core/index.ts@@ -1,3 +1,5 @@+export * from "./auth/index.js";+export * from "./base64.js";export * from "./fetcher/index.js";export * as logging from "./logging/index.js";export * from "./pagination/index.js";diff --git a/packages/sdk/tests/unit/auth/BasicAuth.test.ts b/packages/sdk/tests/unit/auth/BasicAuth.test.tsnew file mode 100644index 000000000..8c82c1b72--- /dev/null+++ b/packages/sdk/tests/unit/auth/BasicAuth.test.ts@@ -0,0 +1,112 @@+import { BasicAuth } from "../../../src/core/auth/BasicAuth";++describe("BasicAuth", () => {+ interface ToHeaderTestCase {+ description: string;+ input: { username?: string; password?: string };+ expected: string | undefined;+ }++ interface FromHeaderTestCase {+ description: string;+ input: string;+ expected: { username: string; password: string };+ }++ interface ErrorTestCase {+ description: string;+ input: string;+ expectedError: string;+ }++ describe("toAuthorizationHeader", () => {+ const toHeaderTests: ToHeaderTestCase[] = [+ {+ description: "correctly converts to header with both username and password",+ input: { username: "username", password: "password" },+ expected: "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",+ },+ {+ description: "encodes username only with trailing colon",+ input: { username: "username" },+ expected: "Basic dXNlcm5hbWU6",+ },+ {+ description: "encodes password only with leading colon",+ input: { password: "password" },+ expected: "Basic OnBhc3N3b3Jk",+ },+ {+ description: "returns undefined when neither provided",+ input: {},+ expected: undefined,+ },+ {+ description: "returns undefined when both are empty strings",+ input: { username: "", password: "" },+ expected: undefined,+ },+ ];++ toHeaderTests.forEach(({ description, input, expected }) => {+ it(description, () => {+ expect(BasicAuth.toAuthorizationHeader(input)).toBe(expected);+ });+ });+ });++ describe("fromAuthorizationHeader", () => {+ const fromHeaderTests: FromHeaderTestCase[] = [+ {+ description: "correctly parses header",+ input: "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",+ expected: { username: "username", password: "password" },+ },+ {+ description: "handles password with colons",+ input: "Basic dXNlcjpwYXNzOndvcmQ=",+ expected: { username: "user", password: "pass:word" },+ },+ {+ description: "handles empty username and password (just colon)",+ input: "Basic Og==",+ expected: { username: "", password: "" },+ },+ {+ description: "handles empty username",+ input: "Basic OnBhc3N3b3Jk",+ expected: { username: "", password: "password" },+ },+ {+ description: "handles empty password",+ input: "Basic dXNlcm5hbWU6",+ expected: { username: "username", password: "" },+ },+ ];++ fromHeaderTests.forEach(({ description, input, expected }) => {+ it(description, () => {+ expect(BasicAuth.fromAuthorizationHeader(input)).toEqual(expected);+ });+ });++ const errorTests: ErrorTestCase[] = [+ {+ description: "throws error for completely empty credentials",+ input: "Basic ",+ expectedError: "Invalid basic auth",+ },+ {+ description: "throws error for credentials without colon",+ input: "Basic dXNlcm5hbWU=",+ expectedError: "Invalid basic auth",+ },+ ];++ errorTests.forEach(({ description, input, expectedError }) => {+ it(description, () => {+ expect(() => BasicAuth.fromAuthorizationHeader(input)).toThrow(expectedError);+ });+ });+ });+});diff --git a/packages/sdk/tests/unit/auth/BearerToken.test.ts b/packages/sdk/tests/unit/auth/BearerToken.test.tsnew file mode 100644index 000000000..7757b87cb--- /dev/null+++ b/packages/sdk/tests/unit/auth/BearerToken.test.ts@@ -0,0 +1,14 @@+import { BearerToken } from "../../../src/core/auth/BearerToken";++describe("BearerToken", () => {+ describe("toAuthorizationHeader", () => {+ it("correctly converts to header", () => {+ expect(BearerToken.toAuthorizationHeader("my-token")).toBe("Bearer my-token");+ });+ });+ describe("fromAuthorizationHeader", () => {+ it("correctly parses header", () => {+ expect(BearerToken.fromAuthorizationHeader("Bearer my-token")).toBe("my-token");+ });+ });+});diff --git a/packages/sdk/tests/unit/base64.test.ts b/packages/sdk/tests/unit/base64.test.tsnew file mode 100644index 000000000..939594ca2--- /dev/null+++ b/packages/sdk/tests/unit/base64.test.ts@@ -0,0 +1,53 @@+import { base64Decode, base64Encode } from "../../src/core/base64";++describe("base64", () => {+ describe("base64Encode", () => {+ it("should encode ASCII strings", () => {+ expect(base64Encode("hello")).toBe("aGVsbG8=");+ expect(base64Encode("")).toBe("");+ });++ it("should encode UTF-8 strings", () => {+ expect(base64Encode("café")).toBe("Y2Fmw6k=");+ expect(base64Encode("🎉")).toBe("8J+OiQ==");+ });++ it("should handle basic auth credentials", () => {+ expect(base64Encode("username:password")).toBe("dXNlcm5hbWU6cGFzc3dvcmQ=");+ });+ });++ describe("base64Decode", () => {+ it("should decode ASCII strings", () => {+ expect(base64Decode("aGVsbG8=")).toBe("hello");+ expect(base64Decode("")).toBe("");+ });++ it("should decode UTF-8 strings", () => {+ expect(base64Decode("Y2Fmw6k=")).toBe("café");+ expect(base64Decode("8J+OiQ==")).toBe("🎉");+ });++ it("should handle basic auth credentials", () => {+ expect(base64Decode("dXNlcm5hbWU6cGFzc3dvcmQ=")).toBe("username:password");+ });+ });++ describe("round-trip encoding", () => {+ const testStrings = [+ "hello world",+ "[email protected]",+ "café",+ "username:password",+ "[email protected]:super$ecret123!",+ ];++ testStrings.forEach((testString) => {+ it(`should round-trip encode/decode: "${testString}"`, () => {+ const encoded = base64Encode(testString);+ const decoded = base64Decode(encoded);+ expect(decoded).toBe(testString);+ });+ });+ });+});diff --git a/packages/sdk/tests/wire/agents.test.ts b/packages/sdk/tests/wire/agents.test.tsindex 9c1a1989c..244c0bf2e 100644--- a/packages/sdk/tests/wire/agents.test.ts+++ b/packages/sdk/tests/wire/agents.test.ts@@ -7,7 +7,7 @@ import { mockServerPool } from "../mock-server/MockServerPool";describe("AgentsClient", () => {test("list (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: [@@ -62,7 +62,7 @@ describe("AgentsClient", () => {test("list (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -75,7 +75,7 @@ describe("AgentsClient", () => {test("create (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { model: { name: "name" }, name: "name" };const rawResponseBody = {data: {@@ -145,7 +145,7 @@ describe("AgentsClient", () => {test("create (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { name: "xy", model: { name: "x" } };const rawResponseBody = { error: { message: "message" } };@@ -170,7 +170,7 @@ describe("AgentsClient", () => {test("create (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { name: "xy", model: { name: "x" } };const rawResponseBody = { error: { message: "message" } };@@ -195,7 +195,7 @@ describe("AgentsClient", () => {test("create (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { name: "xy", model: { name: "x" } };const rawResponseBody = { error: { message: "message" } };@@ -220,7 +220,7 @@ describe("AgentsClient", () => {test("get (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: {@@ -284,7 +284,7 @@ describe("AgentsClient", () => {test("get (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -303,7 +303,7 @@ describe("AgentsClient", () => {test("delete (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });server.mockEndpoint().delete("/api/v1/agents/agent_id").respondWith().statusCode(200).build();@@ -313,7 +313,7 @@ describe("AgentsClient", () => {test("delete (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -332,7 +332,7 @@ describe("AgentsClient", () => {test("update (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { model: { name: "name" } };const rawResponseBody = {data: {@@ -401,7 +401,7 @@ describe("AgentsClient", () => {test("update (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { model: { name: "x" } };const rawResponseBody = { error: { message: "message" } };@@ -425,7 +425,7 @@ describe("AgentsClient", () => {test("update (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { model: { name: "x" } };const rawResponseBody = { error: { message: "message" } };@@ -449,7 +449,7 @@ describe("AgentsClient", () => {test("update (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { model: { name: "x" } };const rawResponseBody = { error: { message: "message" } };diff --git a/packages/sdk/tests/wire/auth.test.ts b/packages/sdk/tests/wire/auth.test.tsindex 2d73e751b..6ce141895 100644--- a/packages/sdk/tests/wire/auth.test.ts+++ b/packages/sdk/tests/wire/auth.test.ts@@ -7,7 +7,7 @@ import { mockServerPool } from "../mock-server/MockServerPool";describe("AuthClient", () => {test("logout", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });server.mockEndpoint().post("/api/v1/auth/logout").respondWith().statusCode(200).build();@@ -17,7 +17,7 @@ describe("AuthClient", () => {test("me (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { email: "email", role: "role", type: "default" };@@ -33,7 +33,7 @@ describe("AuthClient", () => {test("me (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };diff --git a/packages/sdk/tests/wire/mcpServers.test.ts b/packages/sdk/tests/wire/mcpServers.test.tsindex db6eb456c..0af93e36d 100644--- a/packages/sdk/tests/wire/mcpServers.test.ts+++ b/packages/sdk/tests/wire/mcpServers.test.ts@@ -7,7 +7,7 @@ import { mockServerPool } from "../mock-server/MockServerPool";describe("McpServersClient", () => {test("list (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { data: [{ name: "name", url: "url" }] };@@ -32,7 +32,7 @@ describe("McpServersClient", () => {test("list (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -51,7 +51,7 @@ describe("McpServersClient", () => {test("authorize (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { authorization_url: "authorization_url", status: "authenticated" };@@ -72,7 +72,7 @@ describe("McpServersClient", () => {test("authorize (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -91,7 +91,7 @@ describe("McpServersClient", () => {test("authorize (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -110,7 +110,7 @@ describe("McpServersClient", () => {test("authorize (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -129,7 +129,7 @@ describe("McpServersClient", () => {test("authorize (5)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -148,7 +148,7 @@ describe("McpServersClient", () => {test("authorize (6)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -167,7 +167,7 @@ describe("McpServersClient", () => {test("delete_authorize (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: {@@ -206,7 +206,7 @@ describe("McpServersClient", () => {test("delete_authorize (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };diff --git a/packages/sdk/tests/wire/models.test.ts b/packages/sdk/tests/wire/models.test.tsindex 9a9217bf2..7e517f3cb 100644--- a/packages/sdk/tests/wire/models.test.ts+++ b/packages/sdk/tests/wire/models.test.ts@@ -7,7 +7,7 @@ import { mockServerPool } from "../mock-server/MockServerPool";describe("ModelsClient", () => {test("list (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { data: [{ model_id: "model_id", name: "name", properties: {} }] };@@ -27,7 +27,7 @@ describe("ModelsClient", () => {test("list (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };diff --git a/packages/sdk/tests/wire/server.test.ts b/packages/sdk/tests/wire/server.test.tsindex e7fd48fa5..69cccd5eb 100644--- a/packages/sdk/tests/wire/server.test.ts+++ b/packages/sdk/tests/wire/server.test.ts@@ -7,7 +7,7 @@ import { mockServerPool } from "../mock-server/MockServerPool";describe("ServerClient", () => {test("get_capabilities (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: {@@ -44,7 +44,7 @@ describe("ServerClient", () => {test("get_capabilities (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };diff --git a/packages/sdk/tests/wire/sessions.test.ts b/packages/sdk/tests/wire/sessions.test.tsindex 1fa82bfb0..28a30cd92 100644--- a/packages/sdk/tests/wire/sessions.test.ts+++ b/packages/sdk/tests/wire/sessions.test.ts@@ -7,7 +7,7 @@ import { mockServerPool } from "../mock-server/MockServerPool";describe("SessionsClient", () => {test("list (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: [@@ -65,7 +65,7 @@ describe("SessionsClient", () => {test("list (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -78,7 +78,7 @@ describe("SessionsClient", () => {test("create (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { agent: { name: "name" } };const rawResponseBody = {data: {@@ -126,7 +126,7 @@ describe("SessionsClient", () => {test("create (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { agent: { name: "xy" } };const rawResponseBody = { error: { message: "message" } };@@ -150,7 +150,7 @@ describe("SessionsClient", () => {test("create (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { agent: { name: "xy" } };const rawResponseBody = { error: { message: "message" } };@@ -174,7 +174,7 @@ describe("SessionsClient", () => {test("create (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { agent: { name: "xy" } };const rawResponseBody = { error: { message: "message" } };@@ -198,7 +198,7 @@ describe("SessionsClient", () => {test("get (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: {@@ -241,7 +241,7 @@ describe("SessionsClient", () => {test("get (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -260,7 +260,7 @@ describe("SessionsClient", () => {test("get (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -279,7 +279,7 @@ describe("SessionsClient", () => {test("delete (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });server.mockEndpoint().delete("/api/v1/sessions/session_id").respondWith().statusCode(200).build();@@ -289,7 +289,7 @@ describe("SessionsClient", () => {test("delete (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -308,7 +308,7 @@ describe("SessionsClient", () => {test("update (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {};const rawResponseBody = {data: {@@ -352,7 +352,7 @@ describe("SessionsClient", () => {test("update (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {};const rawResponseBody = { error: { message: "message" } };@@ -372,7 +372,7 @@ describe("SessionsClient", () => {test("update (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {};const rawResponseBody = { error: { message: "message" } };@@ -392,7 +392,7 @@ describe("SessionsClient", () => {test("update (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {};const rawResponseBody = { error: { message: "message" } };@@ -412,7 +412,7 @@ describe("SessionsClient", () => {test("update (5)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {};const rawResponseBody = { error: { message: "message" } };@@ -432,7 +432,7 @@ describe("SessionsClient", () => {test("cancel (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {};const rawResponseBody = {};@@ -451,7 +451,7 @@ describe("SessionsClient", () => {test("cancel (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {};const rawResponseBody = { error: { message: "message" } };@@ -471,7 +471,7 @@ describe("SessionsClient", () => {test("cancel (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {};const rawResponseBody = { error: { message: "message" } };@@ -491,7 +491,7 @@ describe("SessionsClient", () => {test("cancel (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {};const rawResponseBody = { error: { message: "message" } };@@ -511,7 +511,7 @@ describe("SessionsClient", () => {test("list_events (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: [@@ -572,7 +572,7 @@ describe("SessionsClient", () => {test("list_events (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -591,7 +591,7 @@ describe("SessionsClient", () => {test("list_events (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -610,7 +610,7 @@ describe("SessionsClient", () => {test("list_events (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -629,7 +629,7 @@ describe("SessionsClient", () => {test("list_turns (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: [@@ -689,7 +689,7 @@ describe("SessionsClient", () => {test("list_turns (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -708,7 +708,7 @@ describe("SessionsClient", () => {test("list_turns (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -727,7 +727,7 @@ describe("SessionsClient", () => {test("list_turns (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -746,7 +746,7 @@ describe("SessionsClient", () => {test("create_turn_stream (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { stream: true };const rawResponseBody ='event: \ndata: {"created_at":"created_at","id":"id","thread_id":"thread_id","mcp_servers":[{"auth_url":"auth_url","id":"id","name":"name"}],"type":"mcp.auth_required"}\n\n';@@ -784,7 +784,7 @@ describe("SessionsClient", () => {test("create_turn_stream (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { stream: true };const rawResponseBody = { error: { message: "message" } };@@ -804,7 +804,7 @@ describe("SessionsClient", () => {test("create_turn_stream (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { stream: true };const rawResponseBody = { error: { message: "message" } };@@ -824,7 +824,7 @@ describe("SessionsClient", () => {test("create_turn_stream (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { stream: true };const rawResponseBody = { error: { message: "message" } };@@ -844,7 +844,7 @@ describe("SessionsClient", () => {test("create_turn_stream (5)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { stream: true };const rawResponseBody = { error: { message: "message" } };@@ -864,7 +864,7 @@ describe("SessionsClient", () => {test("create_turn_stream (6)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { stream: true };const rawResponseBody = { error: { message: "message" } };@@ -884,7 +884,7 @@ describe("SessionsClient", () => {test("create_turn (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { stream: false };const rawResponseBody = {data: {@@ -930,7 +930,7 @@ describe("SessionsClient", () => {test("create_turn (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { stream: false };const rawResponseBody = { error: { message: "message" } };@@ -950,7 +950,7 @@ describe("SessionsClient", () => {test("create_turn (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { stream: false };const rawResponseBody = { error: { message: "message" } };@@ -970,7 +970,7 @@ describe("SessionsClient", () => {test("create_turn (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { stream: false };const rawResponseBody = { error: { message: "message" } };@@ -990,7 +990,7 @@ describe("SessionsClient", () => {test("create_turn (5)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { stream: false };const rawResponseBody = { error: { message: "message" } };@@ -1010,7 +1010,7 @@ describe("SessionsClient", () => {test("create_turn (6)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { stream: false };const rawResponseBody = { error: { message: "message" } };@@ -1030,7 +1030,7 @@ describe("SessionsClient", () => {test("get_turn (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: {@@ -1075,7 +1075,7 @@ describe("SessionsClient", () => {test("get_turn (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -1094,7 +1094,7 @@ describe("SessionsClient", () => {test("get_turn (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -1113,7 +1113,7 @@ describe("SessionsClient", () => {test("list_turn_events (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: [@@ -1168,7 +1168,7 @@ describe("SessionsClient", () => {test("list_turn_events (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -1187,7 +1187,7 @@ describe("SessionsClient", () => {test("list_turn_events (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -1206,7 +1206,7 @@ describe("SessionsClient", () => {test("list_turn_events (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -1225,7 +1225,7 @@ describe("SessionsClient", () => {test("subscribe_to_turn (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody ='event: \ndata: {"created_at":"created_at","id":"id","thread_id":"thread_id","mcp_servers":[{"auth_url":"auth_url","id":"id","name":"name"}],"type":"mcp.auth_required"}\n\n';@@ -1262,7 +1262,7 @@ describe("SessionsClient", () => {test("subscribe_to_turn (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -1281,7 +1281,7 @@ describe("SessionsClient", () => {test("subscribe_to_turn (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -1300,7 +1300,7 @@ describe("SessionsClient", () => {test("subscribe_to_turn (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -1319,7 +1319,7 @@ describe("SessionsClient", () => {test("subscribe_to_turn (5)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };diff --git a/packages/sdk/tests/wire/settings/mcpServers.test.ts b/packages/sdk/tests/wire/settings/mcpServers.test.tsindex 863ff2ccf..2dcadc893 100644--- a/packages/sdk/tests/wire/settings/mcpServers.test.ts+++ b/packages/sdk/tests/wire/settings/mcpServers.test.ts@@ -7,7 +7,7 @@ import { mockServerPool } from "../../mock-server/MockServerPool";describe("McpServersClient", () => {test("list (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: [@@ -49,7 +49,7 @@ describe("McpServersClient", () => {test("list (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -68,7 +68,7 @@ describe("McpServersClient", () => {test("list (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -87,7 +87,7 @@ describe("McpServersClient", () => {test("upsert (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { name: "name", type: "remote", url: "url" };const rawResponseBody = {data: {@@ -130,7 +130,7 @@ describe("McpServersClient", () => {test("upsert (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { name: "xy", type: "remote", url: "url" };const rawResponseBody = { error: { message: "message" } };@@ -153,7 +153,7 @@ describe("McpServersClient", () => {test("upsert (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { name: "xy", type: "remote", url: "url" };const rawResponseBody = { error: { message: "message" } };@@ -176,7 +176,7 @@ describe("McpServersClient", () => {test("catalog (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: [{ auth: { type: "dcr" }, logo: "logo", name: "name", type: "remote", url: "url" }],@@ -208,7 +208,7 @@ describe("McpServersClient", () => {test("catalog (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -227,7 +227,7 @@ describe("McpServersClient", () => {test("catalog (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -246,7 +246,7 @@ describe("McpServersClient", () => {test("get (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: {@@ -285,7 +285,7 @@ describe("McpServersClient", () => {test("get (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -304,7 +304,7 @@ describe("McpServersClient", () => {test("list_tools (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { data: [{ key: "value" }] };@@ -328,7 +328,7 @@ describe("McpServersClient", () => {test("list_tools (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -347,7 +347,7 @@ describe("McpServersClient", () => {test("list_tools (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -366,7 +366,7 @@ describe("McpServersClient", () => {test("list_tools (4)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -385,7 +385,7 @@ describe("McpServersClient", () => {test("list_tools (5)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };diff --git a/packages/sdk/tests/wire/settings/modelProviders.test.ts b/packages/sdk/tests/wire/settings/modelProviders.test.tsindex f8e7d29ec..923f5d221 100644--- a/packages/sdk/tests/wire/settings/modelProviders.test.ts+++ b/packages/sdk/tests/wire/settings/modelProviders.test.ts@@ -7,7 +7,7 @@ import { mockServerPool } from "../../mock-server/MockServerPool";describe("ModelProvidersClient", () => {test("list (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: [@@ -51,7 +51,7 @@ describe("ModelProvidersClient", () => {test("list (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -70,7 +70,7 @@ describe("ModelProvidersClient", () => {test("list (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -89,7 +89,7 @@ describe("ModelProvidersClient", () => {test("upsert (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {auth: { api_key: "api_key" },models: [{ model_id: "model_id", name: "name", properties: {} }],@@ -146,7 +146,7 @@ describe("ModelProvidersClient", () => {test("upsert (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {auth: { api_key: "x" },models: [@@ -190,7 +190,7 @@ describe("ModelProvidersClient", () => {test("catalog (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: [@@ -232,7 +232,7 @@ describe("ModelProvidersClient", () => {test("catalog (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -251,7 +251,7 @@ describe("ModelProvidersClient", () => {test("catalog (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };diff --git a/packages/sdk/tests/wire/settings/sandboxProviders.test.ts b/packages/sdk/tests/wire/settings/sandboxProviders.test.tsindex bc54c3465..9989413fd 100644--- a/packages/sdk/tests/wire/settings/sandboxProviders.test.ts+++ b/packages/sdk/tests/wire/settings/sandboxProviders.test.ts@@ -7,7 +7,7 @@ import { mockServerPool } from "../../mock-server/MockServerPool";describe("SandboxProvidersClient", () => {test("get (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: {@@ -47,7 +47,7 @@ describe("SandboxProvidersClient", () => {test("get (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -66,7 +66,7 @@ describe("SandboxProvidersClient", () => {test("upsert (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {auth: { api_key: "api_key" },auto_archive_interval_in_minutes: 1,@@ -125,7 +125,7 @@ describe("SandboxProvidersClient", () => {test("upsert (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = {auth: { api_key: "x" },auto_archive_interval_in_minutes: 1,@@ -163,7 +163,7 @@ describe("SandboxProvidersClient", () => {test("catalog (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: [@@ -203,7 +203,7 @@ describe("SandboxProvidersClient", () => {test("catalog (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -222,7 +222,7 @@ describe("SandboxProvidersClient", () => {test("catalog (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };diff --git a/packages/sdk/tests/wire/settings/skills.test.ts b/packages/sdk/tests/wire/settings/skills.test.tsindex d6b6084d6..a1f3bcf29 100644--- a/packages/sdk/tests/wire/settings/skills.test.ts+++ b/packages/sdk/tests/wire/settings/skills.test.ts@@ -7,7 +7,7 @@ import { mockServerPool } from "../../mock-server/MockServerPool";describe("SkillsClient", () => {test("list (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: [{ description: "description", name: "name", path: "path", ref: "ref", type: "git", url: "url" }],@@ -38,7 +38,7 @@ describe("SkillsClient", () => {test("list (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -57,7 +57,7 @@ describe("SkillsClient", () => {test("list (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -76,7 +76,7 @@ describe("SkillsClient", () => {test("upsert (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { description: "description", name: "name", ref: "ref", type: "git", url: "url" };const rawResponseBody = {data: { description: "description", name: "name", path: "path", ref: "ref", type: "git", url: "url" },@@ -112,7 +112,7 @@ describe("SkillsClient", () => {test("upsert (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawRequestBody = { description: "x", name: "xy", ref: "x", type: "git", url: "x" };const rawResponseBody = { error: { message: "message" } };@@ -138,7 +138,7 @@ describe("SkillsClient", () => {test("catalog (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = {data: [{ description: "description", name: "name", path: "path", ref: "ref", type: "git", url: "url" }],@@ -169,7 +169,7 @@ describe("SkillsClient", () => {test("catalog (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };@@ -188,7 +188,7 @@ describe("SkillsClient", () => {test("catalog (3)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };diff --git a/packages/sdk/tests/wire/skills.test.ts b/packages/sdk/tests/wire/skills.test.tsindex 3435c4997..26963a10b 100644--- a/packages/sdk/tests/wire/skills.test.ts+++ b/packages/sdk/tests/wire/skills.test.ts@@ -7,7 +7,7 @@ import { mockServerPool } from "../mock-server/MockServerPool";describe("SkillsClient", () => {test("list (1)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { data: [{ description: "description", name: "name" }] };@@ -26,7 +26,7 @@ describe("SkillsClient", () => {test("list (2)", async () => {const server = mockServerPool.createServer();- const client = new TrueForge({ maxRetries: 0, baseUrl: server.baseUrl });+ const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });const rawResponseBody = { error: { message: "message" } };diff --git a/packages/server/scripts/write-openapi.ts b/packages/server/scripts/write-openapi.tsindex 297c0f991..ce6b89101 100644--- a/packages/server/scripts/write-openapi.ts+++ b/packages/server/scripts/write-openapi.ts@@ -69,7 +69,10 @@ const app = createServerApp({oidcClient: undefined,});-const document = buildOpenApiDocument(app);+// Runtime apps only advertise BearerAuth when OIDC is configured. The committed+// Fern OpenAPI still documents optional Bearer so the SDK keeps `token` support+// (`buildOpenApiDocument` registers the scheme when authEnabled).+const document = buildOpenApiDocument(app, { authEnabled: true });const sdkOutputPath = path.join(import.meta.dirname, '../../../.github/fern/openapi/openapi.json');mkdirSync(path.dirname(sdkOutputPath), { recursive: true });writeFileSync(sdkOutputPath, `${JSON.stringify(canonicalise(document), null, 2)}\n`);diff --git a/packages/server/src/apis/settings.ts b/packages/server/src/apis/settings.tsindex 19f520cfc..940df5e7a 100644--- a/packages/server/src/apis/settings.ts+++ b/packages/server/src/apis/settings.ts@@ -1,7 +1,7 @@/*** Admin/settings API surface under /api/v1/settings.* Sub-routers (model-providers, mcp-servers, skills, sandbox-providers) mount here.- * Auth is applied at the /api/v1/settings mount boundary in app.ts (admin when OIDC is on).+ * Auth is applied at the /api/v1/settings mount boundary in app.ts (admin when auth is enabled).*/import { OpenAPIHono } from '@hono/zod-openapi';import type { Logger } from 'winston';diff --git a/packages/server/src/app.ts b/packages/server/src/app.tsindex 4bc5ebcd3..bf0092244 100644--- a/packages/server/src/app.ts+++ b/packages/server/src/app.ts@@ -35,6 +35,8 @@ import type { ActiveTurnRegistry } from './runtime/activeTurns';import type { EventSubscriptionRegistry } from './runtime/event-subscription';import { zodErrorResponse, zodValidationHook } from './zodErrorResponse';+const BEARER_AUTH_SCHEME = 'BearerAuth';+const openApiDocConfig = {openapi: '3.1.0',info: {@@ -43,17 +45,39 @@ const openApiDocConfig = {'HTTP API for the TrueForge agent server (`/api/v1`). Interactive docs are served at `/api/v1/docs` ' +'(OpenAPI JSON at `/api/v1/openapi.json`).\n\n' +'**Authentication:** Standalone deployments (no OIDC) accept requests without credentials — middleware ' +- 'stamps a local default user. When OIDC is configured, browser login sets an httpOnly `id_token` cookie; ' +- 'protected routes read that cookie (not `Authorization: Bearer`). There is no built-in API-key scheme; ' ++ 'stamps a local default user. When OIDC is configured, protected routes require a valid `id_token` cookie ' ++ 'or `Authorization: Bearer` ID token. There is no built-in API-key scheme; ' +'pass custom headers only if your reverse proxy or IdP layer requires them.\n\n' +'Covers DB-backed sessions, the agent registry, settings catalogs, and model/MCP/skill/sandbox providers.',version: '0.1.0',},};-/** Single source for both the served document and the one the SDK is built from. */-export function buildOpenApiDocument(app: OpenAPIHono) {- return app.getOpenAPI31Document(openApiDocConfig);+/** Registers the Bearer ID-token scheme used by {@link buildOpenApiDocument}. */+export function registerOpenApiBearerAuth(app: OpenAPIHono): void {+ app.openAPIRegistry.registerComponent('securitySchemes', BEARER_AUTH_SCHEME, {+ type: 'http',+ scheme: 'bearer',+ bearerFormat: 'JWT',+ description:+ 'ID token (`Authorization: Bearer <id_token>`). Required on protected routes. ' ++ 'Browser sessions may use the HttpOnly `id_token` cookie instead.',+ });+}++/**+ * Single source for both the served document and the one the SDK is built from.+ * When `authEnabled`, advertises required Bearer auth on operations that inherit global security.+ */+export function buildOpenApiDocument(app: OpenAPIHono, options?: { authEnabled?: boolean }) {+ const authEnabled = options?.authEnabled ?? false;+ if (authEnabled) {+ registerOpenApiBearerAuth(app);+ }+ return app.getOpenAPI31Document({+ ...openApiDocConfig,+ ...(authEnabled ? { security: [{ [BEARER_AUTH_SCHEME]: [] }] } : {}),+ });}function routeNotFound(c: Context) {@@ -104,6 +128,7 @@ export interface ServerDeps<TTransaction> {export function createServerApp<TTransaction>(deps: ServerDeps<TTransaction>) {const app = new OpenAPIHono({ defaultHook: zodValidationHook });+ const authEnabled = deps.oidcClient != null;app.get('/healthz', c => c.text('OK!'));@@ -227,7 +252,7 @@ export function createServerApp<TTransaction>(deps: ServerDeps<TTransaction>) {);app.get('/api/v1/docs', swaggerUI({ url: '/api/v1/openapi.json' }));- app.get('/api/v1/openapi.json', c => c.json(buildOpenApiDocument(app)));+ app.get('/api/v1/openapi.json', c => c.json(buildOpenApiDocument(app, { authEnabled })));app.notFound(routeNotFound);diff --git a/packages/server/src/auth/identity.ts b/packages/server/src/auth/identity.tsindex 1aa98eed1..fc46a1ab6 100644--- a/packages/server/src/auth/identity.ts+++ b/packages/server/src/auth/identity.ts@@ -17,7 +17,7 @@ export const LOCAL_USER_CONTEXT: UserContext = {role: 'admin',};-/** Standalone/no IdP: always true. With OIDC: admin role only. */+/** Auth disabled: always true. Auth enabled: admin role only. */export function isAdmin(user: UserContext): boolean {if (!getOidcVerify()) {return true;diff --git a/packages/server/src/auth/middleware.ts b/packages/server/src/auth/middleware.tsindex e6f6f3485..74dfecca1 100644--- a/packages/server/src/auth/middleware.ts+++ b/packages/server/src/auth/middleware.ts@@ -12,8 +12,35 @@ declare module 'hono' {}}+const AUTH_HEADER_TYPE = 'Bearer';++/**+ * OIDC ID token from `Authorization: Bearer <jwt>` when present.+ * Case-insensitive scheme; rejects empty credentials. Non-Bearer schemes → undefined+ * so cookie auth can still apply.+ */+export function readBearerIdToken(c: Context): string | undefined {+ const header = c.req.header('Authorization')?.trim();+ if (!header) {+ return undefined;+ }+ const prefix = `${AUTH_HEADER_TYPE} `;+ if (!header.toLowerCase().startsWith(prefix.toLowerCase())) {+ return undefined;+ }+ const token = header.slice(prefix.length).trim();+ return token.length > 0 ? token : undefined;+}++/**+ * Prefer Bearer over the browser cookie when both are sent (explicit API auth wins).+ */+export function readIdToken(c: Context): string | undefined {+ return readBearerIdToken(c) ?? readIdTokenCookie({ context: c });+}+/**- * Cookie → {@link UserContext} when OIDC is on and the token is valid.+ * Bearer or cookie ID token → {@link UserContext} when auth is enabled and the JWT is valid.* Missing/invalid JWT → `undefined`. Claim mapping failures after a successful verify rethrow.*/export async function resolveAuthUser(c: Context): Promise<UserContext | undefined> {@@ -22,7 +49,7 @@ export async function resolveAuthUser(c: Context): Promise<UserContext | undefinreturn undefined;}- const token = readIdTokenCookie({ context: c });+ const token = readIdToken(c);if (!token) {return undefined;}@@ -41,7 +68,7 @@ export async function resolveAuthUser(c: Context): Promise<UserContext | undefinreturn toUserContext(claims, oidcVerify.oidcConfig);}-/** Set `c.var.user` and continue, or throw 401. Without OIDC, sets {@link LOCAL_USER_CONTEXT}. */+/** Set `c.var.user` and continue, or throw 401. When auth is disabled, sets {@link LOCAL_USER_CONTEXT}. */export const authMiddleware: MiddlewareHandler = async (c, next) => {if (!getOidcVerify()) {c.set('user_context', LOCAL_USER_CONTEXT);@@ -64,7 +91,7 @@ export const authMiddleware: MiddlewareHandler = async (c, next) => {return next();};-/** Standalone admin gate: no-op without OIDC; with OIDC requires an authenticated admin. */+/** Admin gate: no-op when auth is disabled; when auth is enabled requires an authenticated admin. */export const adminAuthMiddleware: MiddlewareHandler = async (c, next) => {if (!getOidcVerify()) {return next();diff --git a/packages/server/src/auth/oidc.ts b/packages/server/src/auth/oidc.tsindex f034dc3db..7504904b6 100644--- a/packages/server/src/auth/oidc.ts+++ b/packages/server/src/auth/oidc.ts@@ -17,7 +17,7 @@ const CALLBACK_PATH = '/api/v1/auth/callback';const OAUTH_STATE_MAX_AGE_SECONDS = 10 * 60;const ID_TOKEN_COOKIE_MAX_AGE_SECONDS = 24 * 60 * 60;-/** JWKS + claim config used by cookie JWT verification when browser OIDC is on. */+/** JWKS + claim config used by cookie JWT verification when auth is enabled. */export interface OidcVerify {jwks: JWTVerifyGetKey;issuer: string;@@ -48,12 +48,12 @@ export function disableOidcAuth(): void {oidcVerify = null;}-/** Active verification config, or `null` when OIDC browser auth is off. */+/** Active verification config, or `null` when auth is disabled. */export function getOidcVerify(): OidcVerify | null {return oidcVerify;}-/** Discover the IdP once at process startup when OIDC is configured; wires cookie auth verification. */+/** Discover the IdP once at process startup when auth is enabled; wires cookie auth verification. */export async function initOidc(oidc: OIDCConfig | undefined): Promise<Configuration | undefined> {if (!oidc) {disableOidcAuth();diff --git a/packages/server/src/main.ts b/packages/server/src/main.tsindex 1a3faeb15..49c5cda8a 100644--- a/packages/server/src/main.ts+++ b/packages/server/src/main.ts@@ -204,9 +204,9 @@ async function createServerRuntime<TTransaction>(persistence: ServerPersistence<const oidc = isOidcConfigured(configuration) ? configuration.OIDC : undefined;if (oidc) {- logger.info('OIDC is configured', { issuer: oidc.OIDC_ISSUER_URL });+ logger.info('Auth is enabled', { issuer: oidc.OIDC_ISSUER_URL });} else {- logger.warn('OIDC is not configured; browser login is disabled');+ logger.warn('Auth is disabled; browser login is off');}const oidcClient = await initOidc(oidc);diff --git a/packages/server/src/routes/authRoutes.ts b/packages/server/src/routes/authRoutes.tsindex eec31180a..132850455 100644--- a/packages/server/src/routes/authRoutes.ts+++ b/packages/server/src/routes/authRoutes.ts@@ -62,8 +62,9 @@ export const meRoute = createRoute({tags: [AUTH_TAG],summary: 'Current session',description:- 'Returns the authenticated caller identity. When OIDC is configured this requires a valid session cookie ' +- '(401 otherwise). Without OIDC, returns the default anonymous identity.',+ 'Returns the authenticated caller identity. When auth is enabled this requires a valid ' ++ '`id_token` cookie or `Authorization: Bearer` ID token (401 otherwise). When auth is disabled, ' ++ 'returns the default identity.','x-fern-sdk-group-name': ['auth'],'x-fern-sdk-method-name': 'me',responses: {@@ -73,7 +74,7 @@ export const meRoute = createRoute({},401: {content: { 'application/json': { schema: RequestErrorResponseSchema } },- description: 'OIDC is configured and the request has no valid session cookie.',+ description: 'Auth is enabled and the request has no valid cookie or Bearer ID token.',},},});diff --git a/packages/server/tests/unit/apis/auth.test.ts b/packages/server/tests/unit/apis/auth.test.tsindex c58860f58..999f807a6 100644--- a/packages/server/tests/unit/apis/auth.test.ts+++ b/packages/server/tests/unit/apis/auth.test.ts@@ -72,7 +72,7 @@ describe('auth router (no identity provider configured)', () => {expect(res.status).toBe(204);});- it('GET /auth/me returns the default identity when OIDC is off', async () => {+ it('GET /auth/me returns the default identity when auth is disabled', async () => {const router = createAuthRouter({ oidcClient: undefined, logger });const res = await router.request('/me');@@ -108,7 +108,7 @@ function cookieValue(cookies: string[], name: string): string | undefined {return undefined;}-describe('auth router (OIDC configured)', () => {+describe('auth router (auth enabled)', () => {const realFetch = globalThis.fetch;let privateKey: Awaited<ReturnType<typeof generateKeyPair>>['privateKey'];let publicJwk: JWK;diff --git a/packages/server/tests/unit/apis/capabilities.test.ts b/packages/server/tests/unit/apis/capabilities.test.tsindex 400c66431..3e36b0701 100644--- a/packages/server/tests/unit/apis/capabilities.test.ts+++ b/packages/server/tests/unit/apis/capabilities.test.ts@@ -86,7 +86,7 @@ describe('capabilities routers', () => {});});- describe('when OIDC is configured', () => {+ describe('when auth is enabled', () => {const realFetch = globalThis.fetch;let privateKey: Awaited<ReturnType<typeof generateKeyPair>>['privateKey'];let oidcClient: Configuration;diff --git a/packages/server/tests/unit/auth/identity.test.ts b/packages/server/tests/unit/auth/identity.test.tsindex 98c56452f..5234adf5e 100644--- a/packages/server/tests/unit/auth/identity.test.ts+++ b/packages/server/tests/unit/auth/identity.test.ts@@ -27,7 +27,7 @@ describe('isAdmin', () => {expect(isAdmin(LOCAL_USER_CONTEXT)).toBe(true);});- it('checks role when OIDC is configured', async () => {+ it('checks role when auth is enabled', async () => {globalThis.fetch = async () =>new Response(JSON.stringify({diff --git a/packages/server/tests/unit/auth/middleware.test.ts b/packages/server/tests/unit/auth/middleware.test.tsindex 0884a636b..8657f4e54 100644--- a/packages/server/tests/unit/auth/middleware.test.ts+++ b/packages/server/tests/unit/auth/middleware.test.ts@@ -56,7 +56,7 @@ function createApp() {}describe('authMiddleware', () => {- it('allows settings without admin role when OIDC is not configured', async () => {+ it('allows settings without admin role when auth is disabled', async () => {disableOidcAuth();const res = await createApp().request('/api/v1/settings');expect(res.status).toBe(200);@@ -66,7 +66,7 @@ describe('authMiddleware', () => {});});- it('sets default user when OIDC is not configured', async () => {+ it('sets default user when auth is disabled', async () => {disableOidcAuth();const res = await createApp().request('/api/v1/models');expect(res.status).toBe(200);@@ -76,7 +76,7 @@ describe('authMiddleware', () => {});});- describe('when OIDC is configured', () => {+ describe('when auth is enabled', () => {const realFetch = globalThis.fetch;let privateKey: Awaited<ReturnType<typeof generateKeyPair>>['privateKey'];let oidcClient: Configuration;@@ -141,7 +141,7 @@ describe('authMiddleware', () => {.sign(privateKey);}- it('returns 401 when the id_token cookie is missing', async () => {+ it('returns 401 when the id_token cookie and Bearer token are missing', async () => {const res = await createApp().request('/api/v1/models');expect(res.status).toBe(401);expect(await res.json()).toEqual({ error: { message: 'Authentication required' } });@@ -155,6 +155,14 @@ describe('authMiddleware', () => {expect(await res.json()).toEqual({ error: { message: 'Authentication required' } });});+ it('returns 401 when the Bearer token is invalid', async () => {+ const res = await createApp().request('/api/v1/models', {+ headers: { Authorization: 'Bearer not-a-jwt' },+ });+ expect(res.status).toBe(401);+ expect(await res.json()).toEqual({ error: { message: 'Authentication required' } });+ });+it('returns 401 when the token has the wrong issuer', async () => {const token = await createIdToken({ issuer: 'https://other.example.com' });const res = await createApp().request('/api/v1/models', {@@ -194,6 +202,49 @@ describe('authMiddleware', () => {});});+ it('sets user context from Authorization Bearer ID token', async () => {+ const token = await createIdToken({ sub: 'alice', groups: ['admin'] });+ const res = await createApp().request('/api/v1/models', {+ headers: { Authorization: `Bearer ${token}` },+ });+ expect(res.status).toBe(200);+ expect(await res.json()).toEqual({+ ok: true,+ user: { userRef: 'alice', role: 'admin' },+ });+ });++ it('prefers Bearer over cookie when both are present', async () => {+ const cookieToken = await createIdToken({ sub: 'cookie-user', groups: [] });+ const bearerToken = await createIdToken({ sub: 'bearer-user', groups: ['admin'] });+ const res = await createApp().request('/api/v1/models', {+ headers: {+ Cookie: `id_token=${cookieToken}`,+ Authorization: `Bearer ${bearerToken}`,+ },+ });+ expect(res.status).toBe(200);+ expect(await res.json()).toEqual({+ ok: true,+ user: { userRef: 'bearer-user', role: 'admin' },+ });+ });++ it('ignores non-Bearer Authorization and falls back to cookie', async () => {+ const token = await createIdToken({ sub: 'alice', groups: ['admin'] });+ const res = await createApp().request('/api/v1/models', {+ headers: {+ Authorization: `Basic ${token}`,+ Cookie: `id_token=${token}`,+ },+ });+ expect(res.status).toBe(200);+ expect(await res.json()).toEqual({+ ok: true,+ user: { userRef: 'alice', role: 'admin' },+ });+ });+it('allows settings when the caller has admin role', async () => {const token = await createIdToken({ sub: 'alice', groups: ['admin'] });const res = await createApp().request('/api/v1/settings', {@@ -206,6 +257,18 @@ describe('authMiddleware', () => {});});+ it('allows settings with Bearer when the caller has admin role', async () => {+ const token = await createIdToken({ sub: 'alice', groups: ['admin'] });+ const res = await createApp().request('/api/v1/settings', {+ headers: { Authorization: `Bearer ${token}` },+ });+ expect(res.status).toBe(200);+ expect(await res.json()).toEqual({+ ok: true,+ user: { userRef: 'alice', role: 'admin' },+ });+ });+it('returns 403 on settings when the caller is not admin', async () => {const token = await createIdToken({ sub: 'bob', groups: ['everyone'] });const res = await createApp().request('/api/v1/settings', {