@agentick/client-multiplexer 0.1.9 → 0.2.1

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.
Files changed (2) hide show
  1. package/README.md +26 -25
  2. package/package.json +7 -10
package/README.md CHANGED
@@ -13,21 +13,21 @@ pnpm add @agentick/client-multiplexer
13
13
  ## Quick Start
14
14
 
15
15
  ```typescript
16
- import { createClient } from '@agentick/client';
17
- import { createSharedTransport } from '@agentick/client-multiplexer';
16
+ import { createClient } from "@agentick/client";
17
+ import { createSharedTransport } from "@agentick/client-multiplexer";
18
18
 
19
19
  // Create client with shared transport
20
20
  const client = createClient({
21
- baseUrl: '/api',
22
- transport: createSharedTransport({ baseUrl: '/api', token: 'your-token' }),
21
+ baseUrl: "/api",
22
+ transport: createSharedTransport({ baseUrl: "/api", token: "your-token" }),
23
23
  });
24
24
 
25
25
  // Use exactly like a regular client
26
- const session = client.session('main');
26
+ const session = client.session("main");
27
27
  session.subscribe();
28
28
  session.onEvent((event) => console.log(event));
29
29
 
30
- const handle = session.send('Hello!');
30
+ const handle = session.send("Hello!");
31
31
  await handle.result;
32
32
  ```
33
33
 
@@ -56,22 +56,23 @@ The multiplexer uses browser tab leader election to ensure only one tab maintain
56
56
  Creates a shared transport instance. Supports both SSE and WebSocket transports.
57
57
 
58
58
  ```typescript
59
- import { createSharedTransport, type SharedTransportConfig } from '@agentick/client-multiplexer';
59
+ import { createSharedTransport, type SharedTransportConfig } from "@agentick/client-multiplexer";
60
60
 
61
61
  // SSE transport (default for http:// URLs)
62
62
  const sseTransport = createSharedTransport({
63
- baseUrl: 'https://api.example.com',
64
- token: 'your-auth-token', // Optional
65
- timeout: 30000, // Optional
66
- withCredentials: true, // Optional
63
+ baseUrl: "https://api.example.com",
64
+ token: "your-auth-token", // Optional
65
+ timeout: 30000, // Optional
66
+ withCredentials: true, // Optional
67
67
  });
68
68
 
69
69
  // WebSocket transport (default for ws:// URLs)
70
70
  const wsTransport = createSharedTransport({
71
- baseUrl: 'wss://api.example.com',
72
- token: 'your-auth-token',
73
- clientId: 'my-client', // Optional
74
- reconnect: { // Optional
71
+ baseUrl: "wss://api.example.com",
72
+ token: "your-auth-token",
73
+ clientId: "my-client", // Optional
74
+ reconnect: {
75
+ // Optional
75
76
  enabled: true,
76
77
  maxAttempts: 5,
77
78
  delay: 1000,
@@ -80,8 +81,8 @@ const wsTransport = createSharedTransport({
80
81
 
81
82
  // Explicit transport selection
82
83
  const explicitTransport = createSharedTransport({
83
- baseUrl: 'https://api.example.com',
84
- transport: 'websocket', // Force WebSocket even with http:// URL
84
+ baseUrl: "https://api.example.com",
85
+ transport: "websocket", // Force WebSocket even with http:// URL
85
86
  });
86
87
  ```
87
88
 
@@ -91,31 +92,31 @@ The transport implements `ClientTransport` from `@agentick/client` plus addition
91
92
 
92
93
  ```typescript
93
94
  // Check leadership status
94
- transport.isLeader; // boolean
95
+ transport.isLeader; // boolean
95
96
 
96
97
  // Get unique tab identifier
97
- transport.tabId; // string
98
+ transport.tabId; // string
98
99
 
99
100
  // Listen for leadership changes
100
101
  transport.onLeadershipChange((isLeader) => {
101
- console.log(isLeader ? 'This tab is now the leader' : 'Leadership transferred');
102
+ console.log(isLeader ? "This tab is now the leader" : "Leadership transferred");
102
103
  });
103
104
  ```
104
105
 
105
106
  ### Accessing Transport from Client
106
107
 
107
108
  ```typescript
108
- import { createClient, type ClientTransport } from '@agentick/client';
109
- import { createSharedTransport, type SharedTransport } from '@agentick/client-multiplexer';
109
+ import { createClient, type ClientTransport } from "@agentick/client";
110
+ import { createSharedTransport, type SharedTransport } from "@agentick/client-multiplexer";
110
111
 
111
112
  const client = createClient({
112
- baseUrl: '/api',
113
- transport: createSharedTransport({ baseUrl: '/api' }),
113
+ baseUrl: "/api",
114
+ transport: createSharedTransport({ baseUrl: "/api" }),
114
115
  });
115
116
 
116
117
  // Access the transport for leadership info
117
118
  const transport = client.getTransport() as SharedTransport | undefined;
118
- console.log('Is leader:', transport?.isLeader);
119
+ console.log("Is leader:", transport?.isLeader);
119
120
  ```
120
121
 
121
122
  ## Architecture
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@agentick/client-multiplexer",
3
- "version": "0.1.9",
3
+ "version": "0.2.1",
4
4
  "description": "Multi-tab connection multiplexer for Agentick client",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/agenticklabs/agentick.git",
8
+ "directory": "packages/client-multiplexer"
9
+ },
5
10
  "files": [
6
11
  "dist"
7
12
  ],
@@ -15,19 +20,11 @@
15
20
  }
16
21
  },
17
22
  "dependencies": {
18
- "@agentick/client": "0.1.9"
23
+ "@agentick/client": "0.2.1"
19
24
  },
20
25
  "devDependencies": {
21
26
  "typescript": "^5.8.3"
22
27
  },
23
- "peerDependencies": {
24
- "@agentick/client": "0.1.9"
25
- },
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/agenticklabs/agentick.git",
29
- "directory": "packages/client-multiplexer"
30
- },
31
28
  "scripts": {
32
29
  "build": "tsc -p tsconfig.build.json",
33
30
  "dev": "tsc -p tsconfig.build.json --watch",