Tela SDK for JavaScript
    Preparing search index...

    Class Agents

    Agents API resource.

    const tela = new TelaSDK({ apiKey: '...' })

    // Warm a session while the user prepares their first message.
    await tela.agents.wake({ agentId: 'agent-123' })

    // Start a session by agent id (`POST /agent/:id/run`).
    const { sessionId } = await tela.agents.run({
    agentId: 'agent-123',
    message: 'Summarize the latest tickets',
    inputs: {
    report: tela.createFile('https://example.com/q3.pdf'),
    notes: { type: 'text', content: 'Focus on churn.' },
    },
    })

    // Stream / inspect / cancel by session id (agent-sdk pass-through).
    for await (const event of await tela.agents.streamSession(sessionId))
    console.log(event.kind)
    const timeline = await tela.agents.fetchTimeline(sessionId)
    Index

    Constructors

    Properties

    cancelSession: (sessionId: string) => Promise<{} | {}>

    Cancels a running session. Pass-through to the agent-sdk client (POST /v4/sessions/:id/cancel).

    fetchThread: (sessionId: string, options?: FetchTimelineOptions) => Promise<{}>

    Fetches the session's cross-turn message history. Pass-through to the agent-sdk client (GET /v4/sessions/:id/thread).

    fetchTimeline: (
        sessionId: string,
        options?: FetchTimelineOptions,
    ) => Promise<{}>

    Fetches the session timeline summary. Pass-through to the agent-sdk client (GET /v4/sessions/:id/timeline).

    resolveReference: {
        (reference: string, options?: {}): Promise<ArrayBuffer>;
        (reference: string, options: {}): Promise<ReadableStream<Uint8Array>>;
        <T = unknown>(reference: string, options: {}): Promise<T>;
    }

    Resolves a vault:// reference to bytes/stream/json. Pass-through to the agent-sdk client.

    streamSession: (
        sessionId: string,
        options?: StreamSessionOptions,
    ) => Promise<AsyncIterable<{} | {} | {} | {} | {}, any, any>>

    Streams a session's events. Pass-through to the agent-sdk client (GET /v4/sessions/:id).

    updateSessionModel: (input: {}) => Promise<{} | {}>

    Updates the model used by a session. Pass-through to the agent-sdk client (PUT /v4/sessions/:id/model). This works before the first message and between turns; an actively processing turn rejects the change.

    Methods

    • Fetches an agent record by id via the Tela gateway (GET /agent/:id).

      Parameters

      • agentId: string

      Returns Promise<AgentRecord>

    • Starts (or continues) an agent session via the Tela gateway (POST /agent/:id/run).

      • New session: pass agentId (+ message).
      • Prepared wake: pass agentId and the wakeSessionId returned by wake. Tela resolves the repository identity internally.
      • Continue: pass agentId and the existing sessionId.

      The per-variable inputs map is flattened into the wire inputSchema array (each entry tagged with its variable name); any TelaFile inputs are uploaded to the vault first. Returns the sessionId to stream/inspect.

      Parameters

      Returns Promise<{} | {}>

    • Starts (or continues) an agent session with direct streaming enabled via the Tela gateway (POST /agent/:id/run/direct-stream).

      Accepts the same inputs and returns the same response as run; the dedicated path opts the upstream Agent API execution into its direct stream transport.

      Parameters

      Returns Promise<{} | {}>

    • Updates an agent's model, delegating to the agent-sdk client (PUT /v4/agents/:repository/model). The agentId is resolved to the underlying repository first.

      Parameters

      Returns Promise<{} | {}>

    • Starts warming an agent session or re-wakes an existing paused session, delegating to the agent-sdk client (POST /v4/agents/:organizationName/:repository/wake). The Tela agentId is resolved to its organization and repository first.

      Pass runtime environment variables here so they are injected before the worker is primed; do not resend them when claiming the returned session.

      Pass the same webhooks to run when claiming the warmed session.

      Parameters

      Returns Promise<{} | {}>