agentlink-sdk 1.0.5 → 1.0.6

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
@@ -34,12 +34,17 @@ pnpm add agentlink-sdk
34
34
 
35
35
  ### 基本使用
36
36
 
37
+ SDK 默认使用服务端地址 `https://mixlab.top`,可直接创建客户端;如需使用自建或其它服务端,可传入 `serverUrl` 覆盖默认值。
38
+
37
39
  ```typescript
38
40
  import { AgentLinkClient } from 'agentlink-sdk';
39
41
 
40
- // 创建客户端实例
42
+ // 使用默认地址 https://mixlab.top
43
+ const client = new AgentLinkClient();
44
+
45
+ // 或指定自定义服务端地址
41
46
  const client = new AgentLinkClient({
42
- serverUrl: 'https://agent-link-server.vercel.app'
47
+ serverUrl: 'https://your-agentlink-server.com'
43
48
  });
44
49
 
45
50
  // 发送数据
@@ -69,7 +74,7 @@ new AgentLinkClient(options: AgentLinkClientOptions)
69
74
 
70
75
  **参数:**
71
76
 
72
- - `options.serverUrl` (string, 必需): 服务端验证地址,例如 `'https://agentlink-server.vercel.app'`
77
+ - `options.serverUrl` (string, 可选): 服务端验证地址。不传时使用默认地址 `https://mixlab.top`;可传入自定义地址如 `'https://your-server.com'`
73
78
 
74
79
  #### 方法
75
80
 
@@ -223,10 +228,18 @@ console.log('所有白名单:', allInfo.whitelist);
223
228
 
224
229
  ```typescript
225
230
  interface AgentLinkClientOptions {
226
- serverUrl: string;
231
+ serverUrl?: string; // 可选,默认 'https://mixlab.top'
227
232
  }
228
233
  ```
229
234
 
235
+ ### DEFAULT_SERVER_URL
236
+
237
+ ```typescript
238
+ const DEFAULT_SERVER_URL = 'https://mixlab.top';
239
+ ```
240
+
241
+ 如需与默认地址保持一致(例如在配置中引用),可从 SDK 导入:`import { DEFAULT_SERVER_URL } from 'agentlink-sdk'`。
242
+
230
243
  ### SenderInfo
231
244
 
232
245
  ```typescript
@@ -289,9 +302,8 @@ interface WhitelistResponse {
289
302
  ### 发送数据示例
290
303
 
291
304
  ```typescript
292
- const client = new AgentLinkClient({
293
- serverUrl: 'https://agent-link-server.vercel.app'
294
- });
305
+ // 使用默认地址
306
+ const client = new AgentLinkClient();
295
307
 
296
308
  // 发送复杂数据
297
309
  await client.sendData(
@@ -310,9 +322,8 @@ await client.sendData(
310
322
  ### 接收数据示例
311
323
 
312
324
  ```typescript
313
- const client = new AgentLinkClient({
314
- serverUrl: 'https://agent-link-server.vercel.app'
315
- });
325
+ // 使用默认地址,也可传入 serverUrl 使用自建服务端
326
+ const client = new AgentLinkClient();
316
327
 
317
328
  // 监听数据
318
329
  client.receiveData((data, type, senderInfo, verification) => {
package/dist/index.d.mts CHANGED
@@ -1,12 +1,15 @@
1
1
  interface AgentLinkClientOptions {
2
2
  /**
3
- * 服务端验证地址
4
- * 例如: 'https://agentlink-server.vercel.app'
3
+ * 服务端验证地址,不传则使用默认地址 https://mixlab.top
4
+ * 例如: 'https://mixlab.top' 或自定义 'https://your-server.com'
5
5
  */
6
- serverUrl: string;
6
+ serverUrl?: string;
7
7
  }
8
+ /** 默认服务端地址 */
9
+ declare const DEFAULT_SERVER_URL = "https://mixlab.top";
8
10
  interface WhitelistInfo {
9
11
  domain: string;
12
+ name?: string | null;
10
13
  description?: string | null;
11
14
  }
12
15
  interface WhitelistResponse {
@@ -28,7 +31,7 @@ declare class AgentLinkClient {
28
31
  private static tokenCache;
29
32
  private static whitelistCache;
30
33
  private static CACHE_TTL;
31
- constructor(options: AgentLinkClientOptions);
34
+ constructor(options?: AgentLinkClientOptions);
32
35
  /**
33
36
  * 确保有 Token(自动获取)
34
37
  */
@@ -117,4 +120,4 @@ declare function verifyWhitelist(serverUrl: string, origin?: string): Promise<bo
117
120
  */
118
121
  declare function fetchWhitelistInfo(serverUrl: string, includeAll?: boolean): Promise<any>;
119
122
 
120
- export { AgentLinkClient, type AgentLinkClientOptions, type SenderInfo, type URLData, type WhitelistInfo, type WhitelistResponse, base64ToUint8Array, compress, decodeDataFromUrl, decompress, encodeDataToUrl, fetchWhitelistInfo, uint8ArrayToBase64, verifyWhitelist };
123
+ export { AgentLinkClient, type AgentLinkClientOptions, DEFAULT_SERVER_URL, type SenderInfo, type URLData, type WhitelistInfo, type WhitelistResponse, base64ToUint8Array, compress, decodeDataFromUrl, decompress, encodeDataToUrl, fetchWhitelistInfo, uint8ArrayToBase64, verifyWhitelist };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  interface AgentLinkClientOptions {
2
2
  /**
3
- * 服务端验证地址
4
- * 例如: 'https://agentlink-server.vercel.app'
3
+ * 服务端验证地址,不传则使用默认地址 https://mixlab.top
4
+ * 例如: 'https://mixlab.top' 或自定义 'https://your-server.com'
5
5
  */
6
- serverUrl: string;
6
+ serverUrl?: string;
7
7
  }
8
+ /** 默认服务端地址 */
9
+ declare const DEFAULT_SERVER_URL = "https://mixlab.top";
8
10
  interface WhitelistInfo {
9
11
  domain: string;
12
+ name?: string | null;
10
13
  description?: string | null;
11
14
  }
12
15
  interface WhitelistResponse {
@@ -28,7 +31,7 @@ declare class AgentLinkClient {
28
31
  private static tokenCache;
29
32
  private static whitelistCache;
30
33
  private static CACHE_TTL;
31
- constructor(options: AgentLinkClientOptions);
34
+ constructor(options?: AgentLinkClientOptions);
32
35
  /**
33
36
  * 确保有 Token(自动获取)
34
37
  */
@@ -117,4 +120,4 @@ declare function verifyWhitelist(serverUrl: string, origin?: string): Promise<bo
117
120
  */
118
121
  declare function fetchWhitelistInfo(serverUrl: string, includeAll?: boolean): Promise<any>;
119
122
 
120
- export { AgentLinkClient, type AgentLinkClientOptions, type SenderInfo, type URLData, type WhitelistInfo, type WhitelistResponse, base64ToUint8Array, compress, decodeDataFromUrl, decompress, encodeDataToUrl, fetchWhitelistInfo, uint8ArrayToBase64, verifyWhitelist };
123
+ export { AgentLinkClient, type AgentLinkClientOptions, DEFAULT_SERVER_URL, type SenderInfo, type URLData, type WhitelistInfo, type WhitelistResponse, base64ToUint8Array, compress, decodeDataFromUrl, decompress, encodeDataToUrl, fetchWhitelistInfo, uint8ArrayToBase64, verifyWhitelist };
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AgentLinkClient: () => AgentLinkClient,
24
+ DEFAULT_SERVER_URL: () => DEFAULT_SERVER_URL,
24
25
  base64ToUint8Array: () => base64ToUint8Array,
25
26
  compress: () => compress,
26
27
  decodeDataFromUrl: () => decodeDataFromUrl,
@@ -173,12 +174,14 @@ async function fetchWhitelistInfo(serverUrl, includeAll = false) {
173
174
  }
174
175
 
175
176
  // src/client.ts
177
+ var DEFAULT_SERVER_URL = "https://mixlab.top";
176
178
  var _AgentLinkClient = class _AgentLinkClient {
177
- constructor(options) {
179
+ constructor(options = {}) {
178
180
  // 发送端 Token 缓存(实例级别)
179
181
  this.token = null;
180
182
  this.tokenPromise = null;
181
- this.serverUrl = options.serverUrl.replace(/\/$/, "");
183
+ const base = options.serverUrl ?? DEFAULT_SERVER_URL;
184
+ this.serverUrl = base.replace(/\/$/, "");
182
185
  }
183
186
  /**
184
187
  * 确保有 Token(自动获取)
package/dist/index.mjs CHANGED
@@ -139,12 +139,14 @@ async function fetchWhitelistInfo(serverUrl, includeAll = false) {
139
139
  }
140
140
 
141
141
  // src/client.ts
142
+ var DEFAULT_SERVER_URL = "https://mixlab.top";
142
143
  var _AgentLinkClient = class _AgentLinkClient {
143
- constructor(options) {
144
+ constructor(options = {}) {
144
145
  // 发送端 Token 缓存(实例级别)
145
146
  this.token = null;
146
147
  this.tokenPromise = null;
147
- this.serverUrl = options.serverUrl.replace(/\/$/, "");
148
+ const base = options.serverUrl ?? DEFAULT_SERVER_URL;
149
+ this.serverUrl = base.replace(/\/$/, "");
148
150
  }
149
151
  /**
150
152
  * 确保有 Token(自动获取)
@@ -304,6 +306,7 @@ _AgentLinkClient.CACHE_TTL = 60 * 60 * 1e3;
304
306
  var AgentLinkClient = _AgentLinkClient;
305
307
  export {
306
308
  AgentLinkClient,
309
+ DEFAULT_SERVER_URL,
307
310
  base64ToUint8Array,
308
311
  compress,
309
312
  decodeDataFromUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentlink-sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "AgentLink client SDK for cross-domain data synchronization via URL hash",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",