@nuwa-ai/cap-kit
Version:
680 lines (676 loc) • 21.4 kB
TypeScript
import { RoochClient } from '@roochnetwork/rooch-sdk';
import { SignerInterface } from '@nuwa-ai/identity-kit';
import { z } from 'zod';
interface Result<T> {
code: number;
error?: string;
data?: T;
}
interface Page<T> {
totalItems: number;
page: number;
pageSize: number;
items: T[];
}
declare const CapMcpServerConfigSchema: z.ZodObject<{
url: z.ZodString;
transport: z.ZodEnum<["httpStream", "sse"]>;
}, "strip", z.ZodTypeAny, {
url: string;
transport: "httpStream" | "sse";
}, {
url: string;
transport: "httpStream" | "sse";
}>;
declare const CapModelSchema: z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
slug: z.ZodString;
providerName: z.ZodString;
providerSlug: z.ZodString;
description: z.ZodString;
contextLength: z.ZodNumber;
pricing: z.ZodObject<{
input_per_million_tokens: z.ZodNumber;
output_per_million_tokens: z.ZodNumber;
request_per_k_requests: z.ZodNumber;
image_per_k_images: z.ZodNumber;
web_search_per_k_searches: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
}, {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
}>;
supported_inputs: z.ZodArray<z.ZodString, "many">;
supported_parameters: z.ZodArray<z.ZodString, "many">;
}, "strip", z.ZodTypeAny, {
id: string;
name: string;
description: string;
slug: string;
providerName: string;
providerSlug: string;
contextLength: number;
pricing: {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
};
supported_inputs: string[];
supported_parameters: string[];
}, {
id: string;
name: string;
description: string;
slug: string;
providerName: string;
providerSlug: string;
contextLength: number;
pricing: {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
};
supported_inputs: string[];
supported_parameters: string[];
}>;
declare const CapPromptSchema: z.ZodObject<{
value: z.ZodString;
suggestions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
value: string;
suggestions?: string[] | undefined;
}, {
value: string;
suggestions?: string[] | undefined;
}>;
declare const CapIDSchema: z.ZodObject<{
id: z.ZodString;
authorDID: z.ZodString;
idName: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
authorDID: string;
idName: string;
}, {
id: string;
authorDID: string;
idName: string;
}>;
declare const CapCoreSchema: z.ZodObject<{
prompt: z.ZodObject<{
value: z.ZodString;
suggestions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
value: string;
suggestions?: string[] | undefined;
}, {
value: string;
suggestions?: string[] | undefined;
}>;
model: z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
slug: z.ZodString;
providerName: z.ZodString;
providerSlug: z.ZodString;
description: z.ZodString;
contextLength: z.ZodNumber;
pricing: z.ZodObject<{
input_per_million_tokens: z.ZodNumber;
output_per_million_tokens: z.ZodNumber;
request_per_k_requests: z.ZodNumber;
image_per_k_images: z.ZodNumber;
web_search_per_k_searches: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
}, {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
}>;
supported_inputs: z.ZodArray<z.ZodString, "many">;
supported_parameters: z.ZodArray<z.ZodString, "many">;
}, "strip", z.ZodTypeAny, {
id: string;
name: string;
description: string;
slug: string;
providerName: string;
providerSlug: string;
contextLength: number;
pricing: {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
};
supported_inputs: string[];
supported_parameters: string[];
}, {
id: string;
name: string;
description: string;
slug: string;
providerName: string;
providerSlug: string;
contextLength: number;
pricing: {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
};
supported_inputs: string[];
supported_parameters: string[];
}>;
mcpServers: z.ZodRecord<z.ZodString, z.ZodObject<{
url: z.ZodString;
transport: z.ZodEnum<["httpStream", "sse"]>;
}, "strip", z.ZodTypeAny, {
url: string;
transport: "httpStream" | "sse";
}, {
url: string;
transport: "httpStream" | "sse";
}>>;
}, "strip", z.ZodTypeAny, {
prompt: {
value: string;
suggestions?: string[] | undefined;
};
model: {
id: string;
name: string;
description: string;
slug: string;
providerName: string;
providerSlug: string;
contextLength: number;
pricing: {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
};
supported_inputs: string[];
supported_parameters: string[];
};
mcpServers: Record<string, {
url: string;
transport: "httpStream" | "sse";
}>;
}, {
prompt: {
value: string;
suggestions?: string[] | undefined;
};
model: {
id: string;
name: string;
description: string;
slug: string;
providerName: string;
providerSlug: string;
contextLength: number;
pricing: {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
};
supported_inputs: string[];
supported_parameters: string[];
};
mcpServers: Record<string, {
url: string;
transport: "httpStream" | "sse";
}>;
}>;
declare const CapThumbnailSchema: z.ZodNullable<z.ZodObject<{
type: z.ZodEnum<["file", "url"]>;
file: z.ZodOptional<z.ZodString>;
url: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
}, {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
}>>;
declare const CapMetadataSchema: z.ZodObject<{
displayName: z.ZodString;
description: z.ZodString;
tags: z.ZodArray<z.ZodString, "many">;
submittedAt: z.ZodNumber;
homepage: z.ZodOptional<z.ZodString>;
repository: z.ZodOptional<z.ZodString>;
thumbnail: z.ZodNullable<z.ZodObject<{
type: z.ZodEnum<["file", "url"]>;
file: z.ZodOptional<z.ZodString>;
url: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
}, {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
displayName: string;
description: string;
tags: string[];
submittedAt: number;
thumbnail: {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
} | null;
homepage?: string | undefined;
repository?: string | undefined;
}, {
displayName: string;
description: string;
tags: string[];
submittedAt: number;
thumbnail: {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
} | null;
homepage?: string | undefined;
repository?: string | undefined;
}>;
declare const CapSchema: z.ZodObject<{
id: z.ZodString;
authorDID: z.ZodString;
idName: z.ZodString;
} & {
core: z.ZodObject<{
prompt: z.ZodObject<{
value: z.ZodString;
suggestions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
value: string;
suggestions?: string[] | undefined;
}, {
value: string;
suggestions?: string[] | undefined;
}>;
model: z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
slug: z.ZodString;
providerName: z.ZodString;
providerSlug: z.ZodString;
description: z.ZodString;
contextLength: z.ZodNumber;
pricing: z.ZodObject<{
input_per_million_tokens: z.ZodNumber;
output_per_million_tokens: z.ZodNumber;
request_per_k_requests: z.ZodNumber;
image_per_k_images: z.ZodNumber;
web_search_per_k_searches: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
}, {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
}>;
supported_inputs: z.ZodArray<z.ZodString, "many">;
supported_parameters: z.ZodArray<z.ZodString, "many">;
}, "strip", z.ZodTypeAny, {
id: string;
name: string;
description: string;
slug: string;
providerName: string;
providerSlug: string;
contextLength: number;
pricing: {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
};
supported_inputs: string[];
supported_parameters: string[];
}, {
id: string;
name: string;
description: string;
slug: string;
providerName: string;
providerSlug: string;
contextLength: number;
pricing: {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
};
supported_inputs: string[];
supported_parameters: string[];
}>;
mcpServers: z.ZodRecord<z.ZodString, z.ZodObject<{
url: z.ZodString;
transport: z.ZodEnum<["httpStream", "sse"]>;
}, "strip", z.ZodTypeAny, {
url: string;
transport: "httpStream" | "sse";
}, {
url: string;
transport: "httpStream" | "sse";
}>>;
}, "strip", z.ZodTypeAny, {
prompt: {
value: string;
suggestions?: string[] | undefined;
};
model: {
id: string;
name: string;
description: string;
slug: string;
providerName: string;
providerSlug: string;
contextLength: number;
pricing: {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
};
supported_inputs: string[];
supported_parameters: string[];
};
mcpServers: Record<string, {
url: string;
transport: "httpStream" | "sse";
}>;
}, {
prompt: {
value: string;
suggestions?: string[] | undefined;
};
model: {
id: string;
name: string;
description: string;
slug: string;
providerName: string;
providerSlug: string;
contextLength: number;
pricing: {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
};
supported_inputs: string[];
supported_parameters: string[];
};
mcpServers: Record<string, {
url: string;
transport: "httpStream" | "sse";
}>;
}>;
metadata: z.ZodObject<{
displayName: z.ZodString;
description: z.ZodString;
tags: z.ZodArray<z.ZodString, "many">;
submittedAt: z.ZodNumber;
homepage: z.ZodOptional<z.ZodString>;
repository: z.ZodOptional<z.ZodString>;
thumbnail: z.ZodNullable<z.ZodObject<{
type: z.ZodEnum<["file", "url"]>;
file: z.ZodOptional<z.ZodString>;
url: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
}, {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
displayName: string;
description: string;
tags: string[];
submittedAt: number;
thumbnail: {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
} | null;
homepage?: string | undefined;
repository?: string | undefined;
}, {
displayName: string;
description: string;
tags: string[];
submittedAt: number;
thumbnail: {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
} | null;
homepage?: string | undefined;
repository?: string | undefined;
}>;
}, "strip", z.ZodTypeAny, {
id: string;
authorDID: string;
idName: string;
core: {
prompt: {
value: string;
suggestions?: string[] | undefined;
};
model: {
id: string;
name: string;
description: string;
slug: string;
providerName: string;
providerSlug: string;
contextLength: number;
pricing: {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
};
supported_inputs: string[];
supported_parameters: string[];
};
mcpServers: Record<string, {
url: string;
transport: "httpStream" | "sse";
}>;
};
metadata: {
displayName: string;
description: string;
tags: string[];
submittedAt: number;
thumbnail: {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
} | null;
homepage?: string | undefined;
repository?: string | undefined;
};
}, {
id: string;
authorDID: string;
idName: string;
core: {
prompt: {
value: string;
suggestions?: string[] | undefined;
};
model: {
id: string;
name: string;
description: string;
slug: string;
providerName: string;
providerSlug: string;
contextLength: number;
pricing: {
input_per_million_tokens: number;
output_per_million_tokens: number;
request_per_k_requests: number;
image_per_k_images: number;
web_search_per_k_searches: number;
};
supported_inputs: string[];
supported_parameters: string[];
};
mcpServers: Record<string, {
url: string;
transport: "httpStream" | "sse";
}>;
};
metadata: {
displayName: string;
description: string;
tags: string[];
submittedAt: number;
thumbnail: {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
} | null;
homepage?: string | undefined;
repository?: string | undefined;
};
}>;
declare const ResultCapMetadataSchema: z.ZodObject<{
id: z.ZodString;
cid: z.ZodString;
name: z.ZodString;
version: z.ZodString;
displayName: z.ZodString;
description: z.ZodString;
tags: z.ZodArray<z.ZodString, "many">;
submittedAt: z.ZodNumber;
homepage: z.ZodOptional<z.ZodString>;
repository: z.ZodOptional<z.ZodString>;
thumbnail: z.ZodNullable<z.ZodObject<{
type: z.ZodEnum<["file", "url"]>;
file: z.ZodOptional<z.ZodString>;
url: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
}, {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
id: string;
cid: string;
name: string;
version: string;
displayName: string;
description: string;
tags: string[];
submittedAt: number;
thumbnail: {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
} | null;
homepage?: string | undefined;
repository?: string | undefined;
}, {
id: string;
cid: string;
name: string;
version: string;
displayName: string;
description: string;
tags: string[];
submittedAt: number;
thumbnail: {
type: "file" | "url";
file?: string | undefined;
url?: string | undefined;
} | null;
homepage?: string | undefined;
repository?: string | undefined;
}>;
type CapMcpServerConfig = z.infer<typeof CapMcpServerConfigSchema>;
type CapModel = z.infer<typeof CapModelSchema>;
type CapPrompt = z.infer<typeof CapPromptSchema>;
type CapID = z.infer<typeof CapIDSchema>;
type CapCore = z.infer<typeof CapCoreSchema>;
type CapThumbnail = z.infer<typeof CapThumbnailSchema>;
type CapMetadata = z.infer<typeof CapMetadataSchema>;
type Cap = z.infer<typeof CapSchema>;
type ResultCap = z.infer<typeof ResultCapMetadataSchema>;
declare class CapKit {
protected roochClient: RoochClient;
protected contractAddress: string;
protected mcpUrl: string;
protected signer: SignerInterface;
constructor(option: {
mcpUrl: string;
roochUrl: string;
contractAddress: string;
signer: SignerInterface;
});
queryCapWithID(id?: string, cid?: string): Promise<Result<ResultCap>>;
queryWithName(name?: string, tags?: string[], page?: number, size?: number): Promise<Result<Page<ResultCap>>>;
downloadCapWithID(id: string, format?: 'base64' | 'utf8'): Promise<Cap>;
downloadCapWithCID(cid: string, format?: 'base64' | 'utf8'): Promise<Cap>;
registerCap(cap: Cap): Promise<string>;
private uploadToIPFS;
private registerOnChain;
}
export { type Cap, type CapCore, CapCoreSchema, type CapID, CapIDSchema, CapKit, type CapMcpServerConfig, CapMcpServerConfigSchema, type CapMetadata, CapMetadataSchema, type CapModel, CapModelSchema, type CapPrompt, CapPromptSchema, CapSchema, type CapThumbnail, CapThumbnailSchema, type Page, type Result, type ResultCap, ResultCapMetadataSchema };