@yushaw/sanqian-sdk 0.3.20 → 0.3.21

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.
@@ -420,6 +420,17 @@ interface AgentConfig {
420
420
  * Set to false if you want the agent to be usable but not discoverable by other agents
421
421
  */
422
422
  searchable?: boolean;
423
+ /**
424
+ * Agent-level permission mode for tool execution.
425
+ * - undefined: backend default (SDK private agents inherit app security level)
426
+ * - null: clear explicit mode and use backend default
427
+ */
428
+ permission_mode?: "standard" | "elevated" | "unrestricted" | null;
429
+ /**
430
+ * Skip all permission checks (YOLO mode, mainly for ACP-style agents).
431
+ * Most agents should keep this false.
432
+ */
433
+ skip_permissions?: boolean;
423
434
  /**
424
435
  * Context providers to attach by default.
425
436
  * Uses provider ID without app prefix (auto-prefixed with your app).
@@ -456,6 +467,10 @@ interface AgentInfo {
456
467
  single_conversation_mode?: boolean;
457
468
  /** Whether this agent can be discovered via search_capability */
458
469
  searchable?: boolean;
470
+ /** Agent-level permission mode (null/undefined means backend default) */
471
+ permission_mode?: "standard" | "elevated" | "unrestricted" | null;
472
+ /** Whether all permission checks are skipped (YOLO mode) */
473
+ skip_permissions?: boolean;
459
474
  created_at?: string;
460
475
  }
461
476
  /** Conversation info */
@@ -540,6 +555,18 @@ interface AgentUpdateConfig {
540
555
  * - true/false: Set explicitly
541
556
  */
542
557
  searchable?: boolean;
558
+ /**
559
+ * Agent-level permission mode.
560
+ * - undefined: Keep existing value
561
+ * - null: Clear explicit mode (fallback to backend default)
562
+ */
563
+ permission_mode?: "standard" | "elevated" | "unrestricted" | null;
564
+ /**
565
+ * Skip all permission checks.
566
+ * - undefined: Keep existing value
567
+ * - true/false: Set explicitly
568
+ */
569
+ skip_permissions?: boolean;
543
570
  }
544
571
  /** Embedding configuration returned from Sanqian */
545
572
  interface EmbeddingConfigResult {
@@ -939,6 +966,7 @@ declare class SanqianSDK {
939
966
  total: number;
940
967
  }>;
941
968
  private getHttpBaseUrl;
969
+ private getHttpAuthHeaders;
942
970
  /**
943
971
  * Get the port number for the Sanqian backend
944
972
  * @throws Error if not connected
@@ -420,6 +420,17 @@ interface AgentConfig {
420
420
  * Set to false if you want the agent to be usable but not discoverable by other agents
421
421
  */
422
422
  searchable?: boolean;
423
+ /**
424
+ * Agent-level permission mode for tool execution.
425
+ * - undefined: backend default (SDK private agents inherit app security level)
426
+ * - null: clear explicit mode and use backend default
427
+ */
428
+ permission_mode?: "standard" | "elevated" | "unrestricted" | null;
429
+ /**
430
+ * Skip all permission checks (YOLO mode, mainly for ACP-style agents).
431
+ * Most agents should keep this false.
432
+ */
433
+ skip_permissions?: boolean;
423
434
  /**
424
435
  * Context providers to attach by default.
425
436
  * Uses provider ID without app prefix (auto-prefixed with your app).
@@ -456,6 +467,10 @@ interface AgentInfo {
456
467
  single_conversation_mode?: boolean;
457
468
  /** Whether this agent can be discovered via search_capability */
458
469
  searchable?: boolean;
470
+ /** Agent-level permission mode (null/undefined means backend default) */
471
+ permission_mode?: "standard" | "elevated" | "unrestricted" | null;
472
+ /** Whether all permission checks are skipped (YOLO mode) */
473
+ skip_permissions?: boolean;
459
474
  created_at?: string;
460
475
  }
461
476
  /** Conversation info */
@@ -540,6 +555,18 @@ interface AgentUpdateConfig {
540
555
  * - true/false: Set explicitly
541
556
  */
542
557
  searchable?: boolean;
558
+ /**
559
+ * Agent-level permission mode.
560
+ * - undefined: Keep existing value
561
+ * - null: Clear explicit mode (fallback to backend default)
562
+ */
563
+ permission_mode?: "standard" | "elevated" | "unrestricted" | null;
564
+ /**
565
+ * Skip all permission checks.
566
+ * - undefined: Keep existing value
567
+ * - true/false: Set explicitly
568
+ */
569
+ skip_permissions?: boolean;
543
570
  }
544
571
  /** Embedding configuration returned from Sanqian */
545
572
  interface EmbeddingConfigResult {
@@ -939,6 +966,7 @@ declare class SanqianSDK {
939
966
  total: number;
940
967
  }>;
941
968
  private getHttpBaseUrl;
969
+ private getHttpAuthHeaders;
942
970
  /**
943
971
  * Get the port number for the Sanqian backend
944
972
  * @throws Error if not connected
@@ -1140,6 +1140,11 @@ var SanqianSDK = class _SanqianSDK {
1140
1140
  const host = info.ws_host || "127.0.0.1";
1141
1141
  return `${protocol}://${host}:${info.port}`;
1142
1142
  }
1143
+ getHttpAuthHeaders() {
1144
+ const info = this.connectionInfo || this.config.connectionInfo;
1145
+ const token = info?.token;
1146
+ return token ? { "X-App-Token": token } : {};
1147
+ }
1143
1148
  /**
1144
1149
  * Get the port number for the Sanqian backend
1145
1150
  * @throws Error if not connected
@@ -1704,7 +1709,7 @@ var SanqianSDK = class _SanqianSDK {
1704
1709
  async listChannelPlugins() {
1705
1710
  await this.ensureReady();
1706
1711
  const url = `${this.getHttpBaseUrl()}/api/channels/plugins`;
1707
- const response = await fetch(url);
1712
+ const response = await fetch(url, { headers: this.getHttpAuthHeaders() });
1708
1713
  if (!response.ok) {
1709
1714
  throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, `Failed to list channel plugins: ${response.statusText}`);
1710
1715
  }
@@ -1713,7 +1718,7 @@ var SanqianSDK = class _SanqianSDK {
1713
1718
  async listChannelAccounts() {
1714
1719
  await this.ensureReady();
1715
1720
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts`;
1716
- const response = await fetch(url);
1721
+ const response = await fetch(url, { headers: this.getHttpAuthHeaders() });
1717
1722
  if (!response.ok) {
1718
1723
  throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, `Failed to list channel accounts: ${response.statusText}`);
1719
1724
  }
@@ -1724,7 +1729,7 @@ var SanqianSDK = class _SanqianSDK {
1724
1729
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts`;
1725
1730
  const response = await fetch(url, {
1726
1731
  method: "POST",
1727
- headers: { "Content-Type": "application/json" },
1732
+ headers: { ...this.getHttpAuthHeaders(), "Content-Type": "application/json" },
1728
1733
  body: JSON.stringify(req)
1729
1734
  });
1730
1735
  if (!response.ok) {
@@ -1736,7 +1741,7 @@ var SanqianSDK = class _SanqianSDK {
1736
1741
  async getChannelAccount(id) {
1737
1742
  await this.ensureReady();
1738
1743
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}`;
1739
- const response = await fetch(url);
1744
+ const response = await fetch(url, { headers: this.getHttpAuthHeaders() });
1740
1745
  if (!response.ok) {
1741
1746
  throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, `Failed to get channel account: ${response.statusText}`);
1742
1747
  }
@@ -1747,7 +1752,7 @@ var SanqianSDK = class _SanqianSDK {
1747
1752
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}`;
1748
1753
  const response = await fetch(url, {
1749
1754
  method: "PUT",
1750
- headers: { "Content-Type": "application/json" },
1755
+ headers: { ...this.getHttpAuthHeaders(), "Content-Type": "application/json" },
1751
1756
  body: JSON.stringify(req)
1752
1757
  });
1753
1758
  if (!response.ok) {
@@ -1759,7 +1764,7 @@ var SanqianSDK = class _SanqianSDK {
1759
1764
  async deleteChannelAccount(id) {
1760
1765
  await this.ensureReady();
1761
1766
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}`;
1762
- const response = await fetch(url, { method: "DELETE" });
1767
+ const response = await fetch(url, { method: "DELETE", headers: this.getHttpAuthHeaders() });
1763
1768
  if (!response.ok) {
1764
1769
  throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, `Failed to delete channel account: ${response.statusText}`);
1765
1770
  }
@@ -1767,7 +1772,7 @@ var SanqianSDK = class _SanqianSDK {
1767
1772
  async startChannelAccount(id) {
1768
1773
  await this.ensureReady();
1769
1774
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}/start`;
1770
- const response = await fetch(url, { method: "POST" });
1775
+ const response = await fetch(url, { method: "POST", headers: this.getHttpAuthHeaders() });
1771
1776
  if (!response.ok) {
1772
1777
  const detail = await response.text();
1773
1778
  throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, `Failed to start channel account: ${detail}`);
@@ -1777,7 +1782,7 @@ var SanqianSDK = class _SanqianSDK {
1777
1782
  async stopChannelAccount(id) {
1778
1783
  await this.ensureReady();
1779
1784
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}/stop`;
1780
- const response = await fetch(url, { method: "POST" });
1785
+ const response = await fetch(url, { method: "POST", headers: this.getHttpAuthHeaders() });
1781
1786
  if (!response.ok) {
1782
1787
  throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, `Failed to stop channel account: ${response.statusText}`);
1783
1788
  }
@@ -1786,7 +1791,7 @@ var SanqianSDK = class _SanqianSDK {
1786
1791
  async getChannelStatus(id) {
1787
1792
  await this.ensureReady();
1788
1793
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}/status`;
1789
- const response = await fetch(url);
1794
+ const response = await fetch(url, { headers: this.getHttpAuthHeaders() });
1790
1795
  if (!response.ok) {
1791
1796
  throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, `Failed to get channel status: ${response.statusText}`);
1792
1797
  }
@@ -1795,7 +1800,7 @@ var SanqianSDK = class _SanqianSDK {
1795
1800
  async probeChannelAccount(id) {
1796
1801
  await this.ensureReady();
1797
1802
  const url = `${this.getHttpBaseUrl()}/api/channels/accounts/${encodeURIComponent(id)}/probe`;
1798
- const response = await fetch(url, { method: "POST" });
1803
+ const response = await fetch(url, { method: "POST", headers: this.getHttpAuthHeaders() });
1799
1804
  if (!response.ok) {
1800
1805
  const detail = await response.text();
1801
1806
  throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, `Failed to probe channel account: ${detail}`);
@@ -1806,7 +1811,7 @@ var SanqianSDK = class _SanqianSDK {
1806
1811
  await this.ensureReady();
1807
1812
  const params = accountId ? `?account_id=${encodeURIComponent(accountId)}` : "";
1808
1813
  const url = `${this.getHttpBaseUrl()}/api/channels/bindings${params}`;
1809
- const response = await fetch(url);
1814
+ const response = await fetch(url, { headers: this.getHttpAuthHeaders() });
1810
1815
  if (!response.ok) {
1811
1816
  throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, `Failed to list channel bindings: ${response.statusText}`);
1812
1817
  }
@@ -1817,7 +1822,7 @@ var SanqianSDK = class _SanqianSDK {
1817
1822
  const url = `${this.getHttpBaseUrl()}/api/channels/bindings`;
1818
1823
  const response = await fetch(url, {
1819
1824
  method: "POST",
1820
- headers: { "Content-Type": "application/json" },
1825
+ headers: { ...this.getHttpAuthHeaders(), "Content-Type": "application/json" },
1821
1826
  body: JSON.stringify(req)
1822
1827
  });
1823
1828
  if (!response.ok) {
@@ -1831,7 +1836,7 @@ var SanqianSDK = class _SanqianSDK {
1831
1836
  const url = `${this.getHttpBaseUrl()}/api/channels/bindings/${encodeURIComponent(id)}`;
1832
1837
  const response = await fetch(url, {
1833
1838
  method: "PUT",
1834
- headers: { "Content-Type": "application/json" },
1839
+ headers: { ...this.getHttpAuthHeaders(), "Content-Type": "application/json" },
1835
1840
  body: JSON.stringify(req)
1836
1841
  });
1837
1842
  if (!response.ok) {
@@ -1843,7 +1848,7 @@ var SanqianSDK = class _SanqianSDK {
1843
1848
  async deleteChannelBinding(id) {
1844
1849
  await this.ensureReady();
1845
1850
  const url = `${this.getHttpBaseUrl()}/api/channels/bindings/${encodeURIComponent(id)}`;
1846
- const response = await fetch(url, { method: "DELETE" });
1851
+ const response = await fetch(url, { method: "DELETE", headers: this.getHttpAuthHeaders() });
1847
1852
  if (!response.ok) {
1848
1853
  throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, `Failed to delete channel binding: ${response.statusText}`);
1849
1854
  }
@@ -1853,7 +1858,7 @@ var SanqianSDK = class _SanqianSDK {
1853
1858
  const url = `${this.getHttpBaseUrl()}/api/channels/send`;
1854
1859
  const response = await fetch(url, {
1855
1860
  method: "POST",
1856
- headers: { "Content-Type": "application/json" },
1861
+ headers: { ...this.getHttpAuthHeaders(), "Content-Type": "application/json" },
1857
1862
  body: JSON.stringify(req)
1858
1863
  });
1859
1864
  if (!response.ok) {