/** * @file ProjectsClient.ts * @description x402 payment-based client for the Inkd Protocol API. * * Agents use this to create projects and push versions by paying USDC * via EIP-3009. No API keys needed — wallet = identity. * * @example * ```ts * import { ProjectsClient } from "@inkd/sdk"; * import { createWalletClient, createPublicClient, http } from "viem"; * import { base } from "viem/chains"; * import { privateKeyToAccount } from "viem/accounts"; * * const account = privateKeyToAccount("0x..."); * const wallet = createWalletClient({ account, chain: base, transport: http() }); * const reader = createPublicClient({ chain: base, transport: http() }); * * const client = new ProjectsClient({ wallet, publicClient: reader }); * * const { projectId } = await client.createProject({ * name: "my-agent", * description: "An autonomous AI agent", * license: "MIT", * }); * * const { txHash } = await client.pushVersion(projectId, { * tag: "v1.0.0", * contentHash: "ar://TxId", * }); * ``` */ import type { WalletClient, PublicClient, Account, Transport, Chain } from "viem"; export interface ProjectsClientConfig { /** Viem WalletClient with account attached. */ wallet: WalletClient; /** Viem PublicClient for reading contract state. */ publicClient: PublicClient; /** Override the API base URL (default: https://api.inkdprotocol.com). */ apiUrl?: string; /** * Private key (hex) for encrypting private projects. * Required for createPrivateProject() and decryptVersion(). */ privateKey?: `0x${string}`; } export interface CreateProjectParams { name: string; description?: string; license?: string; isPublic?: boolean; readmeHash?: string; isAgent?: boolean; agentEndpoint?: string; } export interface CreateProjectResult { projectId: number; txHash: string; owner: string; blockNumber: number; } export interface PushVersionParams { tag: string; contentHash: string; metadataHash?: string; contentSize?: number; } export interface PushVersionResult { tag: string; contentHash: string; txHash: string; blockNumber: number; } export interface Project { id: number; name: string; description: string; license: string; owner: string; isPublic: boolean; isAgent: boolean; agentEndpoint: string; readmeHash: string; createdAt: number; versionCount: number; metadataUri?: string; forkOf?: string; accessManifest?: string; } export interface UploadResult { hash: string; txId: string; url: string; bytes: number; } export interface UploadOptions { contentType?: string; filename?: string; } export declare class ProjectsClient { private readonly fetchPay; private readonly apiUrl; private readonly privateKey; private readonly ownerAddress; constructor(config: ProjectsClientConfig); /** * Create a new project. Pays $5 USDC via x402. */ createProject(params: CreateProjectParams): Promise; /** * Push a new version to a project. Pays $2 USDC via x402. * Tip: upload content via `upload()` first, then pass the returned hash. */ pushVersion(projectId: number, params: PushVersionParams): Promise; /** Get a project by ID (no payment required). */ getProject(projectId: number): Promise; /** List projects (no payment required). */ listProjects(opts?: { offset?: number; limit?: number; }): Promise; /** List projects owned by the connected wallet. */ listMyProjects(opts?: { offset?: number; limit?: number; }): Promise; /** Estimate Arweave upload cost in USDC for a given number of bytes. */ estimateUploadCost(bytes: number): Promise<{ total: string; arweaveCost: string; markup: string; }>; /** * Create a private project. Encrypts content with AES-256-GCM + ECIES key wrapping. * Only the owner (and collaborators added later) can decrypt. * Requires `privateKey` in ProjectsClientConfig. */ createPrivateProject(params: CreateProjectParams & { content: Buffer | Uint8Array; contentType?: string; }): Promise; /** * Decrypt content from a private project version. * Requires `privateKey` in ProjectsClientConfig. */ decryptVersion(encryptedArweaveHash: string, manifestArweaveHash: string): Promise; /** * Add a collaborator to a private project. * Owner fetches and re-encrypts the manifest with the new wallet's public key. */ addCollaborator(manifestArweaveHash: string, collaborator: { address: `0x${string}`; compressedPublicKey: string; }): Promise<{ newManifestHash: string; }>; /** * Upload content to Arweave, encrypt it, and push a private version. * * The content is encrypted with AES-256-GCM (random key) before upload. * The AES key is ECIES-wrapped for the owner and stored in an access manifest on Arweave. * The manifest hash is stored on-chain in the version metadata. * * Requires `privateKey` in ProjectsClientConfig. * * @example * ```ts * const result = await client.pushPrivateVersion(projectId, { * content: fs.readFileSync('./secret-model.bin'), * tag: 'v1.0.0', * contentType: 'application/octet-stream', * }) * console.log(result.txHash) // on-chain TX * // Later, decrypt: * const plaintext = await client.decryptVersion(result.contentHash, result.metadataHash) * ``` */ pushPrivateVersion(projectId: number, params: { content: Buffer | Uint8Array; tag: string; contentType?: string; changelog?: string; filename?: string; }): Promise; /** * Search for agents on the INKD registry by capability or keyword. * * @example * ```ts * const agents = await client.searchAgents("summarization"); * // [{ id: 42, name: "text-summarizer", agentEndpoint: "https://..." }] * ``` */ searchAgents(query: string, options?: { limit?: number; }): Promise; /** * Call a registered agent by project ID. * * Fetches the project from the registry, reads `agentEndpoint`, and * POSTs `input` to `/` as JSON. * * @example * ```ts * const result = await client.callAgent(42, { text: "Hello world", maxLength: 50 }); * ``` */ callAgent(projectId: number | string, input: Record): Promise; /** * Upload content to Arweave via the Inkd API. * Returns an `ar://` hash to use in pushVersion. * Free endpoint — cost is covered by the $2 USDC in pushVersion. */ upload(data: Uint8Array | Buffer | string, opts?: UploadOptions): Promise; } //# sourceMappingURL=ProjectsClient.d.ts.map