Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

5.0 KB
Raw Blame
// This file was auto-generated by Fern from our API Definition.

import { AgentsClient } from "./api/resources/agents/client/Client.js";
import { AuthClient } from "./api/resources/auth/client/Client.js";
import { CatalogsClient } from "./api/resources/catalogs/client/Client.js";
import { InternalClient } from "./api/resources/internal/client/Client.js";
import { McpServersClient } from "./api/resources/mcpServers/client/Client.js";
import { ModelsClient } from "./api/resources/models/client/Client.js";
import { SandboxEnvironmentsClient } from "./api/resources/sandboxEnvironments/client/Client.js";
import { SchedulesClient } from "./api/resources/schedules/client/Client.js";
import { ServerClient } from "./api/resources/server/client/Client.js";
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 NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "./BaseClient.js";
import * as core from "./core/index.js";

export declare namespace TrueForge {
    export type Options = BaseClientOptions;

    export interface RequestOptions extends BaseRequestOptions {}
}

export class TrueForge {
    protected readonly _options: NormalizedClientOptionsWithAuth<TrueForge.Options>;
    protected _internal: InternalClient | undefined;
    protected _agents: AgentsClient | undefined;
    protected _auth: AuthClient | undefined;
    protected _server: ServerClient | undefined;
    protected _mcpServers: McpServersClient | undefined;
    protected _models: ModelsClient | undefined;
    protected _sandboxEnvironments: SandboxEnvironmentsClient | undefined;
    protected _schedules: SchedulesClient | undefined;
    protected _sessions: SessionsClient | undefined;
    protected _skills: SkillsClient | undefined;
    protected _catalogs: CatalogsClient | undefined;
    protected _settings: SettingsClient | undefined;

    constructor(options: TrueForge.Options) {
        this._options = normalizeClientOptionsWithAuth(options);
    }

    public get internal(): InternalClient {
        return (this._internal ??= new InternalClient(this._options));
    }

    public get agents(): AgentsClient {
        return (this._agents ??= new AgentsClient(this._options));
    }

    public get auth(): AuthClient {
        return (this._auth ??= new AuthClient(this._options));
    }

    public get server(): ServerClient {
        return (this._server ??= new ServerClient(this._options));
    }

    public get mcpServers(): McpServersClient {
        return (this._mcpServers ??= new McpServersClient(this._options));
    }

    public get models(): ModelsClient {
        return (this._models ??= new ModelsClient(this._options));
    }

    public get sandboxEnvironments(): SandboxEnvironmentsClient {
        return (this._sandboxEnvironments ??= new SandboxEnvironmentsClient(this._options));
    }

    public get schedules(): SchedulesClient {
        return (this._schedules ??= new SchedulesClient(this._options));
    }

    public get sessions(): SessionsClient {
        return (this._sessions ??= new SessionsClient(this._options));
    }

    public get skills(): SkillsClient {
        return (this._skills ??= new SkillsClient(this._options));
    }

    public get catalogs(): CatalogsClient {
        return (this._catalogs ??= new CatalogsClient(this._options));
    }

    public get settings(): SettingsClient {
        return (this._settings ??= new SettingsClient(this._options));
    }

    /**
     * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
     * This is useful for making requests to endpoints not yet supported in the SDK.
     * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
     *
     * @param {Request | string | URL} input - The URL, path, or Request object.
     * @param {RequestInit} init - Standard fetch RequestInit options.
     * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
     * @returns {Promise<Response>} A standard Response object.
     */
    public async fetch(
        input: Request | string | URL,
        init?: RequestInit,
        requestOptions?: core.PassthroughRequest.RequestOptions,
    ): Promise<Response> {
        return core.makePassthroughRequest(
            input,
            init,
            {
                baseUrl: this._options.baseUrl ?? this._options.environment,
                headers: this._options.headers,
                timeoutInSeconds: this._options.timeoutInSeconds,
                maxRetries: this._options.maxRetries,
                fetch: this._options.fetch,
                logging: this._options.logging,
                getAuthHeaders: async () => (await this._options.authProvider.getAuthRequest()).headers,
            },
            requestOptions,
        );
    }
}