@axiom-lattice/client-sdk 4.3.1 → 4.3.4

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.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * RuntimeAxiomClient transport tests.
3
+ *
4
+ * Asserts the reuse-first transport: the Console client's own `/api/...`
5
+ * paths land on the gateway's `/runtime/api` console mirror, baseURL points
6
+ * at the web app runtime, and the web-app identity (verified bearer or
7
+ * unverified external-user header) is injected per request.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=runtime-client.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-client.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/runtime-client.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * RuntimeAxiomClient transport tests.
3
+ *
4
+ * Asserts the reuse-first transport: the Console client's own `/api/...`
5
+ * paths land on the gateway's `/runtime/api` console mirror, baseURL points
6
+ * at the web app runtime, and the web-app identity (verified bearer or
7
+ * unverified external-user header) is injected per request.
8
+ */
9
+ import { RuntimeAxiomClient } from "../runtime-client";
10
+ const mockFetch = jest.fn();
11
+ global.fetch = mockFetch;
12
+ function mockJsonResponse(body, status = 200) {
13
+ mockFetch.mockResolvedValue({
14
+ ok: status < 400,
15
+ status,
16
+ json: async () => body,
17
+ });
18
+ }
19
+ function makeVerifiedClient(token = "tok-1") {
20
+ return new RuntimeAxiomClient({
21
+ gatewayUrl: "http://gw.test",
22
+ webAppId: "webapp_1",
23
+ assistantId: "asst-1",
24
+ transport: "sse",
25
+ identity: { mode: "verified", tokenProvider: async () => token },
26
+ });
27
+ }
28
+ function makeUnverifiedClient() {
29
+ return new RuntimeAxiomClient({
30
+ gatewayUrl: "http://gw.test/",
31
+ webAppId: "webapp_1",
32
+ assistantId: "asst-1",
33
+ transport: "sse",
34
+ identity: { mode: "unverified", userId: "vendor-user-42" },
35
+ });
36
+ }
37
+ /** Drive the transport exactly like the chat stack's threads.list does. */
38
+ async function listThreads(client) {
39
+ return client.listThreads();
40
+ }
41
+ function lastRequest() {
42
+ const [url, init] = mockFetch.mock.calls[0];
43
+ return [url, init];
44
+ }
45
+ describe("RuntimeAxiomClient", () => {
46
+ afterEach(() => mockFetch.mockClear());
47
+ it("points every Console /api path at the /runtime/api mirror", async () => {
48
+ const client = makeVerifiedClient();
49
+ mockJsonResponse({ success: true, data: { records: [] } });
50
+ await listThreads(client);
51
+ expect(mockFetch).toHaveBeenCalledTimes(1);
52
+ const [url] = lastRequest();
53
+ expect(url).toBe("http://gw.test/api/web-apps/webapp_1/runtime/api/assistants/asst-1/threads");
54
+ });
55
+ it("resolves and injects the bearer lazily (no explicit primeToken call)", async () => {
56
+ const client = makeVerifiedClient("tok-1");
57
+ mockJsonResponse({ success: true, data: { records: [] } });
58
+ await listThreads(client);
59
+ expect(new Headers(lastRequest()[1].headers).get("Authorization")).toBe("Bearer tok-1");
60
+ });
61
+ it("single-flights the token provider across concurrent requests", async () => {
62
+ const provider = jest.fn().mockResolvedValue("tok-2");
63
+ const client = new RuntimeAxiomClient({
64
+ gatewayUrl: "http://gw.test",
65
+ webAppId: "webapp_1",
66
+ assistantId: "asst-1",
67
+ transport: "sse",
68
+ identity: { mode: "verified", tokenProvider: provider },
69
+ });
70
+ mockJsonResponse({ success: true, data: { records: [] } });
71
+ await Promise.all([listThreads(client), listThreads(client)]);
72
+ expect(provider).toHaveBeenCalledTimes(1);
73
+ });
74
+ it("injects X-Axiom-External-User-Id in unverified mode (no Authorization)", async () => {
75
+ const client = makeUnverifiedClient();
76
+ mockJsonResponse({ success: true, data: { records: [] } });
77
+ await listThreads(client);
78
+ const headers = new Headers(lastRequest()[1].headers);
79
+ expect(headers.get("X-Axiom-External-User-Id")).toBe("vendor-user-42");
80
+ expect(headers.get("Authorization")).toBeNull();
81
+ });
82
+ it("trims a trailing slash from the gateway URL", async () => {
83
+ const client = makeUnverifiedClient();
84
+ mockJsonResponse({ success: true, data: { records: [] } });
85
+ await listThreads(client);
86
+ expect(lastRequest()[0]).toContain("/api/web-apps/webapp_1/runtime/api/");
87
+ });
88
+ it("rejects an unverified identity with an empty userId", () => {
89
+ expect(() => new RuntimeAxiomClient({
90
+ gatewayUrl: "http://gw.test",
91
+ webAppId: "webapp_1",
92
+ assistantId: "asst-1",
93
+ transport: "sse",
94
+ identity: { mode: "unverified", userId: "" },
95
+ })).toThrow(/non-empty userId/);
96
+ });
97
+ it("rethrows non-ok responses with a status-carrying error", async () => {
98
+ const client = makeVerifiedClient();
99
+ mockJsonResponse({ error: "nope" }, 401);
100
+ await expect(listThreads(client)).rejects.toMatchObject({ status: 401 });
101
+ });
102
+ it("clones into a sibling runtime client scoped to the cloned assistant", async () => {
103
+ const client = makeVerifiedClient("tok-1");
104
+ mockJsonResponse({ success: true, data: { records: [] } });
105
+ const clone = client.clone({ assistantId: "asst-2" });
106
+ expect(clone).not.toBe(client);
107
+ await listThreads(clone);
108
+ const [url, init] = lastRequest();
109
+ expect(url).toContain("/runtime/api/assistants/asst-2/threads");
110
+ expect(new Headers(init.headers).get("Authorization")).toBe("Bearer tok-1");
111
+ });
112
+ });
113
+ //# sourceMappingURL=runtime-client.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-client.test.js","sourceRoot":"","sources":["../../src/__tests__/runtime-client.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAuC,CAAC;AAChE,MAAkC,CAAC,KAAK,GAAG,SAAS,CAAC;AAEtD,SAAS,gBAAgB,CAAC,IAAa,EAAE,MAAM,GAAG,GAAG;IACnD,SAAS,CAAC,iBAAiB,CAAC;QAC1B,EAAE,EAAE,MAAM,GAAG,GAAG;QAChB,MAAM;QACN,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;KACX,C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AC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -750,7 +750,7 @@ interface UpdateWorkspaceRequest {
750
750
  *
751
751
  * Defaults to "business" for legacy data and omitted input.
752
752
  */
753
- type ProjectKind = "business" | "training" | "personal";
753
+ type ProjectKind = "business" | "training" | "personal" | "public";
754
754
  /**
755
755
  * Project information
756
756
  */
@@ -2118,6 +2118,70 @@ declare class Client extends AbstractClient {
2118
2118
  private streamRun;
2119
2119
  }
2120
2120
 
2121
+ /**
2122
+ * Identity presented to an Agent Web App runtime by {@link RuntimeAxiomClient}.
2123
+ *
2124
+ * Mirrors the web-app SDK identity union: `verified` sessions authenticate
2125
+ * with a short-lived `Authorization: Bearer` token resolved (and refreshed)
2126
+ * per transport use, while `unverified` sessions identify through the stable
2127
+ * `X-Axiom-External-User-Id` header the gateway accepts without a token.
2128
+ */
2129
+ type RuntimeAxiomIdentity = {
2130
+ mode: "verified";
2131
+ tokenProvider: () => Promise<string>;
2132
+ } | {
2133
+ mode: "unverified";
2134
+ userId: string;
2135
+ };
2136
+ /**
2137
+ * AxiomClient transport wired to an Agent Web App runtime instead of the
2138
+ * Console. Reuse-first: only the transport differs. `baseURL` points at
2139
+ * `<gateway>/api/web-apps/:webAppId/runtime`, every Console `/api/...` path
2140
+ * the chat stack produces lands on the gateway's `/runtime/api` console
2141
+ * mirror, and the web-app identity (bearer or external-user header) is
2142
+ * injected fresh per request.
2143
+ *
2144
+ * The chat stack (AgentThreadContext + Chating) therefore runs unmodified.
2145
+ */
2146
+ declare class RuntimeAxiomClient extends Client {
2147
+ private readonly gatewayUrl;
2148
+ private readonly webAppId;
2149
+ private readonly identity;
2150
+ private token;
2151
+ private tokenPromise;
2152
+ constructor(config: Omit<ClientConfig, "apiKey" | "baseURL"> & {
2153
+ gatewayUrl: string;
2154
+ webAppId: string;
2155
+ identity: RuntimeAxiomIdentity;
2156
+ });
2157
+ /**
2158
+ * Resolve (and cache) the current identity credential.
2159
+ *
2160
+ * - `verified`: resolves the bearer token from the provider (single-flight;
2161
+ * call again later to force a refresh, or pass through a fresh provider).
2162
+ * - `unverified`: no credential is needed; returns `""`.
2163
+ *
2164
+ * Transport methods resolve this lazily, so the chat stack needs no explicit
2165
+ * priming — the first request triggers the token provider.
2166
+ */
2167
+ primeToken(): Promise<string>;
2168
+ private identityHeaders;
2169
+ protected getAllHeaders(): Record<string, string>;
2170
+ protected makeRequest<T>(url: string, options?: {
2171
+ method?: string;
2172
+ body?: unknown;
2173
+ headers?: Record<string, string>;
2174
+ }): Promise<T>;
2175
+ private getBaseUrl;
2176
+ /**
2177
+ * Clone into a real sibling instance sharing the runtime identity so the
2178
+ * `AxiomLatticeProvider` per-assistant `clone({ assistantId })` cache keeps
2179
+ * working (each clone carries its own resolved credential cache).
2180
+ */
2181
+ protected createInstance(config: ClientConfig): Client;
2182
+ protected streamRequest(_options: RunOptions, _onEvent: (event: MessageChunk) => void, _onComplete?: (state?: AgentState) => void, _onError?: (error: Error) => void): () => void;
2183
+ }
2184
+
2121
2185
  /**
2122
2186
  * WeChat Mini Program client for interacting with the Axiom Lattice Agent Service API
2123
2187
  */
@@ -2288,4 +2352,4 @@ declare function createSimpleMessageMerger(): {
2288
2352
  reset: () => void;
2289
2353
  };
2290
2354
 
2291
- export { A2AKeyListItem, A2AKeysListResponse, AbortAgentParams, AbstractClient, AddProjectBotMembershipInput, AddProjectMembershipInput, AgentState, AgentWebAppsListResponse, ApiError, ArchiveInput, Assistant, AssistantListResponse, AssistantResponse, AuthenticationError, CapabilityBundleListResponse, ChatResponse, ChatSendOptions, ChatStreamOptions, Client, ClientConfig, CompleteTaskInput, CompleteTaskResponse, CreateA2AKeyInput, CreateAssistantOptions, CreateProjectRequest, CreateThreadOptions, CreateWorkspaceRequest, DatabaseConfigResponse, DatabaseConfigsListResponse, DatasourcesListResponse, ExportBundle, ExportConfigResult, ExportConfirmationRequired, ExportDownload, ExportEntityIds, ExportEntityPreview, ExportEntityPreviewMap, ExportImportClient, ExportJobResult, ExportableEntity, ExportableTypeInfo, FileItem, GetMessagesOptions, GetScheduledTasksOptions, HydratedProjectRoomBusinessEvent, ImportApplyResult, ImportConflict, ImportEntityResult, ImportInsertion, ImportPreviewError, ImportPreviewResult, ImportResolution, ImportResolutions, ImportSource, InvalidCapabilityBundleSummary, ListAgentWebAppsParams, ListProjectRoomMessagesOptions, ListThreadsOptions, LocalA2ATemplatesListResponse, McpServerResponse, McpServersListResponse, MetricsConfigResponse, MetricsConfigsListResponse, MutationExpectedUpdatedAt, NetworkError, PendingMessage, Project, ProjectCapabilitiesResponse, ProjectKind, ProjectRoomBotRecord, ProjectRoomClientError, ProjectRoomDispatchErrorCode, ProjectRoomDispatchResult, ProjectRoomEventConnection, ProjectRoomMembershipRecord, ProjectRoomMessageRecord, ProjectRoomPublicBotRecord, ProjectRoomPublicMembershipRecord, ProjectRoomRecord, ProjectRoomSendResult, ProjectRoomSseFrame, ProjectRoomsClient, RegisterToolOptions, RemovePendingMessageOptions, ResourcesClient, ResumeStreamOptions, RetryConfig, RunOptions, ScheduleExecutionType, ScheduledTask, ScheduledTaskStatus, ScheduledTasksListResponse, SendProjectRoomMessageInput, StorageType, StreamCallbacks, StreamEvent, TaskLifecycleWarning, TaskResponse, TasksListResponse, TestConnectionResponse, TestMcpServerResponse, Thread, ThreadListResponse, ThreadResponse, Tool, ToolResponse, ToolsListResponse, Transport, UpdateAssistantOptions, UpdateProjectBotMembershipInput, UpdateProjectMembershipInput, UpdateProjectRequest, UpdateThreadOptions, UpdateWorkspaceRequest, WeChatClient, Workspace, WorkspaceClient, createSimpleMessageMerger };
2355
+ export { A2AKeyListItem, A2AKeysListResponse, AbortAgentParams, AbstractClient, AddProjectBotMembershipInput, AddProjectMembershipInput, AgentState, AgentWebAppsListResponse, ApiError, ArchiveInput, Assistant, AssistantListResponse, AssistantResponse, AuthenticationError, CapabilityBundleListResponse, ChatResponse, ChatSendOptions, ChatStreamOptions, Client, ClientConfig, CompleteTaskInput, CompleteTaskResponse, CreateA2AKeyInput, CreateAssistantOptions, CreateProjectRequest, CreateThreadOptions, CreateWorkspaceRequest, DatabaseConfigResponse, DatabaseConfigsListResponse, DatasourcesListResponse, ExportBundle, ExportConfigResult, ExportConfirmationRequired, ExportDownload, ExportEntityIds, ExportEntityPreview, ExportEntityPreviewMap, ExportImportClient, ExportJobResult, ExportableEntity, ExportableTypeInfo, FileItem, GetMessagesOptions, GetScheduledTasksOptions, HydratedProjectRoomBusinessEvent, ImportApplyResult, ImportConflict, ImportEntityResult, ImportInsertion, ImportPreviewError, ImportPreviewResult, ImportResolution, ImportResolutions, ImportSource, InvalidCapabilityBundleSummary, ListAgentWebAppsParams, ListProjectRoomMessagesOptions, ListThreadsOptions, LocalA2ATemplatesListResponse, McpServerResponse, McpServersListResponse, MetricsConfigResponse, MetricsConfigsListResponse, MutationExpectedUpdatedAt, NetworkError, PendingMessage, Project, ProjectCapabilitiesResponse, ProjectKind, ProjectRoomBotRecord, ProjectRoomClientError, ProjectRoomDispatchErrorCode, ProjectRoomDispatchResult, ProjectRoomEventConnection, ProjectRoomMembershipRecord, ProjectRoomMessageRecord, ProjectRoomPublicBotRecord, ProjectRoomPublicMembershipRecord, ProjectRoomRecord, ProjectRoomSendResult, ProjectRoomSseFrame, ProjectRoomsClient, RegisterToolOptions, RemovePendingMessageOptions, ResourcesClient, ResumeStreamOptions, RetryConfig, RunOptions, RuntimeAxiomClient, RuntimeAxiomIdentity, ScheduleExecutionType, ScheduledTask, ScheduledTaskStatus, ScheduledTasksListResponse, SendProjectRoomMessageInput, StorageType, StreamCallbacks, StreamEvent, TaskLifecycleWarning, TaskResponse, TasksListResponse, TestConnectionResponse, TestMcpServerResponse, Thread, ThreadListResponse, ThreadResponse, Tool, ToolResponse, ToolsListResponse, Transport, UpdateAssistantOptions, UpdateProjectBotMembershipInput, UpdateProjectMembershipInput, UpdateProjectRequest, UpdateThreadOptions, UpdateWorkspaceRequest, WeChatClient, Workspace, WorkspaceClient, createSimpleMessageMerger };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -1837,6 +1837,7 @@ __export(src_exports, {
1837
1837
  ProjectRoomClientError: () => ProjectRoomClientError,
1838
1838
  ProjectRoomsClient: () => ProjectRoomsClient,
1839
1839
  ResourcesClient: () => ResourcesClient,
1840
+ RuntimeAxiomClient: () => RuntimeAxiomClient,
1840
1841
  ScheduleExecutionType: () => ScheduleExecutionType,
1841
1842
  ScheduledTaskStatus: () => ScheduledTaskStatus,
1842
1843
  WeChatClient: () => WeChatClient,
@@ -4189,6 +4190,115 @@ var _Client = class extends AbstractClient {
4189
4190
  var Client = _Client;
4190
4191
  Client.globalWorkspaceHeaders = {};
4191
4192
 
4193
+ // src/runtime-client.ts
4194
+ var RuntimeAxiomClient = class extends Client {
4195
+ constructor(config) {
4196
+ super({
4197
+ ...config,
4198
+ baseURL: `${config.gatewayUrl.replace(/\/$/, "")}/api/web-apps/${config.webAppId}/runtime`,
4199
+ apiKey: "runtime-bearer"
4200
+ });
4201
+ this.token = null;
4202
+ this.tokenPromise = null;
4203
+ this.gatewayUrl = config.gatewayUrl.replace(/\/$/, "");
4204
+ this.webAppId = config.webAppId;
4205
+ this.identity = config.identity;
4206
+ if (config.identity.mode === "unverified" && config.identity.userId.length === 0) {
4207
+ throw new Error("RuntimeAxiomClient requires a non-empty userId in unverified mode");
4208
+ }
4209
+ }
4210
+ /**
4211
+ * Resolve (and cache) the current identity credential.
4212
+ *
4213
+ * - `verified`: resolves the bearer token from the provider (single-flight;
4214
+ * call again later to force a refresh, or pass through a fresh provider).
4215
+ * - `unverified`: no credential is needed; returns `""`.
4216
+ *
4217
+ * Transport methods resolve this lazily, so the chat stack needs no explicit
4218
+ * priming — the first request triggers the token provider.
4219
+ */
4220
+ async primeToken() {
4221
+ if (this.identity.mode !== "verified")
4222
+ return "";
4223
+ if (!this.tokenPromise) {
4224
+ this.tokenPromise = this.identity.tokenProvider().then((token) => {
4225
+ this.token = token;
4226
+ return token;
4227
+ });
4228
+ }
4229
+ return this.tokenPromise;
4230
+ }
4231
+ identityHeaders() {
4232
+ if (this.identity.mode === "verified") {
4233
+ return { Authorization: `Bearer ${this.token ?? ""}` };
4234
+ }
4235
+ return { "X-Axiom-External-User-Id": this.identity.userId };
4236
+ }
4237
+ getAllHeaders() {
4238
+ const workspace = this.getWorkspaceHeaders();
4239
+ return {
4240
+ ...this.identityHeaders(),
4241
+ ...workspace
4242
+ };
4243
+ }
4244
+ async makeRequest(url, options) {
4245
+ await this.primeToken();
4246
+ const method = options?.method ?? "GET";
4247
+ const headers = {
4248
+ "Content-Type": "application/json",
4249
+ ...this.identityHeaders(),
4250
+ ...options?.headers ?? {}
4251
+ };
4252
+ const requestOptions = { method, headers };
4253
+ if (options?.body !== void 0) {
4254
+ if (options.body instanceof FormData) {
4255
+ requestOptions.body = options.body;
4256
+ delete headers["Content-Type"];
4257
+ } else {
4258
+ requestOptions.body = JSON.stringify(options.body);
4259
+ }
4260
+ }
4261
+ const response = await fetch(`${this.getBaseUrl()}${url}`, requestOptions);
4262
+ if (!response.ok) {
4263
+ let message = `HTTP ${response.status}`;
4264
+ try {
4265
+ const body = await response.json();
4266
+ message = body.error ?? body.message ?? message;
4267
+ } catch {
4268
+ }
4269
+ const error = new Error(message);
4270
+ error.status = response.status;
4271
+ throw error;
4272
+ }
4273
+ if (response.status === 204)
4274
+ return void 0;
4275
+ return await response.json();
4276
+ }
4277
+ getBaseUrl() {
4278
+ return this.config.baseURL;
4279
+ }
4280
+ /**
4281
+ * Clone into a real sibling instance sharing the runtime identity so the
4282
+ * `AxiomLatticeProvider` per-assistant `clone({ assistantId })` cache keeps
4283
+ * working (each clone carries its own resolved credential cache).
4284
+ */
4285
+ createInstance(config) {
4286
+ return new RuntimeAxiomClient({
4287
+ gatewayUrl: this.gatewayUrl,
4288
+ webAppId: this.webAppId,
4289
+ identity: this.identity,
4290
+ assistantId: config.assistantId,
4291
+ transport: config.transport,
4292
+ ...config.timeout !== void 0 ? { timeout: config.timeout } : {},
4293
+ ...config.headers !== void 0 ? { headers: config.headers } : {},
4294
+ ...config.retry !== void 0 ? { retry: config.retry } : {}
4295
+ });
4296
+ }
4297
+ streamRequest(_options, _onEvent, _onComplete, _onError) {
4298
+ throw new Error("RuntimeAxiomClient uses resumeStream; chat.stream is unsupported");
4299
+ }
4300
+ };
4301
+
4192
4302
  // src/wechat-client.ts
4193
4303
  var import_encoding = __toESM(require_encoding());
4194
4304
  var WeChatClient = class extends AbstractClient {
@@ -4934,6 +5044,7 @@ function createSimpleMessageMerger() {
4934
5044
  ProjectRoomClientError,
4935
5045
  ProjectRoomsClient,
4936
5046
  ResourcesClient,
5047
+ RuntimeAxiomClient,
4937
5048
  ScheduleExecutionType,
4938
5049
  ScheduledTaskStatus,
4939
5050
  WeChatClient,