genkit
Version:
Genkit AI framework
53 lines (49 loc) • 1.95 kB
TypeScript
import { AgentAPI } from '@genkit-ai/ai/agent-core';
export { AgentAPI, AgentChat, AgentChunk, AgentError, AgentInterrupt, AgentResponse, AgentTurn, DetachedTask } from '@genkit-ai/ai/agent-core';
export { JsonPatch, applyPatch } from '@genkit-ai/ai/json-patch';
/**
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Options for {@link remoteAgent}.
*/
interface RemoteAgentOptions {
/** Required. The agent endpoint. */
url: string;
/** Optional. Defaults to `${url}/getSnapshot`. */
getSnapshotUrl?: string;
/** Optional. Defaults to `${url}/abort`. */
abortUrl?: string;
/** Optional. Static headers, or a function called per request. */
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
/** Optional. Declares server- vs client-managed state; inferred otherwise. */
stateManagement?: 'server' | 'client';
}
/**
* Creates a typed client for talking to a Genkit agent over HTTP.
*
* ```ts
* import { remoteAgent } from 'genkit/beta/client';
*
* const agent = remoteAgent<WeatherState>({
* url: '/api/weatherAgent',
* });
* const chat = agent.chat();
* const res = await chat.send('Weather in Tokyo?').response;
* console.log(res.text);
* ```
*/
declare function remoteAgent<State = unknown>(options: RemoteAgentOptions): AgentAPI<State>;
export { type RemoteAgentOptions, remoteAgent };