Skip to content

Commit

Permalink
chore: export types
Browse files Browse the repository at this point in the history
  • Loading branch information
iowillhoit committed Feb 1, 2025
1 parent 6dd1d16 commit 132370e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
32 changes: 16 additions & 16 deletions src/agentPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ type ApiStatus = {

type Href = { href: string };

type Links = {
export type AgentPreviewMessageLinks = {
self: Href | null;
messages: Href | null;
session: Href | null;
end: Href | null;
};

type Message = {
export type AgentPreviewMessage = {
type: string;
id: string;
feedbackId: string;
Expand All @@ -40,25 +40,25 @@ type Message = {
};
};

type StartResponse = {
export type AgentPreviewStartResponse = {
sessionId: string;
_links: Links;
messages: Message[];
_links: AgentPreviewMessageLinks;
messages: AgentPreviewMessage[];
};

type SendResponse = {
messages: Message[];
_links: Links;
export type AgentPreviewSendResponse = {
messages: AgentPreviewMessage[];
_links: AgentPreviewMessageLinks;
};

type EndResponse = {
export type AgentPreviewEndResponse = {
messages: {
type: string;
id: string;
reason: string;
feedbackId: string;
};
_links: Links;
_links: AgentPreviewMessageLinks;
};

type EndReason = 'UserRequest' | 'Transfer' | 'Expiration' | 'Error' | 'Other';
Expand All @@ -85,7 +85,7 @@ export class AgentPreview {
};
}

public async start(botId: string): Promise<StartResponse> {
public async start(botId: string): Promise<AgentPreviewStartResponse> {
const url = `${this.tempApiBase}/einstein/ai-agent/v1/agents/${botId}/sessions`;

const body = {
Expand All @@ -100,10 +100,10 @@ export class AgentPreview {
variables: [],
};

return this.got.request<StartResponse>('POST', url, body, this.headers);
return this.got.request<AgentPreviewStartResponse>('POST', url, body, this.headers);
}

public async send(sessionId: string, message: string): Promise<SendResponse> {
public async send(sessionId: string, message: string): Promise<AgentPreviewSendResponse> {
const url = `${this.tempApiBase}/einstein/ai-agent/v1/sessions/${sessionId}/messages`;

const body = {
Expand All @@ -115,13 +115,13 @@ export class AgentPreview {
variables: [],
};

return this.got.request<SendResponse>('POST', url, body, this.headers);
return this.got.request<AgentPreviewSendResponse>('POST', url, body, this.headers);
}

public async end(sessionId: string, reason: EndReason): Promise<EndResponse> {
public async end(sessionId: string, reason: EndReason): Promise<AgentPreviewEndResponse> {
const url = `${this.tempApiBase}/einstein/ai-agent/v1/sessions/${sessionId}`;

return this.got.request<EndResponse>('DELETE', url, undefined, {
return this.got.request<AgentPreviewEndResponse>('DELETE', url, undefined, {
...this.headers,
'x-session-end-reason': reason,
});
Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ export {
type TestCaseResult,
type TestStatus,
} from './agentTester';
export { AgentPreview } from './agentPreview';
export {
AgentPreview,
type AgentPreviewMessageLinks,
type AgentPreviewMessage,
type AgentPreviewStartResponse,
type AgentPreviewSendResponse,
type AgentPreviewEndResponse,
} from './agentPreview';

0 comments on commit 132370e

Please sign in to comment.