@realtimex/sdk 1.0.7 → 1.0.8
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/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +21 -6
- package/dist/index.mjs +21 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -137,7 +137,9 @@ declare class WebhookModule {
|
|
|
137
137
|
|
|
138
138
|
declare class ApiModule {
|
|
139
139
|
private realtimexUrl;
|
|
140
|
-
|
|
140
|
+
private appId;
|
|
141
|
+
constructor(realtimexUrl: string, appId: string);
|
|
142
|
+
private getHeaders;
|
|
141
143
|
getAgents(): Promise<Agent[]>;
|
|
142
144
|
getWorkspaces(): Promise<Workspace[]>;
|
|
143
145
|
getThreads(workspaceSlug: string): Promise<Thread[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -137,7 +137,9 @@ declare class WebhookModule {
|
|
|
137
137
|
|
|
138
138
|
declare class ApiModule {
|
|
139
139
|
private realtimexUrl;
|
|
140
|
-
|
|
140
|
+
private appId;
|
|
141
|
+
constructor(realtimexUrl: string, appId: string);
|
|
142
|
+
private getHeaders;
|
|
141
143
|
getAgents(): Promise<Agent[]>;
|
|
142
144
|
getWorkspaces(): Promise<Workspace[]>;
|
|
143
145
|
getThreads(workspaceSlug: string): Promise<Thread[]>;
|
package/dist/index.js
CHANGED
|
@@ -170,29 +170,44 @@ var WebhookModule = class {
|
|
|
170
170
|
|
|
171
171
|
// src/modules/api.ts
|
|
172
172
|
var ApiModule = class {
|
|
173
|
-
constructor(realtimexUrl) {
|
|
173
|
+
constructor(realtimexUrl, appId) {
|
|
174
174
|
this.realtimexUrl = realtimexUrl.replace(/\/$/, "");
|
|
175
|
+
this.appId = appId;
|
|
176
|
+
}
|
|
177
|
+
getHeaders() {
|
|
178
|
+
return {
|
|
179
|
+
"Content-Type": "application/json",
|
|
180
|
+
"x-app-id": this.appId
|
|
181
|
+
};
|
|
175
182
|
}
|
|
176
183
|
async getAgents() {
|
|
177
|
-
const response = await fetch(`${this.realtimexUrl}/agents
|
|
184
|
+
const response = await fetch(`${this.realtimexUrl}/agents`, {
|
|
185
|
+
headers: this.getHeaders()
|
|
186
|
+
});
|
|
178
187
|
const data = await response.json();
|
|
179
188
|
if (!response.ok) throw new Error(data.error || "Failed to get agents");
|
|
180
189
|
return data.agents;
|
|
181
190
|
}
|
|
182
191
|
async getWorkspaces() {
|
|
183
|
-
const response = await fetch(`${this.realtimexUrl}/workspaces
|
|
192
|
+
const response = await fetch(`${this.realtimexUrl}/workspaces`, {
|
|
193
|
+
headers: this.getHeaders()
|
|
194
|
+
});
|
|
184
195
|
const data = await response.json();
|
|
185
196
|
if (!response.ok) throw new Error(data.error || "Failed to get workspaces");
|
|
186
197
|
return data.workspaces;
|
|
187
198
|
}
|
|
188
199
|
async getThreads(workspaceSlug) {
|
|
189
|
-
const response = await fetch(`${this.realtimexUrl}/workspaces/${encodeURIComponent(workspaceSlug)}/threads
|
|
200
|
+
const response = await fetch(`${this.realtimexUrl}/workspaces/${encodeURIComponent(workspaceSlug)}/threads`, {
|
|
201
|
+
headers: this.getHeaders()
|
|
202
|
+
});
|
|
190
203
|
const data = await response.json();
|
|
191
204
|
if (!response.ok) throw new Error(data.error || "Failed to get threads");
|
|
192
205
|
return data.threads;
|
|
193
206
|
}
|
|
194
207
|
async getTask(taskUuid) {
|
|
195
|
-
const response = await fetch(`${this.realtimexUrl}/task/${encodeURIComponent(taskUuid)}
|
|
208
|
+
const response = await fetch(`${this.realtimexUrl}/task/${encodeURIComponent(taskUuid)}`, {
|
|
209
|
+
headers: this.getHeaders()
|
|
210
|
+
});
|
|
196
211
|
const data = await response.json();
|
|
197
212
|
if (!response.ok) throw new Error(data.error || "Failed to get task");
|
|
198
213
|
return { ...data.task, runs: data.runs };
|
|
@@ -331,7 +346,7 @@ var _RealtimeXSDK = class _RealtimeXSDK {
|
|
|
331
346
|
const realtimexUrl = config.realtimex?.url || _RealtimeXSDK.DEFAULT_REALTIMEX_URL;
|
|
332
347
|
this.activities = new ActivitiesModule(realtimexUrl, this.appId);
|
|
333
348
|
this.webhook = new WebhookModule(realtimexUrl, this.appName, this.appId);
|
|
334
|
-
this.api = new ApiModule(realtimexUrl);
|
|
349
|
+
this.api = new ApiModule(realtimexUrl, this.appId);
|
|
335
350
|
this.task = new TaskModule(realtimexUrl, this.appName, this.appId);
|
|
336
351
|
this.port = new PortModule(config.defaultPort);
|
|
337
352
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -129,29 +129,44 @@ var WebhookModule = class {
|
|
|
129
129
|
|
|
130
130
|
// src/modules/api.ts
|
|
131
131
|
var ApiModule = class {
|
|
132
|
-
constructor(realtimexUrl) {
|
|
132
|
+
constructor(realtimexUrl, appId) {
|
|
133
133
|
this.realtimexUrl = realtimexUrl.replace(/\/$/, "");
|
|
134
|
+
this.appId = appId;
|
|
135
|
+
}
|
|
136
|
+
getHeaders() {
|
|
137
|
+
return {
|
|
138
|
+
"Content-Type": "application/json",
|
|
139
|
+
"x-app-id": this.appId
|
|
140
|
+
};
|
|
134
141
|
}
|
|
135
142
|
async getAgents() {
|
|
136
|
-
const response = await fetch(`${this.realtimexUrl}/agents
|
|
143
|
+
const response = await fetch(`${this.realtimexUrl}/agents`, {
|
|
144
|
+
headers: this.getHeaders()
|
|
145
|
+
});
|
|
137
146
|
const data = await response.json();
|
|
138
147
|
if (!response.ok) throw new Error(data.error || "Failed to get agents");
|
|
139
148
|
return data.agents;
|
|
140
149
|
}
|
|
141
150
|
async getWorkspaces() {
|
|
142
|
-
const response = await fetch(`${this.realtimexUrl}/workspaces
|
|
151
|
+
const response = await fetch(`${this.realtimexUrl}/workspaces`, {
|
|
152
|
+
headers: this.getHeaders()
|
|
153
|
+
});
|
|
143
154
|
const data = await response.json();
|
|
144
155
|
if (!response.ok) throw new Error(data.error || "Failed to get workspaces");
|
|
145
156
|
return data.workspaces;
|
|
146
157
|
}
|
|
147
158
|
async getThreads(workspaceSlug) {
|
|
148
|
-
const response = await fetch(`${this.realtimexUrl}/workspaces/${encodeURIComponent(workspaceSlug)}/threads
|
|
159
|
+
const response = await fetch(`${this.realtimexUrl}/workspaces/${encodeURIComponent(workspaceSlug)}/threads`, {
|
|
160
|
+
headers: this.getHeaders()
|
|
161
|
+
});
|
|
149
162
|
const data = await response.json();
|
|
150
163
|
if (!response.ok) throw new Error(data.error || "Failed to get threads");
|
|
151
164
|
return data.threads;
|
|
152
165
|
}
|
|
153
166
|
async getTask(taskUuid) {
|
|
154
|
-
const response = await fetch(`${this.realtimexUrl}/task/${encodeURIComponent(taskUuid)}
|
|
167
|
+
const response = await fetch(`${this.realtimexUrl}/task/${encodeURIComponent(taskUuid)}`, {
|
|
168
|
+
headers: this.getHeaders()
|
|
169
|
+
});
|
|
155
170
|
const data = await response.json();
|
|
156
171
|
if (!response.ok) throw new Error(data.error || "Failed to get task");
|
|
157
172
|
return { ...data.task, runs: data.runs };
|
|
@@ -290,7 +305,7 @@ var _RealtimeXSDK = class _RealtimeXSDK {
|
|
|
290
305
|
const realtimexUrl = config.realtimex?.url || _RealtimeXSDK.DEFAULT_REALTIMEX_URL;
|
|
291
306
|
this.activities = new ActivitiesModule(realtimexUrl, this.appId);
|
|
292
307
|
this.webhook = new WebhookModule(realtimexUrl, this.appName, this.appId);
|
|
293
|
-
this.api = new ApiModule(realtimexUrl);
|
|
308
|
+
this.api = new ApiModule(realtimexUrl, this.appId);
|
|
294
309
|
this.task = new TaskModule(realtimexUrl, this.appName, this.appId);
|
|
295
310
|
this.port = new PortModule(config.defaultPort);
|
|
296
311
|
}
|