bothy-sdk
    Preparing search index...

    Interface ApiClientExtras

    The members createApiClient adds to the openapi-fetch client.

    interface ApiClientExtras {
        clock: Clock;
        logger: Logger;
        settings: SdkSettings;
        timeoutMs: number;
        bindRun<T>(
            runId: string,
            token: string | Secret,
            fn: () => Promise<T>,
        ): Promise<T>;
        boundRunId(): string | undefined;
        dpopNonce(): string | undefined;
        setRunToken(runId: string, token: string | Secret): void;
        unbound<T>(fn: () => Promise<T>): Promise<T>;
    }
    Index

    Properties

    clock: Clock

    The time source of the client.

    logger: Logger

    The logger of the client.

    settings: SdkSettings

    The resolved SDK settings.

    timeoutMs: number

    The bound of one attempt in milliseconds.

    Methods

    • Runs fn with every request of this client inside it bound to runId: each carries the run's newest invocation token in Invocation-Token (07 SR9). The binding lives in an AsyncLocalStorage, so two concurrent runs never see each other's token.

      Type Parameters

      • T

      Parameters

      • runId: string

        The run.

      • token: string | Secret

        The run's newest invocation token.

      • fn: () => Promise<T>

        The work of the run.

      Returns Promise<T>

      The result of fn.

    • Returns the run the current context is bound to.

      Returns string | undefined

      The run ID, or undefined outside ApiClientExtras.bindRun.

    • Returns the newest DPoP-Nonce the server sent (the gateway proof starts from it).

      Returns string | undefined

      The nonce, or undefined before the first one.

    • Makes token the token every request bound to runId carries from now on (after a renewal or a newer delivery); a run without an active binding is left alone.

      Parameters

      • runId: string

        The run.

      • token: string | Secret

        The newer token.

      Returns void

    • Runs fn without any run binding (the agent's own writes inside a run).

      Type Parameters

      • T

      Parameters

      • fn: () => Promise<T>

        The work.

      Returns Promise<T>

      The result of fn.