@yushaw/sanqian-sdk 0.3.21 → 0.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -640,6 +640,31 @@ if (rerank.available) {
640
640
 
641
641
  ---
642
642
 
643
+ ## Messaging Channels API
644
+
645
+ Channels methods in the SDK use Sanqian HTTP endpoints with `X-App-Token` auth. They only require runtime connection info and do not require WebSocket registration to be completed first.
646
+
647
+ ```typescript
648
+ // Useful when building URLs for local HTTP integrations
649
+ const baseUrl = sdk.getBaseUrl() // e.g. http://127.0.0.1:8765
650
+
651
+ // Fetch config schema for setup forms
652
+ const schema = await sdk.getChannelConfigSchema('telegram')
653
+
654
+ // Validate/probe config before creating an account
655
+ const probe = await sdk.probeChannelConfig({
656
+ channel_type: 'telegram',
657
+ config: { bot_token: process.env.TELEGRAM_BOT_TOKEN }
658
+ })
659
+ if (!probe.ok) {
660
+ console.error(probe.error)
661
+ }
662
+ ```
663
+
664
+ This section only shows the newly added methods. Full account/binding/message operations are available via `listChannelAccounts`, `createChannelAccount`, `listChannelBindings`, `sendChannelMessage`, and related methods.
665
+
666
+ ---
667
+
643
668
  ## Connection
644
669
 
645
670
  ### Connection Lifecycle
@@ -742,6 +767,8 @@ const sdk = new SanqianSDK({
742
767
  reconnectInterval: 5000, // Reconnect interval (ms, default: 5000)
743
768
  heartbeatInterval: 30000, // Heartbeat interval (ms, default: 30000)
744
769
  toolExecutionTimeout: 30000, // Tool timeout (ms, default: 30000)
770
+ connectionFileReconnectMaxDurationMs: 300000, // File-watch reconnect max duration (ms, default: 5min)
771
+ connectionFileReconnectJitterMs: 300, // Extra random delay per retry (ms, default: 300)
745
772
 
746
773
  // Auto-launch
747
774
  autoLaunchSanqian: true, // Launch Sanqian if not running (default: true)
@@ -1521,6 +1548,31 @@ if (rerank.available) {
1521
1548
 
1522
1549
  ---
1523
1550
 
1551
+ ## 消息渠道 API
1552
+
1553
+ SDK 的 channels 方法通过 Sanqian HTTP 接口调用,并自动附带 `X-App-Token` 鉴权。它们只依赖运行时连接信息,不要求先完成 WebSocket 注册。
1554
+
1555
+ ```typescript
1556
+ // 构建本地 HTTP 集成时可直接复用
1557
+ const baseUrl = sdk.getBaseUrl() // 例如 http://127.0.0.1:8765
1558
+
1559
+ // 获取某个渠道的配置 schema(用于设置表单)
1560
+ const schema = await sdk.getChannelConfigSchema('telegram')
1561
+
1562
+ // 创建账号前先探测配置是否可用
1563
+ const probe = await sdk.probeChannelConfig({
1564
+ channel_type: 'telegram',
1565
+ config: { bot_token: process.env.TELEGRAM_BOT_TOKEN }
1566
+ })
1567
+ if (!probe.ok) {
1568
+ console.error(probe.error)
1569
+ }
1570
+ ```
1571
+
1572
+ 这里仅展示新增方法。完整渠道能力可通过 `listChannelAccounts`、`createChannelAccount`、`listChannelBindings`、`sendChannelMessage` 等方法使用。
1573
+
1574
+ ---
1575
+
1524
1576
  ## 连接
1525
1577
 
1526
1578
  ### 连接生命周期
@@ -1778,4 +1830,4 @@ HTTP API 适合任意语言的简单对话。SDK 适合需要工具、Agent、
1778
1830
  | `400` | 请求参数无效 |
1779
1831
  | `404` | Agent 或会话未找到 |
1780
1832
  | `429` | 频率限制 |
1781
- | `500` | 内部服务器错误 |
1833
+ | `500` | 内部服务器错误 |
@@ -33,6 +33,16 @@ interface SDKConfig {
33
33
  heartbeatInterval?: number;
34
34
  /** Tool execution timeout in ms (default: 30000) */
35
35
  toolExecutionTimeout?: number;
36
+ /**
37
+ * Max duration for connection.json-triggered reconnect loop in ms (default: 300000 / 5min).
38
+ * After timeout, SDK stops retrying until next connection.json change event.
39
+ */
40
+ connectionFileReconnectMaxDurationMs?: number;
41
+ /**
42
+ * Random jitter upper bound for each connection.json reconnect delay in ms (default: 300).
43
+ * Helps avoid synchronized reconnect spikes when many apps reconnect together.
44
+ */
45
+ connectionFileReconnectJitterMs?: number;
36
46
  /**
37
47
  * Auto-launch Sanqian if not running (default: false)
38
48
  * When enabled, SDK will try to start Sanqian in hidden/tray mode
@@ -836,6 +846,11 @@ interface ChannelProbeResult {
836
846
  bot_username: string | null;
837
847
  error: string | null;
838
848
  }
849
+ interface ProbeChannelConfigRequest {
850
+ channel_type: string;
851
+ config: Record<string, unknown>;
852
+ }
853
+ type ChannelConfigSchema = Record<string, unknown>;
839
854
  interface CreateChannelAccountRequest {
840
855
  channel_type: string;
841
856
  name: string;
@@ -967,11 +982,18 @@ declare class SanqianSDK {
967
982
  }>;
968
983
  private getHttpBaseUrl;
969
984
  private getHttpAuthHeaders;
985
+ private ensureHttpReady;
970
986
  /**
971
987
  * Get the port number for the Sanqian backend
972
988
  * @throws Error if not connected
973
989
  */
974
990
  getPort(): number;
991
+ /**
992
+ * Get the HTTP base URL for Sanqian backend.
993
+ *
994
+ * @throws Error if connection info is not available
995
+ */
996
+ getBaseUrl(): string;
975
997
  /**
976
998
  * Get conversation messages via history API (aligned with main app history)
977
999
  */
@@ -1114,6 +1136,8 @@ declare class SanqianSDK {
1114
1136
  }>;
1115
1137
  getChannelStatus(id: string): Promise<ChannelStatus>;
1116
1138
  probeChannelAccount(id: string): Promise<ChannelProbeResult>;
1139
+ probeChannelConfig(req: ProbeChannelConfigRequest): Promise<ChannelProbeResult>;
1140
+ getChannelConfigSchema(channelType: string): Promise<ChannelConfigSchema>;
1117
1141
  listChannelBindings(accountId?: string): Promise<ChannelBinding[]>;
1118
1142
  createChannelBinding(req: CreateChannelBindingRequest): Promise<ChannelBinding>;
1119
1143
  updateChannelBinding(id: string, req: UpdateChannelBindingRequest): Promise<ChannelBinding>;
@@ -1207,4 +1231,4 @@ declare class SanqianSDKError extends Error {
1207
1231
  */
1208
1232
  declare function createSDKError(code: SDKErrorCode, details?: string): SanqianSDKError;
1209
1233
 
1210
- export { type AgentCapability, type AgentConfig, type AgentInfo, type AgentUpdateConfig, type Capability, type CapabilitySearchResult, type CapabilityType, type ChannelAccount, type ChannelAccountStatus, type ChannelBinding, type ChannelBindingMatchType, type ChannelChatType, type ChannelDmPolicy, type ChannelDmScope, type ChannelGroupPolicy, type ChannelPluginInfo, type ChannelProbeResult, type ChannelRuntimeStatus, type ChannelStatus, type ChatMessage, type ChatRequest, type ChatResponse, type ChatStreamEvent, type ConnectionInfo, type ConnectionState, type ContextData, type ContextListItem, type ContextProvider, Conversation, type ConversationDetail, type ConversationInfo, type ConversationMessage, type CreateChannelAccountRequest, type CreateChannelBindingRequest, type EmbeddingConfigResult, ErrorMessages, type HitlInterruptPayload, type HitlInterruptType, type HitlResponse, type HitlRiskLevel, type JSONSchema, type JSONSchemaProperty, type ListCapabilitiesOptions, type LoadItem, type LoadItemAction, type LoadItemType, type RemoteToolDefinition, type RerankConfigResult, SANQIAN_WEBSITE, type SDKConfig, SDKErrorCode, type SDKEventName, type SDKEvents, SanqianSDK, SanqianSDKError, type SearchCapabilitiesOptions, type SendChannelMessageRequest, type SendChannelMessageResponse, type SessionResource, type SkillCapability, type StoredSessionResource, type ToolCall, type ToolCapability, type ToolDefinition, type UpdateChannelAccountRequest, type UpdateChannelBindingRequest, createSDKError };
1234
+ export { type AgentCapability, type AgentConfig, type AgentInfo, type AgentUpdateConfig, type Capability, type CapabilitySearchResult, type CapabilityType, type ChannelAccount, type ChannelAccountStatus, type ChannelBinding, type ChannelBindingMatchType, type ChannelChatType, type ChannelConfigSchema, type ChannelDmPolicy, type ChannelDmScope, type ChannelGroupPolicy, type ChannelPluginInfo, type ChannelProbeResult, type ChannelRuntimeStatus, type ChannelStatus, type ChatMessage, type ChatRequest, type ChatResponse, type ChatStreamEvent, type ConnectionInfo, type ConnectionState, type ContextData, type ContextListItem, type ContextProvider, Conversation, type ConversationDetail, type ConversationInfo, type ConversationMessage, type CreateChannelAccountRequest, type CreateChannelBindingRequest, type EmbeddingConfigResult, ErrorMessages, type HitlInterruptPayload, type HitlInterruptType, type HitlResponse, type HitlRiskLevel, type JSONSchema, type JSONSchemaProperty, type ListCapabilitiesOptions, type LoadItem, type LoadItemAction, type LoadItemType, type ProbeChannelConfigRequest, type RemoteToolDefinition, type RerankConfigResult, SANQIAN_WEBSITE, type SDKConfig, SDKErrorCode, type SDKEventName, type SDKEvents, SanqianSDK, SanqianSDKError, type SearchCapabilitiesOptions, type SendChannelMessageRequest, type SendChannelMessageResponse, type SessionResource, type SkillCapability, type StoredSessionResource, type ToolCall, type ToolCapability, type ToolDefinition, type UpdateChannelAccountRequest, type UpdateChannelBindingRequest, createSDKError };
@@ -33,6 +33,16 @@ interface SDKConfig {
33
33
  heartbeatInterval?: number;
34
34
  /** Tool execution timeout in ms (default: 30000) */
35
35
  toolExecutionTimeout?: number;
36
+ /**
37
+ * Max duration for connection.json-triggered reconnect loop in ms (default: 300000 / 5min).
38
+ * After timeout, SDK stops retrying until next connection.json change event.
39
+ */
40
+ connectionFileReconnectMaxDurationMs?: number;
41
+ /**
42
+ * Random jitter upper bound for each connection.json reconnect delay in ms (default: 300).
43
+ * Helps avoid synchronized reconnect spikes when many apps reconnect together.
44
+ */
45
+ connectionFileReconnectJitterMs?: number;
36
46
  /**
37
47
  * Auto-launch Sanqian if not running (default: false)
38
48
  * When enabled, SDK will try to start Sanqian in hidden/tray mode
@@ -836,6 +846,11 @@ interface ChannelProbeResult {
836
846
  bot_username: string | null;
837
847
  error: string | null;
838
848
  }
849
+ interface ProbeChannelConfigRequest {
850
+ channel_type: string;
851
+ config: Record<string, unknown>;
852
+ }
853
+ type ChannelConfigSchema = Record<string, unknown>;
839
854
  interface CreateChannelAccountRequest {
840
855
  channel_type: string;
841
856
  name: string;
@@ -967,11 +982,18 @@ declare class SanqianSDK {
967
982
  }>;
968
983
  private getHttpBaseUrl;
969
984
  private getHttpAuthHeaders;
985
+ private ensureHttpReady;
970
986
  /**
971
987
  * Get the port number for the Sanqian backend
972
988
  * @throws Error if not connected
973
989
  */
974
990
  getPort(): number;
991
+ /**
992
+ * Get the HTTP base URL for Sanqian backend.
993
+ *
994
+ * @throws Error if connection info is not available
995
+ */
996
+ getBaseUrl(): string;
975
997
  /**
976
998
  * Get conversation messages via history API (aligned with main app history)
977
999
  */
@@ -1114,6 +1136,8 @@ declare class SanqianSDK {
1114
1136
  }>;
1115
1137
  getChannelStatus(id: string): Promise<ChannelStatus>;
1116
1138
  probeChannelAccount(id: string): Promise<ChannelProbeResult>;
1139
+ probeChannelConfig(req: ProbeChannelConfigRequest): Promise<ChannelProbeResult>;
1140
+ getChannelConfigSchema(channelType: string): Promise<ChannelConfigSchema>;
1117
1141
  listChannelBindings(accountId?: string): Promise<ChannelBinding[]>;
1118
1142
  createChannelBinding(req: CreateChannelBindingRequest): Promise<ChannelBinding>;
1119
1143
  updateChannelBinding(id: string, req: UpdateChannelBindingRequest): Promise<ChannelBinding>;
@@ -1207,4 +1231,4 @@ declare class SanqianSDKError extends Error {
1207
1231
  */
1208
1232
  declare function createSDKError(code: SDKErrorCode, details?: string): SanqianSDKError;
1209
1233
 
1210
- export { type AgentCapability, type AgentConfig, type AgentInfo, type AgentUpdateConfig, type Capability, type CapabilitySearchResult, type CapabilityType, type ChannelAccount, type ChannelAccountStatus, type ChannelBinding, type ChannelBindingMatchType, type ChannelChatType, type ChannelDmPolicy, type ChannelDmScope, type ChannelGroupPolicy, type ChannelPluginInfo, type ChannelProbeResult, type ChannelRuntimeStatus, type ChannelStatus, type ChatMessage, type ChatRequest, type ChatResponse, type ChatStreamEvent, type ConnectionInfo, type ConnectionState, type ContextData, type ContextListItem, type ContextProvider, Conversation, type ConversationDetail, type ConversationInfo, type ConversationMessage, type CreateChannelAccountRequest, type CreateChannelBindingRequest, type EmbeddingConfigResult, ErrorMessages, type HitlInterruptPayload, type HitlInterruptType, type HitlResponse, type HitlRiskLevel, type JSONSchema, type JSONSchemaProperty, type ListCapabilitiesOptions, type LoadItem, type LoadItemAction, type LoadItemType, type RemoteToolDefinition, type RerankConfigResult, SANQIAN_WEBSITE, type SDKConfig, SDKErrorCode, type SDKEventName, type SDKEvents, SanqianSDK, SanqianSDKError, type SearchCapabilitiesOptions, type SendChannelMessageRequest, type SendChannelMessageResponse, type SessionResource, type SkillCapability, type StoredSessionResource, type ToolCall, type ToolCapability, type ToolDefinition, type UpdateChannelAccountRequest, type UpdateChannelBindingRequest, createSDKError };
1234
+ export { type AgentCapability, type AgentConfig, type AgentInfo, type AgentUpdateConfig, type Capability, type CapabilitySearchResult, type CapabilityType, type ChannelAccount, type ChannelAccountStatus, type ChannelBinding, type ChannelBindingMatchType, type ChannelChatType, type ChannelConfigSchema, type ChannelDmPolicy, type ChannelDmScope, type ChannelGroupPolicy, type ChannelPluginInfo, type ChannelProbeResult, type ChannelRuntimeStatus, type ChannelStatus, type ChatMessage, type ChatRequest, type ChatResponse, type ChatStreamEvent, type ConnectionInfo, type ConnectionState, type ContextData, type ContextListItem, type ContextProvider, Conversation, type ConversationDetail, type ConversationInfo, type ConversationMessage, type CreateChannelAccountRequest, type CreateChannelBindingRequest, type EmbeddingConfigResult, ErrorMessages, type HitlInterruptPayload, type HitlInterruptType, type HitlResponse, type HitlRiskLevel, type JSONSchema, type JSONSchemaProperty, type ListCapabilitiesOptions, type LoadItem, type LoadItemAction, type LoadItemType, type ProbeChannelConfigRequest, type RemoteToolDefinition, type RerankConfigResult, SANQIAN_WEBSITE, type SDKConfig, SDKErrorCode, type SDKEventName, type SDKEvents, SanqianSDK, SanqianSDKError, type SearchCapabilitiesOptions, type SendChannelMessageRequest, type SendChannelMessageResponse, type SessionResource, type SkillCapability, type StoredSessionResource, type ToolCall, type ToolCapability, type ToolDefinition, type UpdateChannelAccountRequest, type UpdateChannelBindingRequest, createSDKError };
@@ -999,7 +999,14 @@ var SanqianSDK = class _SanqianSDK {
999
999
  }
1000
1000
  async doFullConnect() {
1001
1001
  this.log("Starting connection (browser mode)...");
1002
- const info = this.config.connectionInfo;
1002
+ await this.ensureHttpReady();
1003
+ const info = this.connectionInfo || this.config.connectionInfo;
1004
+ if (!info) {
1005
+ throw createSDKError(
1006
+ "NOT_RUNNING" /* NOT_RUNNING */,
1007
+ "Connection info not available in browser mode"
1008
+ );
1009
+ }
1003
1010
  await this.connectWithInfo(info);
1004
1011
  }
1005
1012
  async updateTools(tools) {
@@ -1145,6 +1152,16 @@ var SanqianSDK = class _SanqianSDK {
1145
1152
  const token = info?.token;
1146
1153
  return token ? { "X-App-Token": token } : {};
1147
1154
  }
1155
+ async ensureHttpReady() {
1156
+ const info = this.connectionInfo || this.config.connectionInfo;
1157
+ if (!info) {
1158
+ throw createSDKError(
1159
+ "NOT_RUNNING" /* NOT_RUNNING */,
1160
+ "Connection info not available for HTTP API in browser build"
1161
+ );
1162
+ }
1163
+ this.connectionInfo = info;
1164
+ }
1148
1165
  /**
1149
1166
  * Get the port number for the Sanqian backend
1150
1167
  * @throws Error if not connected
@@ -1156,6 +1173,14 @@ var SanqianSDK = class _SanqianSDK {
1156
1173
  }
1157
1174
  return info.port;
1158
1175
  }
1176
+ /**
1177
+ * Get the HTTP base URL for Sanqian backend.
1178
+ *
1179
+ * @throws Error if connection info is not available
1180
+ */
1181
+ getBaseUrl() {
1182
+ return this.getHttpBaseUrl();
1183
+ }
1159
1184
  /**
1160
1185
  * Get conversation messages via history API (aligned with main app history)
1161
1186
  */
@@ -1707,7 +1732,7 @@ var SanqianSDK = class _SanqianSDK {
1707
1732
  // Channels
1708
1733
  // ============================================
1709
1734
  async listChannelPlugins() {
1710
- await this.ensureReady();
1735
+ await this.ensureHttpReady();
1711
1736
  const url = `${this.getHttpBaseUrl()}/api/channels/plugins`;
1712
1737
  const response = await fetch(url, { headers: this.getHttpAuthHeaders() });
1713
1738
  if (!response.ok) {
@@ -1716,7 +1741,7 @@ var SanqianSDK = class _SanqianSDK {
1716
1741
  return response.json();
1717
1742
  }
1718
1743
  async listChannelAccounts() {
1719
- await this.ensureReady();
1744
+ await this.ensureHttpReady();
1720
1745
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts`;
1721
1746
  const response = await fetch(url, { headers: this.getHttpAuthHeaders() });
1722
1747
  if (!response.ok) {
@@ -1725,7 +1750,7 @@ var SanqianSDK = class _SanqianSDK {
1725
1750
  return response.json();
1726
1751
  }
1727
1752
  async createChannelAccount(req) {
1728
- await this.ensureReady();
1753
+ await this.ensureHttpReady();
1729
1754
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts`;
1730
1755
  const response = await fetch(url, {
1731
1756
  method: "POST",
@@ -1739,7 +1764,7 @@ var SanqianSDK = class _SanqianSDK {
1739
1764
  return response.json();
1740
1765
  }
1741
1766
  async getChannelAccount(id) {
1742
- await this.ensureReady();
1767
+ await this.ensureHttpReady();
1743
1768
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}`;
1744
1769
  const response = await fetch(url, { headers: this.getHttpAuthHeaders() });
1745
1770
  if (!response.ok) {
@@ -1748,7 +1773,7 @@ var SanqianSDK = class _SanqianSDK {
1748
1773
  return response.json();
1749
1774
  }
1750
1775
  async updateChannelAccount(id, req) {
1751
- await this.ensureReady();
1776
+ await this.ensureHttpReady();
1752
1777
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}`;
1753
1778
  const response = await fetch(url, {
1754
1779
  method: "PUT",
@@ -1762,7 +1787,7 @@ var SanqianSDK = class _SanqianSDK {
1762
1787
  return response.json();
1763
1788
  }
1764
1789
  async deleteChannelAccount(id) {
1765
- await this.ensureReady();
1790
+ await this.ensureHttpReady();
1766
1791
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}`;
1767
1792
  const response = await fetch(url, { method: "DELETE", headers: this.getHttpAuthHeaders() });
1768
1793
  if (!response.ok) {
@@ -1770,7 +1795,7 @@ var SanqianSDK = class _SanqianSDK {
1770
1795
  }
1771
1796
  }
1772
1797
  async startChannelAccount(id) {
1773
- await this.ensureReady();
1798
+ await this.ensureHttpReady();
1774
1799
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}/start`;
1775
1800
  const response = await fetch(url, { method: "POST", headers: this.getHttpAuthHeaders() });
1776
1801
  if (!response.ok) {
@@ -1780,7 +1805,7 @@ var SanqianSDK = class _SanqianSDK {
1780
1805
  return response.json();
1781
1806
  }
1782
1807
  async stopChannelAccount(id) {
1783
- await this.ensureReady();
1808
+ await this.ensureHttpReady();
1784
1809
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}/stop`;
1785
1810
  const response = await fetch(url, { method: "POST", headers: this.getHttpAuthHeaders() });
1786
1811
  if (!response.ok) {
@@ -1789,7 +1814,7 @@ var SanqianSDK = class _SanqianSDK {
1789
1814
  return response.json();
1790
1815
  }
1791
1816
  async getChannelStatus(id) {
1792
- await this.ensureReady();
1817
+ await this.ensureHttpReady();
1793
1818
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}/status`;
1794
1819
  const response = await fetch(url, { headers: this.getHttpAuthHeaders() });
1795
1820
  if (!response.ok) {
@@ -1798,7 +1823,7 @@ var SanqianSDK = class _SanqianSDK {
1798
1823
  return response.json();
1799
1824
  }
1800
1825
  async probeChannelAccount(id) {
1801
- await this.ensureReady();
1826
+ await this.ensureHttpReady();
1802
1827
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}/probe`;
1803
1828
  const response = await fetch(url, { method: "POST", headers: this.getHttpAuthHeaders() });
1804
1829
  if (!response.ok) {
@@ -1807,8 +1832,32 @@ var SanqianSDK = class _SanqianSDK {
1807
1832
  }
1808
1833
  return response.json();
1809
1834
  }
1835
+ async probeChannelConfig(req) {
1836
+ await this.ensureHttpReady();
1837
+ const url = `${this.getHttpBaseUrl()}/api/channels/probe-config`;
1838
+ const response = await fetch(url, {
1839
+ method: "POST",
1840
+ headers: { ...this.getHttpAuthHeaders(), "Content-Type": "application/json" },
1841
+ body: JSON.stringify(req)
1842
+ });
1843
+ if (!response.ok) {
1844
+ const detail = await response.text();
1845
+ throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, `Failed to probe channel config: ${detail}`);
1846
+ }
1847
+ return response.json();
1848
+ }
1849
+ async getChannelConfigSchema(channelType) {
1850
+ await this.ensureHttpReady();
1851
+ const url = `${this.getHttpBaseUrl()}/api/channels/plugins/${encodeURIComponent(channelType)}/config-schema`;
1852
+ const response = await fetch(url, { headers: this.getHttpAuthHeaders() });
1853
+ if (!response.ok) {
1854
+ const detail = await response.text();
1855
+ throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, `Failed to get channel config schema: ${detail}`);
1856
+ }
1857
+ return response.json();
1858
+ }
1810
1859
  async listChannelBindings(accountId) {
1811
- await this.ensureReady();
1860
+ await this.ensureHttpReady();
1812
1861
  const params = accountId ? `?account_id=${encodeURIComponent(accountId)}` : "";
1813
1862
  const url = `${this.getHttpBaseUrl()}/api/channels/bindings${params}`;
1814
1863
  const response = await fetch(url, { headers: this.getHttpAuthHeaders() });
@@ -1818,7 +1867,7 @@ var SanqianSDK = class _SanqianSDK {
1818
1867
  return response.json();
1819
1868
  }
1820
1869
  async createChannelBinding(req) {
1821
- await this.ensureReady();
1870
+ await this.ensureHttpReady();
1822
1871
  const url = `${this.getHttpBaseUrl()}/api/channels/bindings`;
1823
1872
  const response = await fetch(url, {
1824
1873
  method: "POST",
@@ -1832,7 +1881,7 @@ var SanqianSDK = class _SanqianSDK {
1832
1881
  return response.json();
1833
1882
  }
1834
1883
  async updateChannelBinding(id, req) {
1835
- await this.ensureReady();
1884
+ await this.ensureHttpReady();
1836
1885
  const url = `${this.getHttpBaseUrl()}/api/channels/bindings/${encodeURIComponent(id)}`;
1837
1886
  const response = await fetch(url, {
1838
1887
  method: "PUT",
@@ -1846,7 +1895,7 @@ var SanqianSDK = class _SanqianSDK {
1846
1895
  return response.json();
1847
1896
  }
1848
1897
  async deleteChannelBinding(id) {
1849
- await this.ensureReady();
1898
+ await this.ensureHttpReady();
1850
1899
  const url = `${this.getHttpBaseUrl()}/api/channels/bindings/${encodeURIComponent(id)}`;
1851
1900
  const response = await fetch(url, { method: "DELETE", headers: this.getHttpAuthHeaders() });
1852
1901
  if (!response.ok) {
@@ -1854,7 +1903,7 @@ var SanqianSDK = class _SanqianSDK {
1854
1903
  }
1855
1904
  }
1856
1905
  async sendChannelMessage(req) {
1857
- await this.ensureReady();
1906
+ await this.ensureHttpReady();
1858
1907
  const url = `${this.getHttpBaseUrl()}/api/channels/send`;
1859
1908
  const response = await fetch(url, {
1860
1909
  method: "POST",