@dexto/client-sdk

中文文档
1.17.0发布于 2026/11/10TypeScriptESM + CJS近 30 天下载 3296

A TypeScript HTTP client for Dexto servers, with a separate entrypoint for authenticated Cloud discovery.

原始使用文档
文档目录13 节
  1. Features
  2. Installation
  3. Cloud discovery
  4. Quick Start
  5. Configuration
  6. API Methods
  7. Connection Management
  8. Messaging
  9. Session Management
  10. Real-time Events
  11. Error Handling
  12. Philosophy
  13. Dependencies

Dexto Client SDK

A TypeScript HTTP client for Dexto servers, with a separate entrypoint for authenticated Cloud discovery.

Features

  • 🔌 Separate exports: Local server and Cloud discovery clients
  • 🌐 Universal: Works in Node.js, browsers, and React Native
  • 📡 HTTP + SSE: Full REST API and real-time SSE streaming support
  • 🛡️ TypeScript: Full type safety
  • 🔄 Auto-retry: Built-in retry logic with exponential backoff
  • ⚡ Cloud contracts: Validated discovery requests and responses

Installation

npm install @dexto/client-sdk

Cloud discovery

import { createDextoCloudClient } from '@dexto/client-sdk/cloud';

const cloud = createDextoCloudClient({
    origin: 'https://app.dexto.ai',
    token: 'your-dexto-api-key',
    fetch: globalThis.fetch,
});

const sources = await cloud.sources({ limit: 20 });
const matches = await cloud.search({ query: 'web search', limit: 10 });
const description = await cloud.describe('dexto.platform.web_search');

Use an organization credential with capabilities:read. Results include schemas and execution/availability metadata; discovery does not grant permission to invoke a capability. Cloud validates current membership and credential permissions on each request.

The CLI uses the same discovery client:

dexto login
dexto cloud sources --json
dexto cloud search "web search" --limit 10 --json
dexto cloud describe dexto.platform.web_search --json

Search returns hasMore, nextOffset, and total. Pass --offset for the next page. JSON failures contain an error object and exit with code 1. Human-readable output is the default.

For another installation, use dexto login --platform-url <application-origin>. The saved key remains bound to that origin, including when the same key appears in the environment. A different shell environment DEXTO_API_KEY can select another origin with --platform-url or DEXTO_PLATFORM_URL. Cloud discovery uses explicit shell environment overrides, not values loaded from .env files. Legacy saved keys without origin metadata require a fresh dexto login --platform-url <application-origin> before discovery.

Quick Start

import { DextoClient } from '@dexto/client-sdk';

const client = new DextoClient({
    baseUrl: 'https://your-dexto-server.com',
    apiKey: 'optional-api-key',
});

// Connect to Dexto server
await client.connect();

// Send a message
const response = await client.sendMessage({
    content: 'Hello, how can you help me?',
});

console.log(response.response);

Configuration

const client = new DextoClient(
    {
        baseUrl: 'https://your-dexto-server.com', // Required: Dexto API base URL
        apiKey: 'your-api-key', // Optional: API key for auth
        timeout: 30000, // Optional: Request timeout (ms)
        retries: 3, // Optional: Retry attempts
    },
    {
        reconnect: true, // Optional: Auto-reconnect
        reconnectInterval: 5000, // Optional: Reconnect delay (ms)
        debug: false, // Optional: Debug logging
    }
);

API Methods

Connection Management

  • connect() - Establish connection to Dexto server
  • disconnect() - Close connection
  • isConnected - Check connection status

Messaging

  • sendMessage(input) - Send message (HTTP)
  • SSE streaming available via /api/message-stream endpoint

Session Management

  • listSessions() - List all sessions
  • createSession(id?) - Create new session
  • getSession(id) - Get session details
  • deleteSession(id) - Delete session

Real-time Events

  • on(eventType, handler) - Subscribe to Dexto events
  • onConnectionState(handler) - Connection state changes

Error Handling

try {
    await client.sendMessage({ content: 'Hello' });
} catch (error) {
    if (error.name === 'ConnectionError') {
        console.log('Failed to connect to Dexto server');
    } else if (error.name === 'HttpError') {
        console.log(`HTTP ${error.status}: ${error.statusText}`);
    }
}

Philosophy

The agent-server export is a thin typed transport client. The Cloud export validates discovery request inputs and successful response contracts, and reports typed HTTP, network, and incompatible-response errors. Server-side authorization and product policy remain with the server.

Dependencies

The published package uses Hono for the agent-server client and Zod for Cloud discovery validation. The separate Cloud export does not import Core or the local server runtime.

版本与发布记录

@dexto/client-sdk 共发布 107 个版本,首次发布于 2025/09/25;过去 12 个月发布了 95 个版本。

版本发布日期距今
1.17.0latest2026/11/102 天前
1.16.62026/11/093 天前
1.16.52026/11/093 天前
1.16.42026/11/093 天前
1.16.32026/11/093 天前
1.16.22026/11/093 天前

关于 @dexto/client-sdk 的常见问题

@dexto/client-sdk 是什么?

A TypeScript HTTP client for Dexto servers, with a separate entrypoint for authenticated Cloud discovery.

如何安装 @dexto/client-sdk?

在项目目录运行 npm install @dexto/client-sdk,或使用 pnpm add / yarn add / bun add。

@dexto/client-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dexto/client-sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dexto/client-sdk 可以商用吗?

@dexto/client-sdk 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@dexto/client-sdk 的下载量有多少?

根据 npm 官方下载统计,@dexto/client-sdk 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,296 次,日均约 110 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dexto/client-sdk 还在维护吗?

最新版本 1.17.0 发布于 2026/11/10(2 天前);至今共发布 107 个版本,其中过去 12 个月发布了 95 个;首次发布于 2025/09/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。