@realtimex/sdk 2.0.5 → 2.0.7

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,132 @@
1
+ import {
2
+ AuthenticationError,
3
+ DeveloperApiError,
4
+ NotFoundError,
5
+ ServerError,
6
+ ValidationError
7
+ } from "./chunk-UPXEAZIT.mjs";
8
+
9
+ // src/cli/client.ts
10
+ var CliApiClient = class {
11
+ constructor(baseUrl, apiKey, appId) {
12
+ this.baseUrl = baseUrl.replace(/\/$/, "");
13
+ this.apiKey = apiKey;
14
+ this.appId = appId;
15
+ }
16
+ getHeaders(extra) {
17
+ const headers = {
18
+ "Content-Type": "application/json",
19
+ "Authorization": `Bearer ${this.apiKey}`
20
+ };
21
+ if (this.appId) headers["x-app-id"] = this.appId;
22
+ return { ...headers, ...extra };
23
+ }
24
+ async handleResponse(response) {
25
+ let data;
26
+ try {
27
+ data = await response.json();
28
+ } catch {
29
+ data = {};
30
+ }
31
+ if (response.ok) return data;
32
+ const message = data?.message || data?.error || response.statusText || "Request failed";
33
+ switch (response.status) {
34
+ case 400:
35
+ throw new ValidationError(message);
36
+ case 401:
37
+ case 403:
38
+ throw new AuthenticationError(message);
39
+ case 404:
40
+ throw new NotFoundError(message);
41
+ case 500:
42
+ case 502:
43
+ case 503:
44
+ throw new ServerError(message);
45
+ default:
46
+ throw new DeveloperApiError(response.status, "API_ERROR", message);
47
+ }
48
+ }
49
+ async request(method, path, body) {
50
+ const url = `${this.baseUrl}/cli${path}`;
51
+ const response = await fetch(url, {
52
+ method,
53
+ headers: this.getHeaders(),
54
+ body: body !== void 0 ? JSON.stringify(body) : void 0
55
+ });
56
+ return this.handleResponse(response);
57
+ }
58
+ };
59
+
60
+ // src/cli/namespace.ts
61
+ var CliApiNamespace = class {
62
+ constructor(baseUrl, apiKey, appId) {
63
+ this._client = new CliApiClient(baseUrl, apiKey, appId);
64
+ }
65
+ async prepare() {
66
+ return this._client.request("GET", "/prepare");
67
+ }
68
+ async listWorkspaces() {
69
+ return this._client.request("GET", "/list-workspaces");
70
+ }
71
+ async createWorkspace(body) {
72
+ return this._client.request("POST", "/create-workspace", body);
73
+ }
74
+ async getWorkspace(workspaceSlug) {
75
+ return this._client.request("GET", `/get-workspace/${encodeURIComponent(workspaceSlug)}`);
76
+ }
77
+ async renameWorkspace(workspaceSlug, body) {
78
+ return this._client.request("POST", `/rename-workspace/${encodeURIComponent(workspaceSlug)}`, body);
79
+ }
80
+ async deleteWorkspace(workspaceSlug) {
81
+ return this._client.request("DELETE", `/delete-workspace/${encodeURIComponent(workspaceSlug)}`);
82
+ }
83
+ async setWorkspaceDefaultAgent(workspaceSlug, body) {
84
+ return this._client.request("POST", `/set-workspace-default-agent/${encodeURIComponent(workspaceSlug)}`, body);
85
+ }
86
+ async clearWorkspaceDefaultAgent(workspaceSlug) {
87
+ return this._client.request("DELETE", `/clear-workspace-default-agent/${encodeURIComponent(workspaceSlug)}`);
88
+ }
89
+ async listThreads(workspaceSlug) {
90
+ return this._client.request("GET", `/list-threads/${encodeURIComponent(workspaceSlug)}`);
91
+ }
92
+ async createThread(workspaceSlug, body) {
93
+ return this._client.request("POST", `/create-thread/${encodeURIComponent(workspaceSlug)}`, body);
94
+ }
95
+ async getThread(workspaceSlug, threadSlug) {
96
+ return this._client.request(
97
+ "GET",
98
+ `/get-thread/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`
99
+ );
100
+ }
101
+ async renameThread(workspaceSlug, threadSlug, body) {
102
+ return this._client.request(
103
+ "POST",
104
+ `/rename-thread/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`,
105
+ body
106
+ );
107
+ }
108
+ async deleteThread(workspaceSlug, threadSlug) {
109
+ return this._client.request(
110
+ "DELETE",
111
+ `/delete-thread/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`
112
+ );
113
+ }
114
+ async sendLlmMessage(workspaceSlug, threadSlug, body) {
115
+ return this._client.request(
116
+ "POST",
117
+ `/send-llm-message/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`,
118
+ body
119
+ );
120
+ }
121
+ async listLlmProviders() {
122
+ return this._client.request("GET", "/list-llm-providers");
123
+ }
124
+ async listLlmModels(provider) {
125
+ return this._client.request("GET", `/list-llm-models/${encodeURIComponent(provider)}`);
126
+ }
127
+ };
128
+
129
+ export {
130
+ CliApiClient,
131
+ CliApiNamespace
132
+ };
@@ -0,0 +1,41 @@
1
+ // src/v1/errors.ts
2
+ var DeveloperApiError = class extends Error {
3
+ constructor(status, code, message) {
4
+ super(message);
5
+ this.status = status;
6
+ this.code = code;
7
+ this.name = "DeveloperApiError";
8
+ }
9
+ };
10
+ var AuthenticationError = class extends DeveloperApiError {
11
+ constructor(message = "Invalid or missing API key") {
12
+ super(403, "AUTHENTICATION_ERROR", message);
13
+ this.name = "AuthenticationError";
14
+ }
15
+ };
16
+ var NotFoundError = class extends DeveloperApiError {
17
+ constructor(message = "Resource not found") {
18
+ super(404, "NOT_FOUND", message);
19
+ this.name = "NotFoundError";
20
+ }
21
+ };
22
+ var ValidationError = class extends DeveloperApiError {
23
+ constructor(message) {
24
+ super(400, "VALIDATION_ERROR", message);
25
+ this.name = "ValidationError";
26
+ }
27
+ };
28
+ var ServerError = class extends DeveloperApiError {
29
+ constructor(message = "Internal server error") {
30
+ super(500, "SERVER_ERROR", message);
31
+ this.name = "ServerError";
32
+ }
33
+ };
34
+
35
+ export {
36
+ DeveloperApiError,
37
+ AuthenticationError,
38
+ NotFoundError,
39
+ ValidationError,
40
+ ServerError
41
+ };
@@ -1,36 +1,10 @@
1
- // src/v1/errors.ts
2
- var DeveloperApiError = class extends Error {
3
- constructor(status, code, message) {
4
- super(message);
5
- this.status = status;
6
- this.code = code;
7
- this.name = "DeveloperApiError";
8
- }
9
- };
10
- var AuthenticationError = class extends DeveloperApiError {
11
- constructor(message = "Invalid or missing API key") {
12
- super(403, "AUTHENTICATION_ERROR", message);
13
- this.name = "AuthenticationError";
14
- }
15
- };
16
- var NotFoundError = class extends DeveloperApiError {
17
- constructor(message = "Resource not found") {
18
- super(404, "NOT_FOUND", message);
19
- this.name = "NotFoundError";
20
- }
21
- };
22
- var ValidationError = class extends DeveloperApiError {
23
- constructor(message) {
24
- super(400, "VALIDATION_ERROR", message);
25
- this.name = "ValidationError";
26
- }
27
- };
28
- var ServerError = class extends DeveloperApiError {
29
- constructor(message = "Internal server error") {
30
- super(500, "SERVER_ERROR", message);
31
- this.name = "ServerError";
32
- }
33
- };
1
+ import {
2
+ AuthenticationError,
3
+ DeveloperApiError,
4
+ NotFoundError,
5
+ ServerError,
6
+ ValidationError
7
+ } from "./chunk-UPXEAZIT.mjs";
34
8
 
35
9
  // src/v1/client.ts
36
10
  var DeveloperApiClient = class {
@@ -585,11 +559,6 @@ var V1ApiNamespace = class {
585
559
  };
586
560
 
587
561
  export {
588
- DeveloperApiError,
589
- AuthenticationError,
590
- NotFoundError,
591
- ValidationError,
592
- ServerError,
593
562
  DeveloperApiClient,
594
563
  V1ChatModule,
595
564
  V1WorkspaceModule,
@@ -0,0 +1,54 @@
1
+ declare class CliApiClient {
2
+ private readonly baseUrl;
3
+ private readonly apiKey;
4
+ private readonly appId?;
5
+ constructor(baseUrl: string, apiKey: string, appId?: string);
6
+ private getHeaders;
7
+ private handleResponse;
8
+ request<T = unknown>(method: string, path: string, body?: unknown): Promise<T>;
9
+ }
10
+
11
+ interface NameRequest {
12
+ name: string;
13
+ }
14
+ interface CreateThreadRequest {
15
+ name?: string;
16
+ }
17
+ interface WorkspaceDefaultAgentRequest {
18
+ canonical: string;
19
+ providerId?: string;
20
+ modelId?: string;
21
+ }
22
+ interface SendLlmMessageRequest {
23
+ message: string;
24
+ chatProvider: string;
25
+ chatModel: string;
26
+ attachments?: Record<string, unknown>[];
27
+ webSearchEnabled?: boolean;
28
+ thinkingEffort?: string;
29
+ chatTuningConfig?: Record<string, unknown>;
30
+ [key: string]: unknown;
31
+ }
32
+ declare class CliApiNamespace {
33
+ /** @internal Shared HTTP client used by all CLI API methods */
34
+ readonly _client: CliApiClient;
35
+ constructor(baseUrl: string, apiKey: string, appId?: string);
36
+ prepare(): Promise<unknown>;
37
+ listWorkspaces(): Promise<unknown>;
38
+ createWorkspace(body: NameRequest): Promise<unknown>;
39
+ getWorkspace(workspaceSlug: string): Promise<unknown>;
40
+ renameWorkspace(workspaceSlug: string, body: NameRequest): Promise<unknown>;
41
+ deleteWorkspace(workspaceSlug: string): Promise<unknown>;
42
+ setWorkspaceDefaultAgent(workspaceSlug: string, body: WorkspaceDefaultAgentRequest): Promise<unknown>;
43
+ clearWorkspaceDefaultAgent(workspaceSlug: string): Promise<unknown>;
44
+ listThreads(workspaceSlug: string): Promise<unknown>;
45
+ createThread(workspaceSlug: string, body?: CreateThreadRequest): Promise<unknown>;
46
+ getThread(workspaceSlug: string, threadSlug: string): Promise<unknown>;
47
+ renameThread(workspaceSlug: string, threadSlug: string, body: NameRequest): Promise<unknown>;
48
+ deleteThread(workspaceSlug: string, threadSlug: string): Promise<unknown>;
49
+ sendLlmMessage(workspaceSlug: string, threadSlug: string, body: SendLlmMessageRequest): Promise<unknown>;
50
+ listLlmProviders(): Promise<unknown>;
51
+ listLlmModels(provider: string): Promise<unknown>;
52
+ }
53
+
54
+ export { CliApiClient, CliApiNamespace, type CreateThreadRequest, type NameRequest, type SendLlmMessageRequest, type WorkspaceDefaultAgentRequest };
@@ -0,0 +1,54 @@
1
+ declare class CliApiClient {
2
+ private readonly baseUrl;
3
+ private readonly apiKey;
4
+ private readonly appId?;
5
+ constructor(baseUrl: string, apiKey: string, appId?: string);
6
+ private getHeaders;
7
+ private handleResponse;
8
+ request<T = unknown>(method: string, path: string, body?: unknown): Promise<T>;
9
+ }
10
+
11
+ interface NameRequest {
12
+ name: string;
13
+ }
14
+ interface CreateThreadRequest {
15
+ name?: string;
16
+ }
17
+ interface WorkspaceDefaultAgentRequest {
18
+ canonical: string;
19
+ providerId?: string;
20
+ modelId?: string;
21
+ }
22
+ interface SendLlmMessageRequest {
23
+ message: string;
24
+ chatProvider: string;
25
+ chatModel: string;
26
+ attachments?: Record<string, unknown>[];
27
+ webSearchEnabled?: boolean;
28
+ thinkingEffort?: string;
29
+ chatTuningConfig?: Record<string, unknown>;
30
+ [key: string]: unknown;
31
+ }
32
+ declare class CliApiNamespace {
33
+ /** @internal Shared HTTP client used by all CLI API methods */
34
+ readonly _client: CliApiClient;
35
+ constructor(baseUrl: string, apiKey: string, appId?: string);
36
+ prepare(): Promise<unknown>;
37
+ listWorkspaces(): Promise<unknown>;
38
+ createWorkspace(body: NameRequest): Promise<unknown>;
39
+ getWorkspace(workspaceSlug: string): Promise<unknown>;
40
+ renameWorkspace(workspaceSlug: string, body: NameRequest): Promise<unknown>;
41
+ deleteWorkspace(workspaceSlug: string): Promise<unknown>;
42
+ setWorkspaceDefaultAgent(workspaceSlug: string, body: WorkspaceDefaultAgentRequest): Promise<unknown>;
43
+ clearWorkspaceDefaultAgent(workspaceSlug: string): Promise<unknown>;
44
+ listThreads(workspaceSlug: string): Promise<unknown>;
45
+ createThread(workspaceSlug: string, body?: CreateThreadRequest): Promise<unknown>;
46
+ getThread(workspaceSlug: string, threadSlug: string): Promise<unknown>;
47
+ renameThread(workspaceSlug: string, threadSlug: string, body: NameRequest): Promise<unknown>;
48
+ deleteThread(workspaceSlug: string, threadSlug: string): Promise<unknown>;
49
+ sendLlmMessage(workspaceSlug: string, threadSlug: string, body: SendLlmMessageRequest): Promise<unknown>;
50
+ listLlmProviders(): Promise<unknown>;
51
+ listLlmModels(provider: string): Promise<unknown>;
52
+ }
53
+
54
+ export { CliApiClient, CliApiNamespace, type CreateThreadRequest, type NameRequest, type SendLlmMessageRequest, type WorkspaceDefaultAgentRequest };
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/cli/index.ts
21
+ var cli_exports = {};
22
+ __export(cli_exports, {
23
+ CliApiClient: () => CliApiClient,
24
+ CliApiNamespace: () => CliApiNamespace
25
+ });
26
+ module.exports = __toCommonJS(cli_exports);
27
+
28
+ // src/v1/errors.ts
29
+ var DeveloperApiError = class extends Error {
30
+ constructor(status, code, message) {
31
+ super(message);
32
+ this.status = status;
33
+ this.code = code;
34
+ this.name = "DeveloperApiError";
35
+ }
36
+ };
37
+ var AuthenticationError = class extends DeveloperApiError {
38
+ constructor(message = "Invalid or missing API key") {
39
+ super(403, "AUTHENTICATION_ERROR", message);
40
+ this.name = "AuthenticationError";
41
+ }
42
+ };
43
+ var NotFoundError = class extends DeveloperApiError {
44
+ constructor(message = "Resource not found") {
45
+ super(404, "NOT_FOUND", message);
46
+ this.name = "NotFoundError";
47
+ }
48
+ };
49
+ var ValidationError = class extends DeveloperApiError {
50
+ constructor(message) {
51
+ super(400, "VALIDATION_ERROR", message);
52
+ this.name = "ValidationError";
53
+ }
54
+ };
55
+ var ServerError = class extends DeveloperApiError {
56
+ constructor(message = "Internal server error") {
57
+ super(500, "SERVER_ERROR", message);
58
+ this.name = "ServerError";
59
+ }
60
+ };
61
+
62
+ // src/cli/client.ts
63
+ var CliApiClient = class {
64
+ constructor(baseUrl, apiKey, appId) {
65
+ this.baseUrl = baseUrl.replace(/\/$/, "");
66
+ this.apiKey = apiKey;
67
+ this.appId = appId;
68
+ }
69
+ getHeaders(extra) {
70
+ const headers = {
71
+ "Content-Type": "application/json",
72
+ "Authorization": `Bearer ${this.apiKey}`
73
+ };
74
+ if (this.appId) headers["x-app-id"] = this.appId;
75
+ return { ...headers, ...extra };
76
+ }
77
+ async handleResponse(response) {
78
+ let data;
79
+ try {
80
+ data = await response.json();
81
+ } catch {
82
+ data = {};
83
+ }
84
+ if (response.ok) return data;
85
+ const message = data?.message || data?.error || response.statusText || "Request failed";
86
+ switch (response.status) {
87
+ case 400:
88
+ throw new ValidationError(message);
89
+ case 401:
90
+ case 403:
91
+ throw new AuthenticationError(message);
92
+ case 404:
93
+ throw new NotFoundError(message);
94
+ case 500:
95
+ case 502:
96
+ case 503:
97
+ throw new ServerError(message);
98
+ default:
99
+ throw new DeveloperApiError(response.status, "API_ERROR", message);
100
+ }
101
+ }
102
+ async request(method, path, body) {
103
+ const url = `${this.baseUrl}/cli${path}`;
104
+ const response = await fetch(url, {
105
+ method,
106
+ headers: this.getHeaders(),
107
+ body: body !== void 0 ? JSON.stringify(body) : void 0
108
+ });
109
+ return this.handleResponse(response);
110
+ }
111
+ };
112
+
113
+ // src/cli/namespace.ts
114
+ var CliApiNamespace = class {
115
+ constructor(baseUrl, apiKey, appId) {
116
+ this._client = new CliApiClient(baseUrl, apiKey, appId);
117
+ }
118
+ async prepare() {
119
+ return this._client.request("GET", "/prepare");
120
+ }
121
+ async listWorkspaces() {
122
+ return this._client.request("GET", "/list-workspaces");
123
+ }
124
+ async createWorkspace(body) {
125
+ return this._client.request("POST", "/create-workspace", body);
126
+ }
127
+ async getWorkspace(workspaceSlug) {
128
+ return this._client.request("GET", `/get-workspace/${encodeURIComponent(workspaceSlug)}`);
129
+ }
130
+ async renameWorkspace(workspaceSlug, body) {
131
+ return this._client.request("POST", `/rename-workspace/${encodeURIComponent(workspaceSlug)}`, body);
132
+ }
133
+ async deleteWorkspace(workspaceSlug) {
134
+ return this._client.request("DELETE", `/delete-workspace/${encodeURIComponent(workspaceSlug)}`);
135
+ }
136
+ async setWorkspaceDefaultAgent(workspaceSlug, body) {
137
+ return this._client.request("POST", `/set-workspace-default-agent/${encodeURIComponent(workspaceSlug)}`, body);
138
+ }
139
+ async clearWorkspaceDefaultAgent(workspaceSlug) {
140
+ return this._client.request("DELETE", `/clear-workspace-default-agent/${encodeURIComponent(workspaceSlug)}`);
141
+ }
142
+ async listThreads(workspaceSlug) {
143
+ return this._client.request("GET", `/list-threads/${encodeURIComponent(workspaceSlug)}`);
144
+ }
145
+ async createThread(workspaceSlug, body) {
146
+ return this._client.request("POST", `/create-thread/${encodeURIComponent(workspaceSlug)}`, body);
147
+ }
148
+ async getThread(workspaceSlug, threadSlug) {
149
+ return this._client.request(
150
+ "GET",
151
+ `/get-thread/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`
152
+ );
153
+ }
154
+ async renameThread(workspaceSlug, threadSlug, body) {
155
+ return this._client.request(
156
+ "POST",
157
+ `/rename-thread/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`,
158
+ body
159
+ );
160
+ }
161
+ async deleteThread(workspaceSlug, threadSlug) {
162
+ return this._client.request(
163
+ "DELETE",
164
+ `/delete-thread/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`
165
+ );
166
+ }
167
+ async sendLlmMessage(workspaceSlug, threadSlug, body) {
168
+ return this._client.request(
169
+ "POST",
170
+ `/send-llm-message/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`,
171
+ body
172
+ );
173
+ }
174
+ async listLlmProviders() {
175
+ return this._client.request("GET", "/list-llm-providers");
176
+ }
177
+ async listLlmModels(provider) {
178
+ return this._client.request("GET", `/list-llm-models/${encodeURIComponent(provider)}`);
179
+ }
180
+ };
181
+ // Annotate the CommonJS export names for ESM import in node:
182
+ 0 && (module.exports = {
183
+ CliApiClient,
184
+ CliApiNamespace
185
+ });
@@ -0,0 +1,9 @@
1
+ import {
2
+ CliApiClient,
3
+ CliApiNamespace
4
+ } from "../chunk-SFY6E7TY.mjs";
5
+ import "../chunk-UPXEAZIT.mjs";
6
+ export {
7
+ CliApiClient,
8
+ CliApiNamespace
9
+ };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { V as V1ApiNamespace } from './errors-DwEt8WYf.mjs';
2
2
  export { A as AuthenticationError, D as DeveloperApiClient, a as DeveloperApiError, N as NotFoundError, S as ServerError, b as ValidationError } from './errors-DwEt8WYf.mjs';
3
+ import { CliApiNamespace } from './cli/index.mjs';
4
+ export { CliApiClient } from './cli/index.mjs';
3
5
 
4
6
  interface SDKConfig {
5
7
  realtimex?: {
@@ -21,9 +23,10 @@ declare class RealtimeXSDK {
21
23
  readonly apiKey: string | undefined;
22
24
  readonly realtimexUrl: string;
23
25
  readonly v1: V1ApiNamespace;
26
+ readonly cli: CliApiNamespace;
24
27
  private static DEFAULT_REALTIMEX_URL;
25
28
  constructor(config?: SDKConfig);
26
29
  private getEnvVar;
27
30
  }
28
31
 
29
- export { RealtimeXSDK, type SDKConfig, V1ApiNamespace };
32
+ export { CliApiNamespace, RealtimeXSDK, type SDKConfig, V1ApiNamespace };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { V as V1ApiNamespace } from './errors-DwEt8WYf.js';
2
2
  export { A as AuthenticationError, D as DeveloperApiClient, a as DeveloperApiError, N as NotFoundError, S as ServerError, b as ValidationError } from './errors-DwEt8WYf.js';
3
+ import { CliApiNamespace } from './cli/index.js';
4
+ export { CliApiClient } from './cli/index.js';
3
5
 
4
6
  interface SDKConfig {
5
7
  realtimex?: {
@@ -21,9 +23,10 @@ declare class RealtimeXSDK {
21
23
  readonly apiKey: string | undefined;
22
24
  readonly realtimexUrl: string;
23
25
  readonly v1: V1ApiNamespace;
26
+ readonly cli: CliApiNamespace;
24
27
  private static DEFAULT_REALTIMEX_URL;
25
28
  constructor(config?: SDKConfig);
26
29
  private getEnvVar;
27
30
  }
28
31
 
29
- export { RealtimeXSDK, type SDKConfig, V1ApiNamespace };
32
+ export { CliApiNamespace, RealtimeXSDK, type SDKConfig, V1ApiNamespace };
package/dist/index.js CHANGED
@@ -21,6 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AuthenticationError: () => AuthenticationError,
24
+ CliApiClient: () => CliApiClient,
25
+ CliApiNamespace: () => CliApiNamespace,
24
26
  DeveloperApiClient: () => DeveloperApiClient,
25
27
  DeveloperApiError: () => DeveloperApiError,
26
28
  NotFoundError: () => NotFoundError,
@@ -617,6 +619,126 @@ var V1ApiNamespace = class {
617
619
  }
618
620
  };
619
621
 
622
+ // src/cli/client.ts
623
+ var CliApiClient = class {
624
+ constructor(baseUrl, apiKey, appId) {
625
+ this.baseUrl = baseUrl.replace(/\/$/, "");
626
+ this.apiKey = apiKey;
627
+ this.appId = appId;
628
+ }
629
+ getHeaders(extra) {
630
+ const headers = {
631
+ "Content-Type": "application/json",
632
+ "Authorization": `Bearer ${this.apiKey}`
633
+ };
634
+ if (this.appId) headers["x-app-id"] = this.appId;
635
+ return { ...headers, ...extra };
636
+ }
637
+ async handleResponse(response) {
638
+ let data;
639
+ try {
640
+ data = await response.json();
641
+ } catch {
642
+ data = {};
643
+ }
644
+ if (response.ok) return data;
645
+ const message = data?.message || data?.error || response.statusText || "Request failed";
646
+ switch (response.status) {
647
+ case 400:
648
+ throw new ValidationError(message);
649
+ case 401:
650
+ case 403:
651
+ throw new AuthenticationError(message);
652
+ case 404:
653
+ throw new NotFoundError(message);
654
+ case 500:
655
+ case 502:
656
+ case 503:
657
+ throw new ServerError(message);
658
+ default:
659
+ throw new DeveloperApiError(response.status, "API_ERROR", message);
660
+ }
661
+ }
662
+ async request(method, path, body) {
663
+ const url = `${this.baseUrl}/cli${path}`;
664
+ const response = await fetch(url, {
665
+ method,
666
+ headers: this.getHeaders(),
667
+ body: body !== void 0 ? JSON.stringify(body) : void 0
668
+ });
669
+ return this.handleResponse(response);
670
+ }
671
+ };
672
+
673
+ // src/cli/namespace.ts
674
+ var CliApiNamespace = class {
675
+ constructor(baseUrl, apiKey, appId) {
676
+ this._client = new CliApiClient(baseUrl, apiKey, appId);
677
+ }
678
+ async prepare() {
679
+ return this._client.request("GET", "/prepare");
680
+ }
681
+ async listWorkspaces() {
682
+ return this._client.request("GET", "/list-workspaces");
683
+ }
684
+ async createWorkspace(body) {
685
+ return this._client.request("POST", "/create-workspace", body);
686
+ }
687
+ async getWorkspace(workspaceSlug) {
688
+ return this._client.request("GET", `/get-workspace/${encodeURIComponent(workspaceSlug)}`);
689
+ }
690
+ async renameWorkspace(workspaceSlug, body) {
691
+ return this._client.request("POST", `/rename-workspace/${encodeURIComponent(workspaceSlug)}`, body);
692
+ }
693
+ async deleteWorkspace(workspaceSlug) {
694
+ return this._client.request("DELETE", `/delete-workspace/${encodeURIComponent(workspaceSlug)}`);
695
+ }
696
+ async setWorkspaceDefaultAgent(workspaceSlug, body) {
697
+ return this._client.request("POST", `/set-workspace-default-agent/${encodeURIComponent(workspaceSlug)}`, body);
698
+ }
699
+ async clearWorkspaceDefaultAgent(workspaceSlug) {
700
+ return this._client.request("DELETE", `/clear-workspace-default-agent/${encodeURIComponent(workspaceSlug)}`);
701
+ }
702
+ async listThreads(workspaceSlug) {
703
+ return this._client.request("GET", `/list-threads/${encodeURIComponent(workspaceSlug)}`);
704
+ }
705
+ async createThread(workspaceSlug, body) {
706
+ return this._client.request("POST", `/create-thread/${encodeURIComponent(workspaceSlug)}`, body);
707
+ }
708
+ async getThread(workspaceSlug, threadSlug) {
709
+ return this._client.request(
710
+ "GET",
711
+ `/get-thread/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`
712
+ );
713
+ }
714
+ async renameThread(workspaceSlug, threadSlug, body) {
715
+ return this._client.request(
716
+ "POST",
717
+ `/rename-thread/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`,
718
+ body
719
+ );
720
+ }
721
+ async deleteThread(workspaceSlug, threadSlug) {
722
+ return this._client.request(
723
+ "DELETE",
724
+ `/delete-thread/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`
725
+ );
726
+ }
727
+ async sendLlmMessage(workspaceSlug, threadSlug, body) {
728
+ return this._client.request(
729
+ "POST",
730
+ `/send-llm-message/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`,
731
+ body
732
+ );
733
+ }
734
+ async listLlmProviders() {
735
+ return this._client.request("GET", "/list-llm-providers");
736
+ }
737
+ async listLlmModels(provider) {
738
+ return this._client.request("GET", `/list-llm-models/${encodeURIComponent(provider)}`);
739
+ }
740
+ };
741
+
620
742
  // src/index.ts
621
743
  var _RealtimeXSDK = class _RealtimeXSDK {
622
744
  constructor(config = {}) {
@@ -630,6 +752,11 @@ var _RealtimeXSDK = class _RealtimeXSDK {
630
752
  this.apiKey ?? "",
631
753
  this.appId || void 0
632
754
  );
755
+ this.cli = new CliApiNamespace(
756
+ this.realtimexUrl,
757
+ this.apiKey ?? "",
758
+ this.appId || void 0
759
+ );
633
760
  }
634
761
  getEnvVar(name) {
635
762
  if (typeof process !== "undefined" && process.env) {
@@ -646,6 +773,8 @@ var RealtimeXSDK = _RealtimeXSDK;
646
773
  // Annotate the CommonJS export names for ESM import in node:
647
774
  0 && (module.exports = {
648
775
  AuthenticationError,
776
+ CliApiClient,
777
+ CliApiNamespace,
649
778
  DeveloperApiClient,
650
779
  DeveloperApiError,
651
780
  NotFoundError,
package/dist/index.mjs CHANGED
@@ -1,12 +1,18 @@
1
1
  import {
2
- AuthenticationError,
2
+ CliApiClient,
3
+ CliApiNamespace
4
+ } from "./chunk-SFY6E7TY.mjs";
5
+ import {
3
6
  DeveloperApiClient,
7
+ V1ApiNamespace
8
+ } from "./chunk-XKQRTTIC.mjs";
9
+ import {
10
+ AuthenticationError,
4
11
  DeveloperApiError,
5
12
  NotFoundError,
6
13
  ServerError,
7
- V1ApiNamespace,
8
14
  ValidationError
9
- } from "./chunk-DZUAP6FW.mjs";
15
+ } from "./chunk-UPXEAZIT.mjs";
10
16
 
11
17
  // src/index.ts
12
18
  var _RealtimeXSDK = class _RealtimeXSDK {
@@ -21,6 +27,11 @@ var _RealtimeXSDK = class _RealtimeXSDK {
21
27
  this.apiKey ?? "",
22
28
  this.appId || void 0
23
29
  );
30
+ this.cli = new CliApiNamespace(
31
+ this.realtimexUrl,
32
+ this.apiKey ?? "",
33
+ this.appId || void 0
34
+ );
24
35
  }
25
36
  getEnvVar(name) {
26
37
  if (typeof process !== "undefined" && process.env) {
@@ -36,6 +47,8 @@ _RealtimeXSDK.DEFAULT_REALTIMEX_URL = "http://localhost:3001";
36
47
  var RealtimeXSDK = _RealtimeXSDK;
37
48
  export {
38
49
  AuthenticationError,
50
+ CliApiClient,
51
+ CliApiNamespace,
39
52
  DeveloperApiClient,
40
53
  DeveloperApiError,
41
54
  NotFoundError,
package/dist/v1/index.mjs CHANGED
@@ -1,15 +1,17 @@
1
1
  import {
2
- AuthenticationError,
3
2
  DeveloperApiClient,
4
- DeveloperApiError,
5
- NotFoundError,
6
- ServerError,
7
3
  V1ApiNamespace,
8
4
  V1ChatModule,
9
5
  V1ThreadModule,
10
- V1WorkspaceModule,
6
+ V1WorkspaceModule
7
+ } from "../chunk-XKQRTTIC.mjs";
8
+ import {
9
+ AuthenticationError,
10
+ DeveloperApiError,
11
+ NotFoundError,
12
+ ServerError,
11
13
  ValidationError
12
- } from "../chunk-DZUAP6FW.mjs";
14
+ } from "../chunk-UPXEAZIT.mjs";
13
15
 
14
16
  // src/v1/overrides/v1WorkspaceStreaming.ts
15
17
  async function* streamWorkspaceChat(client, slug, body) {
package/package.json CHANGED
@@ -1,25 +1,30 @@
1
1
  {
2
2
  "name": "@realtimex/sdk",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "SDK for building Local Apps that integrate with RealtimeX",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
+ "types": "./dist/index.d.ts",
10
11
  "import": "./dist/index.mjs",
11
- "require": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
12
+ "require": "./dist/index.js"
13
13
  },
14
14
  "./v1": {
15
+ "types": "./dist/v1/index.d.ts",
15
16
  "import": "./dist/v1/index.mjs",
16
- "require": "./dist/v1/index.js",
17
- "types": "./dist/v1/index.d.ts"
17
+ "require": "./dist/v1/index.js"
18
+ },
19
+ "./cli": {
20
+ "types": "./dist/cli/index.d.ts",
21
+ "import": "./dist/cli/index.mjs",
22
+ "require": "./dist/cli/index.js"
18
23
  }
19
24
  },
20
25
  "scripts": {
21
- "build": "node ../scripts/generate-v1-sdk.mjs --force && tsup src/index.ts src/v1/index.ts --format cjs,esm --dts --clean",
22
- "dev": "tsup src/index.ts src/v1/index.ts --format cjs,esm --dts --watch",
26
+ "build": "node ../scripts/generate-v1-sdk.mjs --force && tsup src/index.ts src/v1/index.ts src/cli/index.ts --format cjs,esm --dts --clean",
27
+ "dev": "tsup src/index.ts src/v1/index.ts src/cli/index.ts --format cjs,esm --dts --watch",
23
28
  "test": "vitest run --passWithNoTests",
24
29
  "sdk:generate": "node ../scripts/generate-v1-sdk.mjs",
25
30
  "sdk:generate:force": "node ../scripts/generate-v1-sdk.mjs --force",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: realtimex-moderator-sdk
3
- description: "Use the RealTimeX API through the generated CLI for workspace, thread, and chat operations."
3
+ description: "Use the RealTimeX API through the generated CLI for workspace, thread, channel (Telegram, Zalo, Discord) and chat operations."
4
4
  author: ""
5
5
  license: "Apache-2.0"
6
6
  argument-hint: "<command> [args] | install cli"
@@ -20,22 +20,36 @@ This skill drives the `realtimex-pp-cli` binary. Verify the CLI is installed and
20
20
 
21
21
  1. Install or reinstall the pinned version via npm:
22
22
  ```bash
23
- npm install -g @realtimex/pp-cli@2.0.5
23
+ npm install -g @realtimex/pp-cli@2.0.7
24
24
  ```
25
25
  2. Verify the exact version:
26
26
  ```bash
27
27
  realtimex-pp-cli --version
28
28
  ```
29
- The output must be `realtimex-pp-cli 2.0.5`.
29
+ The output must be `realtimex-pp-cli 2.0.7`.
30
30
 
31
- If `--version` reports "command not found" after install, the npm global bin directory is not on `$PATH`. If it reports any version other than `2.0.5`, reinstall with the pinned npm command above. Do not proceed with skill commands until exact-version verification succeeds.
31
+ If `--version` reports "command not found" after install, the npm global bin directory is not on `$PATH`. If it reports any version other than `2.0.7`, reinstall with the pinned npm command above. Do not proceed with skill commands until exact-version verification succeeds.
32
+
33
+ * Always run first:
34
+
35
+ ```bash
36
+ realtimex-pp-cli prepare --workspace-slug "$RTX_WORKSPACE_SLUG" --thread-slug "$RTX_THREAD_SLUG" --agent
37
+ ```
32
38
 
33
39
  ## Command Reference
34
40
 
41
+ **approve-channel-pairing-code** — Manage approve channel pairing code
42
+
43
+ - `realtimex-pp-cli approve-channel-pairing-code <code>` — Approve one pending channel pairing code by visible 6-digit code or database id.
44
+
35
45
  **clear-workspace-default-agent** — Manage clear workspace default agent
36
46
 
37
47
  - `realtimex-pp-cli clear-workspace-default-agent <workspaceSlug>` — Clear the default CLI agent from a workspace.
38
48
 
49
+ **create-channel** — Manage create channel
50
+
51
+ - `realtimex-pp-cli create-channel <workspaceSlug>` — Create a chat channel in one exact workspace. Defaults to Telegram when plugin_type, channelType, and type are omitted.
52
+
39
53
  **create-thread** — Manage create thread
40
54
 
41
55
  - `realtimex-pp-cli create-thread <workspaceSlug>` — Create a thread in one workspace. The name is optional but recommended.
@@ -44,6 +58,10 @@ If `--version` reports "command not found" after install, the npm global bin dir
44
58
 
45
59
  - `realtimex-pp-cli create-workspace` — Create a workspace. Requires a human-readable workspace name.
46
60
 
61
+ **delete-channel** — Manage delete channel
62
+
63
+ - `realtimex-pp-cli delete-channel <channelId>` — Delete one chat channel by exact channel id.
64
+
47
65
  **delete-thread** — Manage delete thread
48
66
 
49
67
  - `realtimex-pp-cli delete-thread <workspaceSlug> <threadSlug>` — Delete one thread by exact workspace slug and exact thread slug.
@@ -60,13 +78,17 @@ If `--version` reports "command not found" after install, the npm global bin dir
60
78
 
61
79
  - `realtimex-pp-cli get-workspace <workspaceSlug>` — Get one workspace by exact workspace slug.
62
80
 
81
+ **list-channels** — Manage list channels
82
+
83
+ - `realtimex-pp-cli list-channels` — List configured chat channels. Use returned channel ids with update-channel.
84
+
63
85
  **list-llm-models** — Manage list llm models
64
86
 
65
- - `realtimex-pp-cli list-llm-models <provider>` — List models for one provider id. Use an exact model id from this response with send-llm-message.
87
+ - `realtimex-pp-cli list-llm-models <provider>` — List models for one provider id.
66
88
 
67
89
  **list-llm-providers** — Manage list llm providers
68
90
 
69
- - `realtimex-pp-cli list-llm-providers` — List supported LLM providers. Use provider ids from this response with list-llm-models and send-llm-message.
91
+ - `realtimex-pp-cli list-llm-providers` — List supported LLM providers. Use provider ids from this response when configuring workspace or thread LLM settings.
70
92
 
71
93
  **list-threads** — Manage list threads
72
94
 
@@ -78,7 +100,7 @@ If `--version` reports "command not found" after install, the npm global bin dir
78
100
 
79
101
  **prepare** — Manage prepare
80
102
 
81
- - `realtimex-pp-cli prepare` — Return compact workspace, thread, LLM provider, model, and CLI agent context for agents before choosing arguments.
103
+ - `realtimex-pp-cli prepare` — Return compact workspace, thread, current workspace/thread from explicit workspaceSlug and threadSlug query parameters
82
104
 
83
105
  **rename-thread** — Manage rename thread
84
106
 
@@ -88,14 +110,26 @@ If `--version` reports "command not found" after install, the npm global bin dir
88
110
 
89
111
  - `realtimex-pp-cli rename-workspace <workspaceSlug>` — Rename one workspace by exact workspace slug. Only the name is changed.
90
112
 
91
- **send-llm-message** — Manage send llm message
113
+ **send-message** — Manage send message
92
114
 
93
- - `realtimex-pp-cli send-llm-message <workspaceSlug> <threadSlug>` — Send one non-streaming LLM message to an exact thread.
115
+ - `realtimex-pp-cli send-message <workspaceSlug> <threadSlug>` — Send one message to an exact thread using the same routing as channel replies.
94
116
 
95
117
  **set-workspace-default-agent** — Manage set workspace default agent
96
118
 
97
119
  - `realtimex-pp-cli set-workspace-default-agent <workspaceSlug>` — Set the default CLI agent for a workspace.
98
120
 
121
+ **start-channel** — Manage start channel
122
+
123
+ - `realtimex-pp-cli start-channel <channelId>` — Start one chat channel by exact channel id.
124
+
125
+ **stop-channel** — Manage stop channel
126
+
127
+ - `realtimex-pp-cli stop-channel <channelId>` — Stop one chat channel by exact channel id.
128
+
129
+ **update-channel** — Manage update channel
130
+
131
+ - `realtimex-pp-cli update-channel <channelId>` — Update one chat channel by exact channel id. Only channel writable fields are changed.
132
+
99
133
 
100
134
  ### Finding the right command
101
135
 
@@ -114,7 +148,7 @@ Run `realtimex-pp-cli auth setup` to print the URL and steps for getting a key (
114
148
  export REALTIMEX_APP_ID_AUTH="<your-key>"
115
149
  ```
116
150
 
117
- Or persist it in `~/.config/realtimex-developer-pp-cli/config.toml`.
151
+ Or persist it in `~/.config/realtimex-cli-pp-cli/config.toml`.
118
152
 
119
153
  Run `realtimex-pp-cli doctor` to verify setup.
120
154
 
@@ -126,7 +160,7 @@ Add `--agent` to any command. Expands to: `--json --compact --no-input --no-colo
126
160
  - **Filterable** — `--select` keeps a subset of fields. Dotted paths descend into nested structures; arrays traverse element-wise. Critical for keeping context small on verbose APIs:
127
161
 
128
162
  ```bash
129
- realtimex-pp-cli clear-workspace-default-agent mock-value --agent --select id,name,status
163
+ realtimex-pp-cli approve-channel-pairing-code mock-value --agent --select id,name,status
130
164
  ```
131
165
  - **Previewable** — `--dry-run` shows the request without sending
132
166
  - **Offline-friendly** — sync/search commands can use the local SQLite store when available
@@ -178,7 +212,7 @@ A profile is a saved set of flag values, reused across invocations. Use it when
178
212
 
179
213
  ```
180
214
  realtimex-pp-cli profile save briefing --json
181
- realtimex-pp-cli --profile briefing clear-workspace-default-agent mock-value
215
+ realtimex-pp-cli --profile briefing approve-channel-pairing-code mock-value
182
216
  realtimex-pp-cli profile list --json
183
217
  realtimex-pp-cli profile show briefing
184
218
  realtimex-pp-cli profile delete briefing --yes
@@ -222,9 +256,9 @@ Verify: `claude mcp list`
222
256
  ```bash
223
257
  realtimex-pp-cli --version
224
258
  ```
225
- If the command is missing or the output is not exactly `realtimex-pp-cli 2.0.5`, reinstall the pinned version:
259
+ If the command is missing or the output is not exactly `realtimex-pp-cli 2.0.7`, reinstall the pinned version:
226
260
  ```bash
227
- npm install -g @realtimex/pp-cli@2.0.5
261
+ npm install -g @realtimex/pp-cli@2.0.7
228
262
  ```
229
263
  Then run `realtimex-pp-cli --version` again and proceed only after exact-version verification succeeds.
230
264
  2. Match the user query to the best command from the Unique Capabilities and Command Reference above.
@@ -245,7 +279,7 @@ This skill intentionally exposes a small action-first command set. Prefer these
245
279
  * Always run first:
246
280
 
247
281
  ```bash
248
- realtimex-pp-cli prepare --agent
282
+ realtimex-pp-cli prepare --workspace-slug "$RTX_WORKSPACE_SLUG" --thread-slug "$RTX_THREAD_SLUG" --agent
249
283
  ```
250
284
 
251
285
  * Use exact workspace slugs, thread slugs, provider ids, model ids, agent `canonical`, and agent `modelId` values from `prepare`.
@@ -257,22 +291,14 @@ This skill intentionally exposes a small action-first command set. Prefer these
257
291
  * When the user explicitly uses contextual references such as "current workspace", "this thread", "the thread just created", "that workspace", or similar references, resolve them from the available conversation context only when the reference is unambiguous.
258
292
  * If multiple plausible matches exist, ask the user to choose.
259
293
 
260
- For `send-llm-message`:
294
+ For `send-message`:
261
295
 
262
- * Require all four values to be explicitly named or explicitly referenced in the current request:
296
+ * Require these values to be explicitly named or explicitly referenced in the current request:
263
297
  * workspace
264
298
  * thread
265
- * LLM provider
266
- * LLM model
267
- * If any of those four values are missing or ambiguous, ask for the missing values before running the command.
268
- * Use provider/model only from:
269
- * `prepare.models`
270
- * `list-llm-providers`
271
- * `list-llm-models`
272
- * Never use `prepare.agents[].models` for `send-llm-message`.
273
- * Prefer provider `realtimexai` unless the user explicitly asks for local `nodellama`.
274
- * Only choose a model id that exists in the selected provider's LLM model list.
275
- * If the requested model is unavailable, ask which available model to use instead.
299
+ * message
300
+ * If any of those values are missing or ambiguous, ask for the missing values before running the command.
301
+ * Do not provide LLM provider/model arguments to `send-message`; the server routes the message based on the thread/workspace configuration.
276
302
 
277
303
  For workspace default-agent setup:
278
304