Skip to content

AgentRuns ​

Overview ​

Execute saved agents and inspect persisted run results.

Available Operations ​

listAgentRuns ​

List runs for an agent

Example Usage ​

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.agentRuns.listAgentRuns({
    agentId: "<id>",
  });

  console.log(result);
}

run();

Standalone function ​

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { agentRunsListAgentRuns } from "@meetkai/mka1/funcs/agentRunsListAgentRuns.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await agentRunsListAgentRuns(sdk, {
    agentId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("agentRunsListAgentRuns failed:", res.error);
  }
}

run();

React hooks and utilities ​

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Query hooks for fetching data.
  useAgentRunsListAgentRuns,
  useAgentRunsListAgentRunsSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchAgentRunsListAgentRuns,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidateAgentRunsListAgentRuns,
  invalidateAllAgentRunsListAgentRuns,
} from "@meetkai/mka1/react-query/agentRunsListAgentRuns.js";

Parameters ​

ParameterTypeRequiredDescription
requestoperations.ListAgentRunsRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response ​

Promise<components.AgentRunList>

Errors ​

Error TypeStatus CodeContent Type
errors.ErrorEnvelope401, 404application/json
errors.APIError4XX, 5XX*/*

createAgentRun ​

Starts an asynchronous background run for a saved agent and returns the queued run record. Use the run retrieval endpoint to poll status or the events endpoint to stream progress.

Example Usage ​

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.agentRuns.createAgentRun({
    agentId: "<id>",
    createAgentRunRequest: {
      input: [
        {
          type: "<value>",
        },
      ],
    },
  });

  console.log(result);
}

run();

Standalone function ​

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { agentRunsCreateAgentRun } from "@meetkai/mka1/funcs/agentRunsCreateAgentRun.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await agentRunsCreateAgentRun(sdk, {
    agentId: "<id>",
    createAgentRunRequest: {
      input: [
        {
          type: "<value>",
        },
      ],
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("agentRunsCreateAgentRun failed:", res.error);
  }
}

run();

React hooks and utilities ​

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Mutation hook for triggering the API call.
  useAgentRunsCreateAgentRunMutation
} from "@meetkai/mka1/react-query/agentRunsCreateAgentRun.js";

Parameters ​

ParameterTypeRequiredDescription
requestoperations.CreateAgentRunRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response ​

Promise<components.AgentRun>

Errors ​

Error TypeStatus CodeContent Type
errors.ErrorEnvelope400, 401, 404application/json
errors.ErrorEnvelope502application/json
errors.APIError4XX, 5XX*/*

streamAgentRunEvents ​

Streams Server-Sent Events for the gateway response linked to this agent run. Terminal runs emit a single terminal event and close.

Example Usage ​

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.agentRuns.streamAgentRunEvents({
    agentId: "<id>",
    runId: "<id>",
  });

  console.log(result);
}

run();

Standalone function ​

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { agentRunsStreamAgentRunEvents } from "@meetkai/mka1/funcs/agentRunsStreamAgentRunEvents.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await agentRunsStreamAgentRunEvents(sdk, {
    agentId: "<id>",
    runId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("agentRunsStreamAgentRunEvents failed:", res.error);
  }
}

run();

React hooks and utilities ​

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Query hooks for fetching data.
  useAgentRunsStreamAgentRunEvents,
  useAgentRunsStreamAgentRunEventsSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchAgentRunsStreamAgentRunEvents,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidateAgentRunsStreamAgentRunEvents,
  invalidateAllAgentRunsStreamAgentRunEvents,
} from "@meetkai/mka1/react-query/agentRunsStreamAgentRunEvents.js";

Parameters ​

ParameterTypeRequiredDescription
requestoperations.StreamAgentRunEventsRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response ​

Promise<string>

Errors ​

Error TypeStatus CodeContent Type
errors.ErrorEnvelope401, 404, 409application/json
errors.ErrorEnvelope502application/json
errors.APIError4XX, 5XX*/*

wakeAgentRun ​

Interrupts a short sleep tool call on a background run by forwarding follow-up input to the gateway response.

Example Usage ​

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.agentRuns.wakeAgentRun({
    agentId: "<id>",
    runId: "<id>",
    wakeAgentRunRequest: {
      input: [
        {},
      ],
    },
  });

  console.log(result);
}

run();

Standalone function ​

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { agentRunsWakeAgentRun } from "@meetkai/mka1/funcs/agentRunsWakeAgentRun.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await agentRunsWakeAgentRun(sdk, {
    agentId: "<id>",
    runId: "<id>",
    wakeAgentRunRequest: {
      input: [
        {},
      ],
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("agentRunsWakeAgentRun failed:", res.error);
  }
}

run();

React hooks and utilities ​

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Mutation hook for triggering the API call.
  useAgentRunsWakeAgentRunMutation
} from "@meetkai/mka1/react-query/agentRunsWakeAgentRun.js";

Parameters ​

ParameterTypeRequiredDescription
requestoperations.WakeAgentRunRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response ​

Promise<components.AgentRunWake>

Errors ​

Error TypeStatus CodeContent Type
errors.ErrorEnvelope400, 401, 404, 409application/json
errors.ErrorEnvelope502application/json
errors.APIError4XX, 5XX*/*

decideAgentRunMcpApproval ​

Creates a continuation run for an mcp_approval_request emitted by the source run. The gateway binds the single-use decision to the original server, tool, and arguments; denying never invokes the remote MCP tool.

Example Usage ​

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.agentRuns.decideAgentRunMcpApproval({
    agentId: "<id>",
    runId: "<id>",
    decideAgentRunMcpApprovalRequest: {
      approvalRequestId: "<id>",
      approve: false,
    },
  });

  console.log(result);
}

run();

Standalone function ​

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { agentRunsDecideAgentRunMcpApproval } from "@meetkai/mka1/funcs/agentRunsDecideAgentRunMcpApproval.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await agentRunsDecideAgentRunMcpApproval(sdk, {
    agentId: "<id>",
    runId: "<id>",
    decideAgentRunMcpApprovalRequest: {
      approvalRequestId: "<id>",
      approve: false,
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("agentRunsDecideAgentRunMcpApproval failed:", res.error);
  }
}

run();

React hooks and utilities ​

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Mutation hook for triggering the API call.
  useAgentRunsDecideAgentRunMcpApprovalMutation
} from "@meetkai/mka1/react-query/agentRunsDecideAgentRunMcpApproval.js";

Parameters ​

ParameterTypeRequiredDescription
requestoperations.DecideAgentRunMcpApprovalRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response ​

Promise<components.AgentRunMcpApproval>

Errors ​

Error TypeStatus CodeContent Type
errors.ErrorEnvelope400, 401, 404, 409application/json
errors.ErrorEnvelope502application/json
errors.APIError4XX, 5XX*/*

getAgentRun ​

Retrieve an agent run

Example Usage ​

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.agentRuns.getAgentRun({
    agentId: "<id>",
    runId: "<id>",
  });

  console.log(result);
}

run();

Standalone function ​

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { agentRunsGetAgentRun } from "@meetkai/mka1/funcs/agentRunsGetAgentRun.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await agentRunsGetAgentRun(sdk, {
    agentId: "<id>",
    runId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("agentRunsGetAgentRun failed:", res.error);
  }
}

run();

React hooks and utilities ​

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Query hooks for fetching data.
  useAgentRunsGetAgentRun,
  useAgentRunsGetAgentRunSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchAgentRunsGetAgentRun,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidateAgentRunsGetAgentRun,
  invalidateAllAgentRunsGetAgentRun,
} from "@meetkai/mka1/react-query/agentRunsGetAgentRun.js";

Parameters ​

ParameterTypeRequiredDescription
requestoperations.GetAgentRunRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response ​

Promise<components.AgentRun>

Errors ​

Error TypeStatus CodeContent Type
errors.ErrorEnvelope401, 404application/json
errors.APIError4XX, 5XX*/*