e30e75b5d4
Code Quality / Oxlint + Oxfmt (push) Waiting to run
Code Quality / Template Sync (push) Waiting to run
Code Quality / Build Changed Packages (push) Waiting to run
Code Quality / Test Changed Packages (push) Waiting to run
Deploy Expo Example / Deploy Production (push) Waiting to run
Deploy Ink Example / Deploy Production (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.12) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Waiting to run
Deploy Shadcn Registry / Deploy Production (push) Waiting to run
Template Metrics / LOC + Bundle Size (push) Waiting to run
Changesets / Create Version PR (push) Has been cancelled
437 lines
12 KiB
TypeScript
437 lines
12 KiB
TypeScript
import { UIMessage, UseChatHelpers } from "@ai-sdk/react";
|
|
|
|
import "@standard-schema/spec";
|
|
|
|
import { ChatInit } from "ai";
|
|
|
|
declare class AssistantCloud {
|
|
readonly threads: AssistantCloudThreads;
|
|
readonly auth: {
|
|
tokens: AssistantCloudAuthTokens;
|
|
};
|
|
readonly runs: AssistantCloudRuns;
|
|
readonly files: AssistantCloudFiles;
|
|
readonly telemetry: AssistantCloudTelemetryConfig;
|
|
constructor(config: AssistantCloudConfig);
|
|
}
|
|
|
|
declare class AssistantCloudAPI {
|
|
_auth: AssistantCloudAuthStrategy;
|
|
_baseUrl: string;
|
|
constructor(config: AssistantCloudConfig);
|
|
initializeAuth(): Promise<boolean>;
|
|
makeRawRequest(endpoint: string, options?: MakeRequestOptions): Promise<Response>;
|
|
makeRequest(endpoint: string, options?: MakeRequestOptions): Promise<any>;
|
|
}
|
|
|
|
type AssistantCloudAuthStrategy = {
|
|
readonly strategy: "anon" | "api-key" | "jwt";
|
|
getAuthHeaders(): Promise<Record<string, string> | false>;
|
|
readAuthHeaders(headers: Headers): void;
|
|
};
|
|
|
|
declare class AssistantCloudAuthTokens {
|
|
private cloud;
|
|
constructor(cloud: AssistantCloudAPI);
|
|
create(): Promise<AssistantCloudAuthTokensCreateResponse>;
|
|
}
|
|
|
|
type AssistantCloudAuthTokensCreateResponse = {
|
|
token: string;
|
|
};
|
|
|
|
type AssistantCloudConfig = ({
|
|
baseUrl: string;
|
|
authToken: () => Promise<string | null>;
|
|
} | {
|
|
baseUrl?: string;
|
|
apiKey: string;
|
|
userId: string;
|
|
workspaceId: string;
|
|
} | {
|
|
baseUrl: string;
|
|
anonymous: true;
|
|
}) & {
|
|
telemetry?: boolean | AssistantCloudTelemetryConfig;
|
|
};
|
|
|
|
declare class AssistantCloudFiles {
|
|
private cloud;
|
|
constructor(cloud: AssistantCloudAPI);
|
|
pdfToImages(body: PdfToImagesRequestBody): Promise<PdfToImagesResponse>;
|
|
generatePresignedUploadUrl(body: GeneratePresignedUploadUrlRequestBody): Promise<GeneratePresignedUploadUrlResponse>;
|
|
}
|
|
|
|
type AssistantCloudMessageCreateResponse = {
|
|
message_id: string;
|
|
};
|
|
|
|
type AssistantCloudRunReport = {
|
|
thread_id: string;
|
|
status: "completed" | "error" | "incomplete";
|
|
total_steps?: number;
|
|
tool_calls?: ReportToolCall[];
|
|
steps?: {
|
|
input_tokens?: number;
|
|
output_tokens?: number;
|
|
reasoning_tokens?: number;
|
|
cached_input_tokens?: number;
|
|
tool_calls?: ReportToolCall[];
|
|
start_ms?: number;
|
|
end_ms?: number;
|
|
}[];
|
|
input_tokens?: number;
|
|
output_tokens?: number;
|
|
reasoning_tokens?: number;
|
|
cached_input_tokens?: number;
|
|
model_id?: string;
|
|
provider_type?: string;
|
|
duration_ms?: number;
|
|
output_text?: string;
|
|
metadata?: Record<string, unknown>;
|
|
};
|
|
|
|
declare class AssistantCloudRuns {
|
|
private cloud;
|
|
constructor(cloud: AssistantCloudAPI);
|
|
__internal_getAssistantOptions(assistantId: string): {
|
|
api: string;
|
|
headers: () => Promise<{
|
|
Accept: string;
|
|
}>;
|
|
body: {
|
|
assistant_id: string;
|
|
response_format: string;
|
|
thread_id: string;
|
|
};
|
|
};
|
|
stream(body: AssistantCloudRunsStreamBody): Promise<AssistantStream>;
|
|
report(body: AssistantCloudRunReport): Promise<{
|
|
run_id: string;
|
|
}>;
|
|
}
|
|
|
|
type AssistantCloudRunsStreamBody = {
|
|
thread_id: string;
|
|
assistant_id: "system/thread_title";
|
|
messages: readonly unknown[];
|
|
};
|
|
|
|
type AssistantCloudTelemetryConfig = {
|
|
enabled?: boolean;
|
|
beforeReport?: (report: AssistantCloudRunReport) => AssistantCloudRunReport | null;
|
|
};
|
|
|
|
type AssistantCloudThreadMessageCreateBody = {
|
|
parent_id: string | null;
|
|
format: "aui/v0" | string;
|
|
content: ReadonlyJSONObject;
|
|
};
|
|
|
|
type AssistantCloudThreadMessageListQuery = {
|
|
format?: string;
|
|
};
|
|
|
|
type AssistantCloudThreadMessageListResponse = {
|
|
messages: CloudMessage[];
|
|
};
|
|
|
|
type AssistantCloudThreadMessageUpdateBody = {
|
|
content: ReadonlyJSONObject;
|
|
};
|
|
|
|
declare class AssistantCloudThreadMessages {
|
|
private cloud;
|
|
constructor(cloud: AssistantCloudAPI);
|
|
list(threadId: string, query?: AssistantCloudThreadMessageListQuery): Promise<AssistantCloudThreadMessageListResponse>;
|
|
create(threadId: string, body: AssistantCloudThreadMessageCreateBody): Promise<AssistantCloudMessageCreateResponse>;
|
|
update(threadId: string, messageId: string, body: AssistantCloudThreadMessageUpdateBody): Promise<void>;
|
|
}
|
|
|
|
declare class AssistantCloudThreads {
|
|
private cloud;
|
|
readonly messages: AssistantCloudThreadMessages;
|
|
constructor(cloud: AssistantCloudAPI);
|
|
list(query?: AssistantCloudThreadsListQuery): Promise<AssistantCloudThreadsListResponse>;
|
|
get(threadId: string): Promise<CloudThread$1>;
|
|
create(body: AssistantCloudThreadsCreateBody): Promise<AssistantCloudThreadsCreateResponse>;
|
|
update(threadId: string, body: AssistantCloudThreadsUpdateBody): Promise<void>;
|
|
delete(threadId: string): Promise<void>;
|
|
}
|
|
|
|
type AssistantCloudThreadsCreateBody = {
|
|
title?: string | undefined;
|
|
last_message_at: Date;
|
|
metadata?: unknown | undefined;
|
|
external_id?: string | undefined;
|
|
};
|
|
|
|
type AssistantCloudThreadsCreateResponse = {
|
|
thread_id: string;
|
|
};
|
|
|
|
type AssistantCloudThreadsListQuery = {
|
|
is_archived?: boolean;
|
|
limit?: number;
|
|
after?: string;
|
|
};
|
|
|
|
type AssistantCloudThreadsListResponse = {
|
|
threads: CloudThread$1[];
|
|
};
|
|
|
|
type AssistantCloudThreadsUpdateBody = {
|
|
title?: string | undefined;
|
|
last_message_at?: Date | undefined;
|
|
metadata?: unknown | undefined;
|
|
is_archived?: boolean | undefined;
|
|
};
|
|
|
|
type AssistantStream = ReadableStream<AssistantStreamChunk>;
|
|
|
|
declare const AssistantStream: {
|
|
toResponse(stream: AssistantStream, transformer: AssistantStreamEncoder): Response;
|
|
fromResponse(response: Response, transformer: ReadableWritablePair<AssistantStreamChunk, Uint8Array<ArrayBuffer>>): ReadableStream<AssistantStreamChunk>;
|
|
toByteStream(stream: AssistantStream, transformer: ReadableWritablePair<Uint8Array<ArrayBuffer>, AssistantStreamChunk>): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
fromByteStream(readable: ReadableStream<Uint8Array<ArrayBuffer>>, transformer: ReadableWritablePair<AssistantStreamChunk, Uint8Array<ArrayBuffer>>): ReadableStream<AssistantStreamChunk>;
|
|
};
|
|
|
|
type AssistantStreamChunk = {
|
|
readonly path: readonly number[];
|
|
} & ({
|
|
readonly type: "part-start";
|
|
readonly part: PartInit;
|
|
} | {
|
|
readonly type: "part-finish";
|
|
} | {
|
|
readonly type: "tool-call-args-text-finish";
|
|
} | {
|
|
readonly type: "text-delta";
|
|
readonly textDelta: string;
|
|
} | {
|
|
readonly type: "annotations";
|
|
readonly annotations: ReadonlyJSONValue[];
|
|
} | {
|
|
readonly type: "data";
|
|
readonly data: ReadonlyJSONValue[];
|
|
} | {
|
|
readonly type: "step-start";
|
|
readonly messageId: string;
|
|
} | {
|
|
readonly type: "step-finish";
|
|
readonly finishReason: "content-filter" | "error" | "length" | "other" | "stop" | "tool-calls" | "unknown";
|
|
readonly usage: {
|
|
readonly inputTokens: number;
|
|
readonly outputTokens: number;
|
|
};
|
|
readonly isContinued: boolean;
|
|
} | {
|
|
readonly type: "message-finish";
|
|
readonly finishReason: "content-filter" | "error" | "length" | "other" | "stop" | "tool-calls" | "unknown";
|
|
readonly usage: {
|
|
readonly inputTokens: number;
|
|
readonly outputTokens: number;
|
|
};
|
|
} | {
|
|
readonly type: "result";
|
|
readonly artifact?: ReadonlyJSONValue;
|
|
readonly result: ReadonlyJSONValue;
|
|
readonly isError: boolean;
|
|
readonly modelContent?: readonly ToolModelContentPart[];
|
|
readonly messages?: ReadonlyJSONValue;
|
|
} | {
|
|
readonly type: "error";
|
|
readonly error: string;
|
|
} | {
|
|
readonly type: "update-state";
|
|
readonly operations: ObjectStreamOperation[];
|
|
});
|
|
|
|
type AssistantStreamEncoder = ReadableWritablePair<Uint8Array<ArrayBuffer>, AssistantStreamChunk> & {
|
|
headers?: Headers;
|
|
};
|
|
|
|
type CloudMessage = {
|
|
id: string;
|
|
parent_id: string | null;
|
|
height: number;
|
|
created_at: Date;
|
|
updated_at: Date;
|
|
format: "aui/v0" | string;
|
|
content: ReadonlyJSONObject;
|
|
};
|
|
|
|
type CloudThread = {
|
|
id: string;
|
|
title: string;
|
|
status: ThreadStatus;
|
|
externalId: string | null;
|
|
lastMessageAt: Date;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
};
|
|
|
|
type CloudThread$1 = {
|
|
title: string;
|
|
last_message_at: Date;
|
|
metadata: unknown;
|
|
external_id: string | null;
|
|
id: string;
|
|
project_id: string;
|
|
created_at: Date;
|
|
updated_at: Date;
|
|
workspace_id: string;
|
|
is_archived: boolean;
|
|
};
|
|
|
|
type GeneratePresignedUploadUrlRequestBody = {
|
|
filename: string;
|
|
};
|
|
|
|
type GeneratePresignedUploadUrlResponse = {
|
|
success: boolean;
|
|
signedUrl: string;
|
|
expiresAt: string;
|
|
publicUrl: string;
|
|
};
|
|
|
|
type MakeRequestOptions = {
|
|
method?: "POST" | "PUT" | "DELETE" | undefined;
|
|
headers?: Record<string, string> | undefined;
|
|
query?: Record<string, string | number | boolean> | undefined;
|
|
body?: object | undefined;
|
|
};
|
|
|
|
type ObjectStreamOperation = {
|
|
readonly type: "set";
|
|
readonly path: readonly string[];
|
|
readonly value: ReadonlyJSONValue;
|
|
} | {
|
|
readonly type: "append-text";
|
|
readonly path: readonly string[];
|
|
readonly value: string;
|
|
};
|
|
|
|
type PartInit = {
|
|
readonly type: "reasoning" | "text";
|
|
readonly parentId?: string;
|
|
} | {
|
|
readonly type: "tool-call";
|
|
readonly toolCallId: string;
|
|
readonly toolName: string;
|
|
readonly parentId?: string;
|
|
} | {
|
|
readonly type: "source";
|
|
readonly sourceType: "url";
|
|
readonly id: string;
|
|
readonly url: string;
|
|
readonly title?: string;
|
|
readonly parentId?: string;
|
|
} | {
|
|
readonly type: "file";
|
|
readonly data: string;
|
|
readonly mimeType: string;
|
|
readonly parentId?: string;
|
|
} | {
|
|
readonly type: "data";
|
|
readonly name: string;
|
|
readonly data: ReadonlyJSONValue;
|
|
readonly parentId?: string;
|
|
};
|
|
|
|
type PdfToImagesRequestBody = {
|
|
file_blob?: string | undefined;
|
|
file_url?: string | undefined;
|
|
};
|
|
|
|
type PdfToImagesResponse = {
|
|
success: boolean;
|
|
urls: string[];
|
|
message: string;
|
|
};
|
|
|
|
type ReadonlyJSONArray = readonly ReadonlyJSONValue[];
|
|
|
|
type ReadonlyJSONObject = {
|
|
readonly [key: string]: ReadonlyJSONValue;
|
|
};
|
|
|
|
type ReadonlyJSONValue = null | string | number | boolean | ReadonlyJSONObject | ReadonlyJSONArray;
|
|
|
|
type ReportToolCall = {
|
|
tool_name: string;
|
|
tool_call_id: string;
|
|
tool_args?: string;
|
|
tool_result?: string;
|
|
tool_source?: "backend" | "frontend" | "mcp";
|
|
start_ms?: number;
|
|
end_ms?: number;
|
|
sampling_calls?: SamplingCallData[];
|
|
};
|
|
|
|
type SamplingCallData = {
|
|
model_id?: string;
|
|
input_tokens?: number;
|
|
output_tokens?: number;
|
|
reasoning_tokens?: number;
|
|
cached_input_tokens?: number;
|
|
duration_ms?: number;
|
|
};
|
|
|
|
type ThreadStatus = "archived" | "regular";
|
|
|
|
type ToolModelContentPart = {
|
|
readonly type: "text";
|
|
readonly text: string;
|
|
} | {
|
|
readonly type: "file";
|
|
readonly data: string;
|
|
readonly mediaType: string;
|
|
readonly filename?: string;
|
|
};
|
|
|
|
type UseCloudChatOptions = ChatInit<UIMessage> & {
|
|
threads?: UseThreadsResult;
|
|
cloud?: AssistantCloud;
|
|
onSyncError?: (error: Error) => void;
|
|
};
|
|
|
|
type UseCloudChatResult = UseChatHelpers<UIMessage> & {
|
|
threads: UseThreadsResult;
|
|
};
|
|
|
|
type UseThreadsOptions = {
|
|
cloud: AssistantCloud;
|
|
includeArchived?: boolean;
|
|
enabled?: boolean;
|
|
};
|
|
|
|
type UseThreadsResult = {
|
|
cloud: AssistantCloud;
|
|
threads: CloudThread[];
|
|
isLoading: boolean;
|
|
error: Error | null;
|
|
refresh: () => Promise<boolean>;
|
|
get: (id: string) => Promise<CloudThread | null>;
|
|
create: (options?: {
|
|
externalId?: string;
|
|
}) => Promise<CloudThread | null>;
|
|
delete: (id: string) => Promise<boolean>;
|
|
rename: (id: string, title: string) => Promise<boolean>;
|
|
archive: (id: string) => Promise<boolean>;
|
|
unarchive: (id: string) => Promise<boolean>;
|
|
threadId: string | null;
|
|
selectThread: (id: string | null) => void;
|
|
generateTitle: (threadId: string) => Promise<string | null>;
|
|
};
|
|
|
|
declare namespace entry_root_exports {
|
|
export { CloudThread, ThreadStatus, UseCloudChatOptions, UseCloudChatResult, UseThreadsOptions, UseThreadsResult, useCloudChat, useThreads };
|
|
}
|
|
|
|
declare function useCloudChat(options?: UseCloudChatOptions): UseCloudChatResult;
|
|
|
|
declare function useThreads(options: UseThreadsOptions): UseThreadsResult;
|
|
|
|
export { entry_root_exports as entry_root };
|