@elizaos/api-client 1.5.3-beta.3 → 1.5.5
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.ts +1102 -1
- package/dist/index.js +449 -144
- package/dist/index.js.map +1 -19
- package/package.json +6 -5
- package/dist/api-client/src/client.d.ts +0 -25
- package/dist/api-client/src/client.d.ts.map +0 -1
- package/dist/api-client/src/index.d.ts +0 -20
- package/dist/api-client/src/index.d.ts.map +0 -1
- package/dist/api-client/src/lib/base-client.d.ts +0 -31
- package/dist/api-client/src/lib/base-client.d.ts.map +0 -1
- package/dist/api-client/src/services/agents.d.ts +0 -107
- package/dist/api-client/src/services/agents.d.ts.map +0 -1
- package/dist/api-client/src/services/audio.d.ts +0 -48
- package/dist/api-client/src/services/audio.d.ts.map +0 -1
- package/dist/api-client/src/services/media.d.ts +0 -14
- package/dist/api-client/src/services/media.d.ts.map +0 -1
- package/dist/api-client/src/services/memory.d.ts +0 -107
- package/dist/api-client/src/services/memory.d.ts.map +0 -1
- package/dist/api-client/src/services/messaging.d.ts +0 -164
- package/dist/api-client/src/services/messaging.d.ts.map +0 -1
- package/dist/api-client/src/services/server.d.ts +0 -47
- package/dist/api-client/src/services/server.d.ts.map +0 -1
- package/dist/api-client/src/services/sessions.d.ts +0 -52
- package/dist/api-client/src/services/sessions.d.ts.map +0 -1
- package/dist/api-client/src/services/system.d.ts +0 -56
- package/dist/api-client/src/services/system.d.ts.map +0 -1
- package/dist/api-client/src/types/agents.d.ts +0 -67
- package/dist/api-client/src/types/agents.d.ts.map +0 -1
- package/dist/api-client/src/types/audio.d.ts +0 -42
- package/dist/api-client/src/types/audio.d.ts.map +0 -1
- package/dist/api-client/src/types/base.d.ts +0 -30
- package/dist/api-client/src/types/base.d.ts.map +0 -1
- package/dist/api-client/src/types/media.d.ts +0 -21
- package/dist/api-client/src/types/media.d.ts.map +0 -1
- package/dist/api-client/src/types/memory.d.ts +0 -43
- package/dist/api-client/src/types/memory.d.ts.map +0 -1
- package/dist/api-client/src/types/messaging.d.ts +0 -186
- package/dist/api-client/src/types/messaging.d.ts.map +0 -1
- package/dist/api-client/src/types/server.d.ts +0 -44
- package/dist/api-client/src/types/server.d.ts.map +0 -1
- package/dist/api-client/src/types/sessions.d.ts +0 -134
- package/dist/api-client/src/types/sessions.d.ts.map +0 -1
- package/dist/api-client/src/types/system.d.ts +0 -16
- package/dist/api-client/src/types/system.d.ts.map +0 -1
- package/dist/core/src/actions.d.ts +0 -23
- package/dist/core/src/actions.d.ts.map +0 -1
- package/dist/core/src/database.d.ts +0 -481
- package/dist/core/src/database.d.ts.map +0 -1
- package/dist/core/src/entities.d.ts +0 -49
- package/dist/core/src/entities.d.ts.map +0 -1
- package/dist/core/src/index.d.ts +0 -27
- package/dist/core/src/index.d.ts.map +0 -1
- package/dist/core/src/logger.d.ts +0 -47
- package/dist/core/src/logger.d.ts.map +0 -1
- package/dist/core/src/prompts.d.ts +0 -8
- package/dist/core/src/prompts.d.ts.map +0 -1
- package/dist/core/src/roles.d.ts +0 -30
- package/dist/core/src/roles.d.ts.map +0 -1
- package/dist/core/src/runtime.d.ts +0 -328
- package/dist/core/src/runtime.d.ts.map +0 -1
- package/dist/core/src/schemas/character.d.ts +0 -228
- package/dist/core/src/schemas/character.d.ts.map +0 -1
- package/dist/core/src/search.d.ts +0 -317
- package/dist/core/src/search.d.ts.map +0 -1
- package/dist/core/src/sentry/instrument.d.ts +0 -12
- package/dist/core/src/sentry/instrument.d.ts.map +0 -1
- package/dist/core/src/services.d.ts +0 -49
- package/dist/core/src/services.d.ts.map +0 -1
- package/dist/core/src/settings.d.ts +0 -87
- package/dist/core/src/settings.d.ts.map +0 -1
- package/dist/core/src/types/agent.d.ts +0 -98
- package/dist/core/src/types/agent.d.ts.map +0 -1
- package/dist/core/src/types/browser.d.ts +0 -127
- package/dist/core/src/types/browser.d.ts.map +0 -1
- package/dist/core/src/types/components.d.ts +0 -135
- package/dist/core/src/types/components.d.ts.map +0 -1
- package/dist/core/src/types/database.d.ts +0 -278
- package/dist/core/src/types/database.d.ts.map +0 -1
- package/dist/core/src/types/email.d.ts +0 -143
- package/dist/core/src/types/email.d.ts.map +0 -1
- package/dist/core/src/types/environment.d.ts +0 -109
- package/dist/core/src/types/environment.d.ts.map +0 -1
- package/dist/core/src/types/events.d.ts +0 -208
- package/dist/core/src/types/events.d.ts.map +0 -1
- package/dist/core/src/types/index.d.ts +0 -30
- package/dist/core/src/types/index.d.ts.map +0 -1
- package/dist/core/src/types/knowledge.d.ts +0 -60
- package/dist/core/src/types/knowledge.d.ts.map +0 -1
- package/dist/core/src/types/lp.d.ts +0 -115
- package/dist/core/src/types/lp.d.ts.map +0 -1
- package/dist/core/src/types/memory.d.ts +0 -165
- package/dist/core/src/types/memory.d.ts.map +0 -1
- package/dist/core/src/types/message.d.ts +0 -202
- package/dist/core/src/types/message.d.ts.map +0 -1
- package/dist/core/src/types/messaging.d.ts +0 -45
- package/dist/core/src/types/messaging.d.ts.map +0 -1
- package/dist/core/src/types/model.d.ts +0 -319
- package/dist/core/src/types/model.d.ts.map +0 -1
- package/dist/core/src/types/pdf.d.ts +0 -68
- package/dist/core/src/types/pdf.d.ts.map +0 -1
- package/dist/core/src/types/plugin.d.ts +0 -64
- package/dist/core/src/types/plugin.d.ts.map +0 -1
- package/dist/core/src/types/post.d.ts +0 -242
- package/dist/core/src/types/post.d.ts.map +0 -1
- package/dist/core/src/types/primitives.d.ts +0 -72
- package/dist/core/src/types/primitives.d.ts.map +0 -1
- package/dist/core/src/types/runtime.d.ts +0 -106
- package/dist/core/src/types/runtime.d.ts.map +0 -1
- package/dist/core/src/types/service.d.ts +0 -147
- package/dist/core/src/types/service.d.ts.map +0 -1
- package/dist/core/src/types/settings.d.ts +0 -30
- package/dist/core/src/types/settings.d.ts.map +0 -1
- package/dist/core/src/types/state.d.ts +0 -59
- package/dist/core/src/types/state.d.ts.map +0 -1
- package/dist/core/src/types/task.d.ts +0 -68
- package/dist/core/src/types/task.d.ts.map +0 -1
- package/dist/core/src/types/tee.d.ts +0 -97
- package/dist/core/src/types/tee.d.ts.map +0 -1
- package/dist/core/src/types/testing.d.ts +0 -29
- package/dist/core/src/types/testing.d.ts.map +0 -1
- package/dist/core/src/types/token.d.ts +0 -73
- package/dist/core/src/types/token.d.ts.map +0 -1
- package/dist/core/src/types/transcription.d.ts +0 -108
- package/dist/core/src/types/transcription.d.ts.map +0 -1
- package/dist/core/src/types/video.d.ts +0 -93
- package/dist/core/src/types/video.d.ts.map +0 -1
- package/dist/core/src/types/wallet.d.ts +0 -49
- package/dist/core/src/types/wallet.d.ts.map +0 -1
- package/dist/core/src/types/web-search.d.ts +0 -112
- package/dist/core/src/types/web-search.d.ts.map +0 -1
- package/dist/core/src/utils/buffer.d.ts +0 -105
- package/dist/core/src/utils/buffer.d.ts.map +0 -1
- package/dist/core/src/utils/environment.d.ts +0 -106
- package/dist/core/src/utils/environment.d.ts.map +0 -1
- package/dist/core/src/utils/server-health.d.ts +0 -23
- package/dist/core/src/utils/server-health.d.ts.map +0 -1
- package/dist/core/src/utils.d.ts +0 -177
- package/dist/core/src/utils.d.ts.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
// src/lib/base-client.ts
|
|
2
|
-
|
|
3
|
-
code;
|
|
4
|
-
details;
|
|
5
|
-
status;
|
|
4
|
+
var ApiError = class extends Error {
|
|
6
5
|
constructor(code, message, details, status) {
|
|
7
6
|
super(message);
|
|
8
7
|
this.code = code;
|
|
@@ -10,9 +9,8 @@ class ApiError extends Error {
|
|
|
10
9
|
this.status = status;
|
|
11
10
|
this.name = "ApiError";
|
|
12
11
|
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
class BaseApiClient {
|
|
12
|
+
};
|
|
13
|
+
var BaseApiClient = class {
|
|
16
14
|
baseUrl;
|
|
17
15
|
apiKey;
|
|
18
16
|
timeout;
|
|
@@ -20,7 +18,7 @@ class BaseApiClient {
|
|
|
20
18
|
constructor(config) {
|
|
21
19
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
22
20
|
this.apiKey = config.apiKey;
|
|
23
|
-
this.timeout = config.timeout ||
|
|
21
|
+
this.timeout = config.timeout || 3e4;
|
|
24
22
|
this.defaultHeaders = {
|
|
25
23
|
"Content-Type": "application/json",
|
|
26
24
|
...config.headers
|
|
@@ -29,6 +27,10 @@ class BaseApiClient {
|
|
|
29
27
|
this.defaultHeaders["X-API-KEY"] = this.apiKey;
|
|
30
28
|
}
|
|
31
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a safe response for no-content scenarios (204 responses)
|
|
32
|
+
* Returns a sensible default based on common API patterns
|
|
33
|
+
*/
|
|
32
34
|
createNoContentResponse() {
|
|
33
35
|
return { success: true };
|
|
34
36
|
}
|
|
@@ -43,12 +45,12 @@ class BaseApiClient {
|
|
|
43
45
|
}
|
|
44
46
|
if (options?.params) {
|
|
45
47
|
Object.entries(options.params).forEach(([key, value]) => {
|
|
46
|
-
if (value !==
|
|
48
|
+
if (value !== void 0 && value !== null) {
|
|
47
49
|
url.searchParams.append(key, String(value));
|
|
48
50
|
}
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
|
-
const controller = new AbortController;
|
|
53
|
+
const controller = new AbortController();
|
|
52
54
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
53
55
|
try {
|
|
54
56
|
const headers = {
|
|
@@ -62,7 +64,7 @@ class BaseApiClient {
|
|
|
62
64
|
const response = await fetch(url.toString(), {
|
|
63
65
|
method,
|
|
64
66
|
headers,
|
|
65
|
-
body: options?.body instanceof FormData ? options.body : options?.body ? JSON.stringify(options.body) :
|
|
67
|
+
body: options?.body instanceof FormData ? options.body : options?.body ? JSON.stringify(options.body) : void 0,
|
|
66
68
|
signal: controller.signal
|
|
67
69
|
});
|
|
68
70
|
clearTimeout(timeoutId);
|
|
@@ -76,7 +78,12 @@ class BaseApiClient {
|
|
|
76
78
|
if (response.ok) {
|
|
77
79
|
return this.createNoContentResponse();
|
|
78
80
|
} else {
|
|
79
|
-
throw new ApiError(
|
|
81
|
+
throw new ApiError(
|
|
82
|
+
"PARSE_ERROR",
|
|
83
|
+
"Failed to parse response as JSON",
|
|
84
|
+
void 0,
|
|
85
|
+
response.status
|
|
86
|
+
);
|
|
80
87
|
}
|
|
81
88
|
}
|
|
82
89
|
if (!response.ok) {
|
|
@@ -128,58 +135,105 @@ class BaseApiClient {
|
|
|
128
135
|
async delete(path, options) {
|
|
129
136
|
return this.request("DELETE", path, options);
|
|
130
137
|
}
|
|
131
|
-
}
|
|
138
|
+
};
|
|
132
139
|
|
|
133
140
|
// src/services/agents.ts
|
|
134
|
-
|
|
141
|
+
var AgentsService = class extends BaseApiClient {
|
|
142
|
+
/**
|
|
143
|
+
* List all agents with minimal details
|
|
144
|
+
*/
|
|
135
145
|
async listAgents() {
|
|
136
146
|
return this.get("/api/agents");
|
|
137
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Get specific agent details
|
|
150
|
+
*/
|
|
138
151
|
async getAgent(agentId) {
|
|
139
152
|
return this.get(`/api/agents/${agentId}`);
|
|
140
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Create a new agent
|
|
156
|
+
*/
|
|
141
157
|
async createAgent(params) {
|
|
142
158
|
return this.post("/api/agents", params);
|
|
143
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Update an existing agent
|
|
162
|
+
*/
|
|
144
163
|
async updateAgent(agentId, params) {
|
|
145
164
|
return this.patch(`/api/agents/${agentId}`, params);
|
|
146
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Delete an agent
|
|
168
|
+
*/
|
|
147
169
|
async deleteAgent(agentId) {
|
|
148
170
|
return this.delete(`/api/agents/${agentId}`);
|
|
149
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Start an existing agent
|
|
174
|
+
*/
|
|
150
175
|
async startAgent(agentId) {
|
|
151
176
|
return this.post(`/api/agents/${agentId}/start`);
|
|
152
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Stop a running agent
|
|
180
|
+
*/
|
|
153
181
|
async stopAgent(agentId) {
|
|
154
182
|
return this.post(`/api/agents/${agentId}/stop`);
|
|
155
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Get all available worlds
|
|
186
|
+
*/
|
|
156
187
|
async getWorlds() {
|
|
157
188
|
return this.get("/api/agents/worlds");
|
|
158
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Add agent to a world
|
|
192
|
+
*/
|
|
159
193
|
async addAgentToWorld(agentId, worldId) {
|
|
160
194
|
return this.post(`/api/agents/${agentId}/worlds`, { worldId });
|
|
161
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Update agent's world settings
|
|
198
|
+
*/
|
|
162
199
|
async updateAgentWorldSettings(agentId, worldId, settings) {
|
|
163
200
|
return this.patch(`/api/agents/${agentId}/worlds/${worldId}`, { settings });
|
|
164
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Get agent's plugin panels
|
|
204
|
+
*/
|
|
165
205
|
async getAgentPanels(agentId) {
|
|
166
|
-
const response = await this.get(
|
|
206
|
+
const response = await this.get(
|
|
207
|
+
`/api/agents/${agentId}/panels`
|
|
208
|
+
);
|
|
167
209
|
const panels = (Array.isArray(response) ? response : []).map((panel, index) => ({
|
|
168
210
|
id: `${panel.name}-${index}`,
|
|
211
|
+
// Generate an ID since server doesn't send one
|
|
169
212
|
name: panel.name,
|
|
170
213
|
url: panel.path,
|
|
171
214
|
type: "plugin"
|
|
172
215
|
}));
|
|
173
216
|
return { panels };
|
|
174
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Get agent logs
|
|
220
|
+
*/
|
|
175
221
|
async getAgentLogs(agentId, params) {
|
|
176
222
|
return this.get(`/api/agents/${agentId}/logs`, { params });
|
|
177
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Delete a specific log entry
|
|
226
|
+
*/
|
|
178
227
|
async deleteAgentLog(agentId, logId) {
|
|
179
228
|
return this.delete(`/api/agents/${agentId}/logs/${logId}`);
|
|
180
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Get agents associated with a server
|
|
232
|
+
*/
|
|
181
233
|
async getAgentsForServer(serverId) {
|
|
182
|
-
return this.get(
|
|
234
|
+
return this.get(
|
|
235
|
+
`/api/messaging/servers/${serverId}/agents`
|
|
236
|
+
);
|
|
183
237
|
}
|
|
184
238
|
async addAgentToServer(serverId, agentId) {
|
|
185
239
|
return this.post(`/api/messaging/servers/${serverId}/agents`, { agentId });
|
|
@@ -188,129 +242,194 @@ class AgentsService extends BaseApiClient {
|
|
|
188
242
|
return this.delete(`/api/messaging/servers/${serverId}/agents/${agentId}`);
|
|
189
243
|
}
|
|
190
244
|
async getServersForAgent(agentId) {
|
|
191
|
-
return this.get(
|
|
245
|
+
return this.get(
|
|
246
|
+
`/api/messaging/agents/${agentId}/servers`
|
|
247
|
+
);
|
|
192
248
|
}
|
|
193
|
-
}
|
|
249
|
+
};
|
|
194
250
|
|
|
195
251
|
// src/services/messaging.ts
|
|
196
|
-
|
|
252
|
+
var MessagingService = class extends BaseApiClient {
|
|
253
|
+
/**
|
|
254
|
+
* Submit agent replies or system messages
|
|
255
|
+
*/
|
|
197
256
|
async submitMessage(params) {
|
|
198
257
|
return this.post("/api/messaging/submit", params);
|
|
199
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Notify message completion
|
|
261
|
+
*/
|
|
200
262
|
async completeMessage(params) {
|
|
201
263
|
return this.post("/api/messaging/complete", params);
|
|
202
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* Ingest messages from external platforms
|
|
267
|
+
*/
|
|
203
268
|
async ingestExternalMessages(params) {
|
|
204
269
|
return this.post("/api/messaging/ingest-external", params);
|
|
205
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Create a new channel
|
|
273
|
+
*/
|
|
206
274
|
async createChannel(params) {
|
|
207
|
-
|
|
208
|
-
name: params.name,
|
|
209
|
-
type: params.type,
|
|
210
|
-
server_id: params.serverId || "00000000-0000-0000-0000-000000000000",
|
|
211
|
-
metadata: params.metadata
|
|
212
|
-
};
|
|
213
|
-
return this.post("/api/messaging/central-channels", payload);
|
|
275
|
+
return this.post("/api/messaging/central-channels", params);
|
|
214
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Create a group channel
|
|
279
|
+
*/
|
|
215
280
|
async createGroupChannel(params) {
|
|
216
|
-
|
|
217
|
-
let cleanedMetadata;
|
|
218
|
-
let serverIdFromMeta;
|
|
219
|
-
let typeFromMeta;
|
|
220
|
-
if (params.metadata) {
|
|
221
|
-
const metadataCopy = { ...params.metadata };
|
|
222
|
-
if ("server_id" in metadataCopy) {
|
|
223
|
-
serverIdFromMeta = metadataCopy["server_id"];
|
|
224
|
-
delete metadataCopy["server_id"];
|
|
225
|
-
}
|
|
226
|
-
if ("type" in metadataCopy) {
|
|
227
|
-
typeFromMeta = metadataCopy["type"];
|
|
228
|
-
delete metadataCopy["type"];
|
|
229
|
-
}
|
|
230
|
-
if (Object.keys(metadataCopy).length > 0) {
|
|
231
|
-
cleanedMetadata = metadataCopy;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
const payload = {
|
|
235
|
-
name: params.name,
|
|
236
|
-
server_id: serverIdFromMeta || DEFAULT_SERVER_ID,
|
|
237
|
-
participantCentralUserIds: params.participantIds,
|
|
238
|
-
...typeFromMeta ? { type: typeFromMeta } : {},
|
|
239
|
-
...cleanedMetadata ? { metadata: cleanedMetadata } : {}
|
|
240
|
-
};
|
|
241
|
-
return this.post("/api/messaging/central-channels", payload);
|
|
281
|
+
return this.post("/api/messaging/central-channels", params);
|
|
242
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Find or create a DM channel
|
|
285
|
+
*/
|
|
243
286
|
async getOrCreateDmChannel(params) {
|
|
244
|
-
|
|
245
|
-
const query = {
|
|
246
|
-
currentUserId: userA,
|
|
247
|
-
targetUserId: userB,
|
|
248
|
-
dmServerId: "00000000-0000-0000-0000-000000000000"
|
|
249
|
-
};
|
|
250
|
-
return this.get("/api/messaging/dm-channel", { params: query });
|
|
287
|
+
return this.get("/api/messaging/dm-channel", { params });
|
|
251
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Get channel details
|
|
291
|
+
*/
|
|
252
292
|
async getChannelDetails(channelId) {
|
|
253
293
|
return this.get(`/api/messaging/central-channels/${channelId}/details`);
|
|
254
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Get channel participants
|
|
297
|
+
*/
|
|
255
298
|
async getChannelParticipants(channelId) {
|
|
256
|
-
return this.get(
|
|
299
|
+
return this.get(
|
|
300
|
+
`/api/messaging/central-channels/${channelId}/participants`
|
|
301
|
+
);
|
|
257
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Add agent to channel
|
|
305
|
+
*/
|
|
258
306
|
async addAgentToChannel(channelId, agentId) {
|
|
259
307
|
return this.post(`/api/messaging/central-channels/${channelId}/agents`, {
|
|
260
308
|
agentId
|
|
261
309
|
});
|
|
262
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Remove agent from channel
|
|
313
|
+
*/
|
|
263
314
|
async removeAgentFromChannel(channelId, agentId) {
|
|
264
|
-
return this.delete(
|
|
315
|
+
return this.delete(
|
|
316
|
+
`/api/messaging/central-channels/${channelId}/agents/${agentId}`
|
|
317
|
+
);
|
|
265
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* Delete a channel
|
|
321
|
+
*/
|
|
266
322
|
async deleteChannel(channelId) {
|
|
267
323
|
return this.delete(`/api/messaging/central-channels/${channelId}`);
|
|
268
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Clear channel history
|
|
327
|
+
*/
|
|
269
328
|
async clearChannelHistory(channelId) {
|
|
270
|
-
return this.delete(
|
|
329
|
+
return this.delete(
|
|
330
|
+
`/api/messaging/central-channels/${channelId}/messages`
|
|
331
|
+
);
|
|
271
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Post a new message to a channel
|
|
335
|
+
*/
|
|
272
336
|
async postMessage(channelId, content, metadata) {
|
|
273
337
|
return this.post(`/api/messaging/central-channels/${channelId}/messages`, {
|
|
274
338
|
content,
|
|
275
339
|
metadata
|
|
276
340
|
});
|
|
277
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Get channel messages
|
|
344
|
+
*/
|
|
278
345
|
async getChannelMessages(channelId, params) {
|
|
279
|
-
return this.get(
|
|
280
|
-
|
|
346
|
+
return this.get(
|
|
347
|
+
`/api/messaging/central-channels/${channelId}/messages`,
|
|
348
|
+
{ params }
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Get a specific message
|
|
353
|
+
*/
|
|
281
354
|
async getMessage(messageId) {
|
|
282
355
|
return this.get(`/api/messaging/messages/${messageId}`);
|
|
283
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* Delete a message from a channel
|
|
359
|
+
*/
|
|
284
360
|
async deleteMessage(channelId, messageId) {
|
|
285
|
-
return this.delete(
|
|
361
|
+
return this.delete(
|
|
362
|
+
`/api/messaging/central-channels/${channelId}/messages/${messageId}`
|
|
363
|
+
);
|
|
286
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* Update a message
|
|
367
|
+
*/
|
|
287
368
|
async updateMessage(messageId, content) {
|
|
288
369
|
return this.patch(`/api/messaging/messages/${messageId}`, { content });
|
|
289
370
|
}
|
|
371
|
+
/**
|
|
372
|
+
* Search messages
|
|
373
|
+
*/
|
|
290
374
|
async searchMessages(params) {
|
|
291
375
|
return this.post("/api/messaging/messages/search", params);
|
|
292
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* List all message servers
|
|
379
|
+
*/
|
|
293
380
|
async listServers() {
|
|
294
381
|
return this.get("/api/messaging/central-servers");
|
|
295
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* Get server channels
|
|
385
|
+
*/
|
|
296
386
|
async getServerChannels(serverId) {
|
|
297
|
-
return this.get(
|
|
387
|
+
return this.get(
|
|
388
|
+
`/api/messaging/central-servers/${serverId}/channels`
|
|
389
|
+
);
|
|
298
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* Create a new server
|
|
393
|
+
*/
|
|
299
394
|
async createServer(params) {
|
|
300
395
|
return this.post("/api/messaging/servers", params);
|
|
301
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Sync server channels
|
|
399
|
+
*/
|
|
302
400
|
async syncServerChannels(serverId, params) {
|
|
303
|
-
return this.post(
|
|
401
|
+
return this.post(
|
|
402
|
+
`/api/messaging/servers/${serverId}/sync-channels`,
|
|
403
|
+
params
|
|
404
|
+
);
|
|
304
405
|
}
|
|
406
|
+
/**
|
|
407
|
+
* Delete a server
|
|
408
|
+
*/
|
|
305
409
|
async deleteServer(serverId) {
|
|
306
410
|
return this.delete(`/api/messaging/servers/${serverId}`);
|
|
307
411
|
}
|
|
412
|
+
/**
|
|
413
|
+
* Update a channel
|
|
414
|
+
*/
|
|
308
415
|
async updateChannel(channelId, params) {
|
|
309
|
-
return this.patch(
|
|
416
|
+
return this.patch(
|
|
417
|
+
`/api/messaging/central-channels/${channelId}`,
|
|
418
|
+
params
|
|
419
|
+
);
|
|
310
420
|
}
|
|
421
|
+
/**
|
|
422
|
+
* Generate channel title
|
|
423
|
+
*/
|
|
311
424
|
async generateChannelTitle(channelId, agentId) {
|
|
312
|
-
return this.post(
|
|
313
|
-
|
|
425
|
+
return this.post(
|
|
426
|
+
`/api/messaging/central-channels/${channelId}/generate-title`,
|
|
427
|
+
{ agentId }
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Add user to channel participants (implemented via updateChannel)
|
|
432
|
+
*/
|
|
314
433
|
async addUserToChannel(channelId, userId) {
|
|
315
434
|
const channel = await this.getChannelDetails(channelId);
|
|
316
435
|
const currentParticipants = channel.metadata?.participantCentralUserIds || [];
|
|
@@ -322,6 +441,9 @@ class MessagingService extends BaseApiClient {
|
|
|
322
441
|
}
|
|
323
442
|
return { success: true, data: channel };
|
|
324
443
|
}
|
|
444
|
+
/**
|
|
445
|
+
* Add multiple users to channel participants (implemented via updateChannel)
|
|
446
|
+
*/
|
|
325
447
|
async addUsersToChannel(channelId, userIds) {
|
|
326
448
|
const channel = await this.getChannelDetails(channelId);
|
|
327
449
|
const currentParticipants = channel.metadata?.participantCentralUserIds || [];
|
|
@@ -335,6 +457,9 @@ class MessagingService extends BaseApiClient {
|
|
|
335
457
|
participantCentralUserIds: newParticipants
|
|
336
458
|
});
|
|
337
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* Remove user from channel participants (implemented via updateChannel)
|
|
462
|
+
*/
|
|
338
463
|
async removeUserFromChannel(channelId, userId) {
|
|
339
464
|
const channel = await this.getChannelDetails(channelId);
|
|
340
465
|
const currentParticipants = channel.metadata?.participantCentralUserIds || [];
|
|
@@ -343,70 +468,136 @@ class MessagingService extends BaseApiClient {
|
|
|
343
468
|
participantCentralUserIds: updatedParticipants
|
|
344
469
|
});
|
|
345
470
|
}
|
|
346
|
-
}
|
|
471
|
+
};
|
|
347
472
|
|
|
348
473
|
// src/services/memory.ts
|
|
349
|
-
|
|
474
|
+
var MemoryService = class extends BaseApiClient {
|
|
475
|
+
/**
|
|
476
|
+
* Get agent memories
|
|
477
|
+
*/
|
|
350
478
|
async getAgentMemories(agentId, params) {
|
|
351
479
|
return this.get(`/api/memory/${agentId}/memories`, { params });
|
|
352
480
|
}
|
|
481
|
+
/**
|
|
482
|
+
* Get room-specific memories
|
|
483
|
+
*/
|
|
353
484
|
async getRoomMemories(agentId, roomId, params) {
|
|
354
485
|
return this.get(`/api/memory/${agentId}/rooms/${roomId}/memories`, {
|
|
355
486
|
params
|
|
356
487
|
});
|
|
357
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* Update a memory
|
|
491
|
+
*/
|
|
358
492
|
async updateMemory(agentId, memoryId, params) {
|
|
359
493
|
return this.patch(`/api/memory/${agentId}/memories/${memoryId}`, params);
|
|
360
494
|
}
|
|
495
|
+
/**
|
|
496
|
+
* Clear all agent memories
|
|
497
|
+
*/
|
|
361
498
|
async clearAgentMemories(agentId) {
|
|
362
499
|
return this.delete(`/api/memory/${agentId}/memories`);
|
|
363
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Clear room memories
|
|
503
|
+
*/
|
|
364
504
|
async clearRoomMemories(agentId, roomId) {
|
|
365
505
|
return this.delete(`/api/memory/${agentId}/memories/all/${roomId}`);
|
|
366
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* List agent's rooms
|
|
509
|
+
*/
|
|
367
510
|
async listAgentRooms(agentId) {
|
|
368
511
|
return this.get(`/api/memory/${agentId}/rooms`);
|
|
369
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* Get room details
|
|
515
|
+
*/
|
|
370
516
|
async getRoom(agentId, roomId) {
|
|
371
517
|
return this.get(`/api/memory/${agentId}/rooms/${roomId}`);
|
|
372
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* Create a room
|
|
521
|
+
*/
|
|
373
522
|
async createRoom(agentId, params) {
|
|
374
523
|
return this.post(`/api/memory/${agentId}/rooms`, params);
|
|
375
524
|
}
|
|
525
|
+
/**
|
|
526
|
+
* Create world from server
|
|
527
|
+
*/
|
|
376
528
|
async createWorldFromServer(serverId, params) {
|
|
377
529
|
return this.post(`/api/memory/groups/${serverId}`, params);
|
|
378
530
|
}
|
|
531
|
+
/**
|
|
532
|
+
* Delete a world
|
|
533
|
+
*/
|
|
379
534
|
async deleteWorld(serverId) {
|
|
380
535
|
return this.delete(`/api/memory/groups/${serverId}`);
|
|
381
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* Clear world memories
|
|
539
|
+
*/
|
|
382
540
|
async clearWorldMemories(serverId) {
|
|
383
541
|
return this.delete(`/api/memory/groups/${serverId}/memories`);
|
|
384
542
|
}
|
|
543
|
+
/**
|
|
544
|
+
* Delete a specific memory
|
|
545
|
+
*/
|
|
385
546
|
async deleteMemory(agentId, memoryId) {
|
|
386
547
|
return this.delete(`/api/memory/${agentId}/memories/${memoryId}`);
|
|
387
548
|
}
|
|
549
|
+
/**
|
|
550
|
+
* Get agent internal memories
|
|
551
|
+
*/
|
|
388
552
|
async getAgentInternalMemories(agentId, agentPerspectiveRoomId, includeEmbedding) {
|
|
389
|
-
return this.get(
|
|
390
|
-
|
|
553
|
+
return this.get(
|
|
554
|
+
`/api/memory/${agentId}/rooms/${agentPerspectiveRoomId}/memories`,
|
|
555
|
+
{ params: { includeEmbedding } }
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Delete agent internal memory
|
|
560
|
+
*/
|
|
391
561
|
async deleteAgentInternalMemory(agentId, memoryId) {
|
|
392
562
|
return this.delete(`/api/memory/${agentId}/memories/${memoryId}`);
|
|
393
563
|
}
|
|
564
|
+
/**
|
|
565
|
+
* Delete all agent internal memories
|
|
566
|
+
*/
|
|
394
567
|
async deleteAllAgentInternalMemories(agentId, agentPerspectiveRoomId) {
|
|
395
|
-
return this.delete(
|
|
568
|
+
return this.delete(
|
|
569
|
+
`/api/memory/${agentId}/memories/all/${agentPerspectiveRoomId}`
|
|
570
|
+
);
|
|
396
571
|
}
|
|
572
|
+
/**
|
|
573
|
+
* Update agent internal memory
|
|
574
|
+
*/
|
|
397
575
|
async updateAgentInternalMemory(agentId, memoryId, memoryData) {
|
|
398
576
|
return this.patch(`/api/memory/${agentId}/memories/${memoryId}`, memoryData);
|
|
399
577
|
}
|
|
578
|
+
/**
|
|
579
|
+
* Delete group memory (implemented via messaging channel message deletion)
|
|
580
|
+
*/
|
|
400
581
|
async deleteGroupMemory(serverId, memoryId) {
|
|
401
|
-
return this.delete(
|
|
582
|
+
return this.delete(
|
|
583
|
+
`/api/messaging/central-channels/${serverId}/messages/${memoryId}`
|
|
584
|
+
);
|
|
402
585
|
}
|
|
586
|
+
/**
|
|
587
|
+
* Clear group chat (implemented via messaging channel history clearing)
|
|
588
|
+
*/
|
|
403
589
|
async clearGroupChat(serverId) {
|
|
404
|
-
return this.delete(
|
|
590
|
+
return this.delete(
|
|
591
|
+
`/api/messaging/central-channels/${serverId}/messages`
|
|
592
|
+
);
|
|
405
593
|
}
|
|
406
|
-
}
|
|
594
|
+
};
|
|
407
595
|
|
|
408
596
|
// src/services/audio.ts
|
|
409
|
-
|
|
597
|
+
var AudioService = class extends BaseApiClient {
|
|
598
|
+
/**
|
|
599
|
+
* Make a binary request using BaseApiClient infrastructure
|
|
600
|
+
*/
|
|
410
601
|
async requestBinary(method, path, options) {
|
|
411
602
|
let url;
|
|
412
603
|
if (this.baseUrl) {
|
|
@@ -418,12 +609,12 @@ class AudioService extends BaseApiClient {
|
|
|
418
609
|
}
|
|
419
610
|
if (options?.params) {
|
|
420
611
|
Object.entries(options.params).forEach(([key, value]) => {
|
|
421
|
-
if (value !==
|
|
612
|
+
if (value !== void 0 && value !== null) {
|
|
422
613
|
url.searchParams.append(key, String(value));
|
|
423
614
|
}
|
|
424
615
|
});
|
|
425
616
|
}
|
|
426
|
-
const controller = new AbortController;
|
|
617
|
+
const controller = new AbortController();
|
|
427
618
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
428
619
|
try {
|
|
429
620
|
const headers = {
|
|
@@ -436,7 +627,7 @@ class AudioService extends BaseApiClient {
|
|
|
436
627
|
const response = await fetch(url.toString(), {
|
|
437
628
|
method,
|
|
438
629
|
headers,
|
|
439
|
-
body: options?.body instanceof FormData ? options.body : options?.body ? JSON.stringify(options.body) :
|
|
630
|
+
body: options?.body instanceof FormData ? options.body : options?.body ? JSON.stringify(options.body) : void 0,
|
|
440
631
|
signal: controller.signal
|
|
441
632
|
});
|
|
442
633
|
clearTimeout(timeoutId);
|
|
@@ -455,6 +646,9 @@ class AudioService extends BaseApiClient {
|
|
|
455
646
|
throw new Error("An unknown error occurred");
|
|
456
647
|
}
|
|
457
648
|
}
|
|
649
|
+
/**
|
|
650
|
+
* Convert audio input to appropriate FormData value
|
|
651
|
+
*/
|
|
458
652
|
processAudioInput(audio) {
|
|
459
653
|
if (audio instanceof Blob) {
|
|
460
654
|
return audio;
|
|
@@ -467,19 +661,21 @@ class AudioService extends BaseApiClient {
|
|
|
467
661
|
const mimeType = mimeMatch ? mimeMatch[1] : "audio/wav";
|
|
468
662
|
const binaryString = atob(base64Data);
|
|
469
663
|
const bytes = new Uint8Array(binaryString.length);
|
|
470
|
-
for (let i = 0;i < binaryString.length; i++) {
|
|
664
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
471
665
|
bytes[i] = binaryString.charCodeAt(i);
|
|
472
666
|
}
|
|
473
667
|
return new Blob([bytes], { type: mimeType });
|
|
474
668
|
} catch (error) {
|
|
475
|
-
throw new Error(
|
|
669
|
+
throw new Error(
|
|
670
|
+
`Invalid base64 data URL: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
671
|
+
);
|
|
476
672
|
}
|
|
477
673
|
}
|
|
478
674
|
if (this.isBase64String(audio)) {
|
|
479
675
|
try {
|
|
480
676
|
const binaryString = atob(audio);
|
|
481
677
|
const bytes = new Uint8Array(binaryString.length);
|
|
482
|
-
for (let i = 0;i < binaryString.length; i++) {
|
|
678
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
483
679
|
bytes[i] = binaryString.charCodeAt(i);
|
|
484
680
|
}
|
|
485
681
|
return new Blob([bytes], { type: "audio/wav" });
|
|
@@ -499,8 +695,13 @@ class AudioService extends BaseApiClient {
|
|
|
499
695
|
if (audioAsAny && typeof audioAsAny === "object" && "buffer" in audioAsAny && audioAsAny.buffer instanceof ArrayBuffer) {
|
|
500
696
|
return new Blob([audioAsAny.buffer], { type: "audio/wav" });
|
|
501
697
|
}
|
|
502
|
-
throw new Error(
|
|
698
|
+
throw new Error(
|
|
699
|
+
`Unsupported audio input type: ${typeof audio}. Expected Blob, Buffer, ArrayBuffer, or string.`
|
|
700
|
+
);
|
|
503
701
|
}
|
|
702
|
+
/**
|
|
703
|
+
* Check if a string appears to be base64 encoded
|
|
704
|
+
*/
|
|
504
705
|
isBase64String(str) {
|
|
505
706
|
const base64Pattern = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
506
707
|
if (str.length < 4 || str.length % 4 !== 0) {
|
|
@@ -508,34 +709,40 @@ class AudioService extends BaseApiClient {
|
|
|
508
709
|
}
|
|
509
710
|
return base64Pattern.test(str);
|
|
510
711
|
}
|
|
712
|
+
/**
|
|
713
|
+
* Safe check for Buffer type (works in both Node.js and browser environments)
|
|
714
|
+
*/
|
|
511
715
|
isBuffer(obj) {
|
|
512
716
|
return obj != null && typeof obj === "object" && typeof obj.constructor === "function" && obj.constructor.name === "Buffer" && typeof obj.readUInt8 === "function";
|
|
513
717
|
}
|
|
718
|
+
/**
|
|
719
|
+
* Handle speech conversation
|
|
720
|
+
*/
|
|
514
721
|
async speechConversation(agentId, params) {
|
|
515
|
-
const formData = new FormData;
|
|
722
|
+
const formData = new FormData();
|
|
516
723
|
const processedAudio = this.processAudioInput(params.audio);
|
|
517
724
|
if (processedAudio instanceof Blob) {
|
|
518
725
|
formData.append("file", processedAudio);
|
|
519
726
|
} else {
|
|
520
727
|
formData.append("file", processedAudio);
|
|
521
728
|
}
|
|
522
|
-
if (params.format)
|
|
523
|
-
|
|
524
|
-
if (params.
|
|
525
|
-
formData.append("language", params.language);
|
|
526
|
-
if (params.metadata)
|
|
527
|
-
formData.append("metadata", JSON.stringify(params.metadata));
|
|
729
|
+
if (params.format) formData.append("format", params.format);
|
|
730
|
+
if (params.language) formData.append("language", params.language);
|
|
731
|
+
if (params.metadata) formData.append("metadata", JSON.stringify(params.metadata));
|
|
528
732
|
return this.request("POST", `/api/audio/${agentId}/speech/conversation`, {
|
|
529
733
|
body: formData
|
|
530
734
|
});
|
|
531
735
|
}
|
|
736
|
+
/**
|
|
737
|
+
* Generate speech from text
|
|
738
|
+
*/
|
|
532
739
|
async generateSpeech(agentId, params) {
|
|
533
740
|
const audioBuffer = await this.requestBinary("POST", `/api/audio/${agentId}/speech/generate`, {
|
|
534
741
|
body: params
|
|
535
742
|
});
|
|
536
743
|
const bytes = new Uint8Array(audioBuffer);
|
|
537
744
|
let binary = "";
|
|
538
|
-
for (let i = 0;i < bytes.byteLength; i++) {
|
|
745
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
539
746
|
binary += String.fromCharCode(bytes[i]);
|
|
540
747
|
}
|
|
541
748
|
const base64Audio = btoa(binary);
|
|
@@ -545,96 +752,155 @@ class AudioService extends BaseApiClient {
|
|
|
545
752
|
format
|
|
546
753
|
};
|
|
547
754
|
}
|
|
755
|
+
/**
|
|
756
|
+
* Synthesize audio message
|
|
757
|
+
*/
|
|
548
758
|
async synthesizeAudioMessage(agentId, params) {
|
|
549
|
-
return this.post(
|
|
759
|
+
return this.post(
|
|
760
|
+
`/api/audio/${agentId}/audio-messages/synthesize`,
|
|
761
|
+
params
|
|
762
|
+
);
|
|
550
763
|
}
|
|
764
|
+
/**
|
|
765
|
+
* Transcribe audio to text
|
|
766
|
+
*/
|
|
551
767
|
async transcribe(agentId, params) {
|
|
552
|
-
const formData = new FormData;
|
|
768
|
+
const formData = new FormData();
|
|
553
769
|
const processedAudio = this.processAudioInput(params.audio);
|
|
554
770
|
if (processedAudio instanceof Blob) {
|
|
555
771
|
formData.append("file", processedAudio);
|
|
556
772
|
} else {
|
|
557
773
|
formData.append("file", processedAudio);
|
|
558
774
|
}
|
|
559
|
-
if (params.format)
|
|
560
|
-
|
|
561
|
-
if (params.language)
|
|
562
|
-
formData.append("language", params.language);
|
|
775
|
+
if (params.format) formData.append("format", params.format);
|
|
776
|
+
if (params.language) formData.append("language", params.language);
|
|
563
777
|
return this.request("POST", `/api/audio/${agentId}/transcriptions`, {
|
|
564
778
|
body: formData
|
|
565
779
|
});
|
|
566
780
|
}
|
|
781
|
+
/**
|
|
782
|
+
* Process speech input
|
|
783
|
+
*/
|
|
567
784
|
async processSpeech(agentId, audio, metadata) {
|
|
568
|
-
const formData = new FormData;
|
|
785
|
+
const formData = new FormData();
|
|
569
786
|
const processedAudio = this.processAudioInput(audio);
|
|
570
787
|
if (processedAudio instanceof Blob) {
|
|
571
788
|
formData.append("file", processedAudio);
|
|
572
789
|
} else {
|
|
573
790
|
formData.append("file", processedAudio);
|
|
574
791
|
}
|
|
575
|
-
if (metadata)
|
|
576
|
-
formData.append("metadata", JSON.stringify(metadata));
|
|
792
|
+
if (metadata) formData.append("metadata", JSON.stringify(metadata));
|
|
577
793
|
return this.request("POST", `/api/audio/${agentId}/speech`, {
|
|
578
794
|
body: formData
|
|
579
795
|
});
|
|
580
796
|
}
|
|
581
|
-
}
|
|
797
|
+
};
|
|
582
798
|
|
|
583
799
|
// src/services/media.ts
|
|
584
|
-
|
|
800
|
+
var MediaService = class extends BaseApiClient {
|
|
801
|
+
/**
|
|
802
|
+
* Upload media for an agent
|
|
803
|
+
*/
|
|
585
804
|
async uploadAgentMedia(agentId, params) {
|
|
586
|
-
const formData = new FormData;
|
|
805
|
+
const formData = new FormData();
|
|
587
806
|
formData.append("file", params.file, params.filename);
|
|
588
|
-
if (params.contentType)
|
|
589
|
-
|
|
590
|
-
if (params.metadata)
|
|
591
|
-
formData.append("metadata", JSON.stringify(params.metadata));
|
|
807
|
+
if (params.contentType) formData.append("contentType", params.contentType);
|
|
808
|
+
if (params.metadata) formData.append("metadata", JSON.stringify(params.metadata));
|
|
592
809
|
return this.request("POST", `/api/media/agents/${agentId}/upload-media`, {
|
|
593
810
|
body: formData
|
|
594
811
|
});
|
|
595
812
|
}
|
|
813
|
+
/**
|
|
814
|
+
* Upload file to a channel
|
|
815
|
+
*/
|
|
596
816
|
async uploadChannelMedia(channelId, file) {
|
|
597
|
-
const formData = new FormData;
|
|
817
|
+
const formData = new FormData();
|
|
598
818
|
formData.append("file", file);
|
|
599
|
-
return this.request(
|
|
600
|
-
|
|
601
|
-
|
|
819
|
+
return this.request(
|
|
820
|
+
"POST",
|
|
821
|
+
`/api/messaging/central-channels/${channelId}/upload-media`,
|
|
822
|
+
{
|
|
823
|
+
body: formData
|
|
824
|
+
}
|
|
825
|
+
);
|
|
602
826
|
}
|
|
603
|
-
}
|
|
827
|
+
};
|
|
604
828
|
|
|
605
829
|
// src/services/server.ts
|
|
606
|
-
|
|
830
|
+
var ServerService = class extends BaseApiClient {
|
|
831
|
+
/**
|
|
832
|
+
* Health check
|
|
833
|
+
*/
|
|
607
834
|
async checkHealth() {
|
|
608
835
|
return this.get("/api/server/health");
|
|
609
836
|
}
|
|
837
|
+
/**
|
|
838
|
+
* Simple ping
|
|
839
|
+
*/
|
|
610
840
|
async ping() {
|
|
611
841
|
return this.get("/api/server/ping");
|
|
612
842
|
}
|
|
843
|
+
/**
|
|
844
|
+
* Hello endpoint
|
|
845
|
+
*/
|
|
613
846
|
async hello() {
|
|
614
847
|
return this.get("/api/server/hello");
|
|
615
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* Get server status
|
|
851
|
+
*/
|
|
616
852
|
async getStatus() {
|
|
617
853
|
return this.get("/api/server/status");
|
|
618
854
|
}
|
|
855
|
+
/**
|
|
856
|
+
* Stop the server
|
|
857
|
+
*/
|
|
619
858
|
async stopServer() {
|
|
620
859
|
return this.post("/api/server/stop");
|
|
621
860
|
}
|
|
861
|
+
/**
|
|
862
|
+
* Get runtime debug info
|
|
863
|
+
*/
|
|
622
864
|
async getDebugInfo() {
|
|
623
865
|
return this.get("/api/server/debug/servers");
|
|
624
866
|
}
|
|
867
|
+
/**
|
|
868
|
+
* Submit logs
|
|
869
|
+
*/
|
|
625
870
|
async submitLogs(logs) {
|
|
626
871
|
return this.post("/api/server/logs", { logs });
|
|
627
872
|
}
|
|
873
|
+
/**
|
|
874
|
+
* Clear logs
|
|
875
|
+
*/
|
|
628
876
|
async clearLogs() {
|
|
629
877
|
return this.delete("/api/server/logs");
|
|
630
878
|
}
|
|
631
|
-
}
|
|
879
|
+
};
|
|
632
880
|
|
|
633
881
|
// src/services/system.ts
|
|
634
|
-
|
|
882
|
+
var SystemService = class extends BaseApiClient {
|
|
883
|
+
/**
|
|
884
|
+
* Retrieve the local environment variables from the ElizaOS server.
|
|
885
|
+
*
|
|
886
|
+
* Server route (packages/server/src/api/system):
|
|
887
|
+
* GET /api/system/env/local -> { success: true, data: Record<string,string> }
|
|
888
|
+
*/
|
|
635
889
|
async getEnvironment() {
|
|
636
890
|
return this.get("/api/system/env/local");
|
|
637
891
|
}
|
|
892
|
+
/**
|
|
893
|
+
* Update (overwrite or merge) the local .env file on the ElizaOS server.
|
|
894
|
+
*
|
|
895
|
+
* Server route (packages/server/src/api/system):
|
|
896
|
+
* POST /api/system/env/local -> { success: true, message: string }
|
|
897
|
+
* Body: { content: Record<string,string> }
|
|
898
|
+
*
|
|
899
|
+
* For developer-ergonomics we accept several shapes:
|
|
900
|
+
* 1. { variables: Record<string,string>; merge?: boolean }
|
|
901
|
+
* 2. { content: Record<string,string> } (server-native)
|
|
902
|
+
* 3. Record<string,string> (shorthand)
|
|
903
|
+
*/
|
|
638
904
|
async updateLocalEnvironment(params) {
|
|
639
905
|
if (!params || typeof params !== "object") {
|
|
640
906
|
throw new Error("updateLocalEnvironment requires a configuration object");
|
|
@@ -649,6 +915,9 @@ class SystemService extends BaseApiClient {
|
|
|
649
915
|
}
|
|
650
916
|
return this.post("/api/system/env/local", body);
|
|
651
917
|
}
|
|
918
|
+
/**
|
|
919
|
+
* Global logs functionality - implementing via system endpoints
|
|
920
|
+
*/
|
|
652
921
|
async getGlobalLogs(params) {
|
|
653
922
|
const response = await fetch(this.buildUrl("/api/server/logs", { params }), {
|
|
654
923
|
method: "GET",
|
|
@@ -670,7 +939,7 @@ class SystemService extends BaseApiClient {
|
|
|
670
939
|
const url = new URL(`${this.baseUrl}${path}`);
|
|
671
940
|
if (options?.params) {
|
|
672
941
|
Object.entries(options.params).forEach(([key, value]) => {
|
|
673
|
-
if (value !==
|
|
942
|
+
if (value !== void 0 && value !== null) {
|
|
674
943
|
url.searchParams.append(key, String(value));
|
|
675
944
|
}
|
|
676
945
|
});
|
|
@@ -686,14 +955,15 @@ class SystemService extends BaseApiClient {
|
|
|
686
955
|
return this.delete("/api/server/logs");
|
|
687
956
|
}
|
|
688
957
|
async deleteLog(logId) {
|
|
689
|
-
throw new Error(
|
|
958
|
+
throw new Error(
|
|
959
|
+
"Individual log deletion is not supported. Use deleteGlobalLogs() to clear all logs."
|
|
960
|
+
);
|
|
690
961
|
}
|
|
691
|
-
}
|
|
962
|
+
};
|
|
692
963
|
|
|
693
964
|
// src/services/sessions.ts
|
|
694
965
|
function toTimestampString(value, paramName) {
|
|
695
|
-
if (!value)
|
|
696
|
-
return;
|
|
966
|
+
if (!value) return void 0;
|
|
697
967
|
let timestamp;
|
|
698
968
|
if (value instanceof Date) {
|
|
699
969
|
timestamp = value.getTime();
|
|
@@ -702,13 +972,13 @@ function toTimestampString(value, paramName) {
|
|
|
702
972
|
timestamp = date.getTime();
|
|
703
973
|
if (isNaN(timestamp)) {
|
|
704
974
|
console.warn(`Invalid date string for ${paramName}: ${value}`);
|
|
705
|
-
return;
|
|
975
|
+
return void 0;
|
|
706
976
|
}
|
|
707
977
|
} else if (typeof value === "number") {
|
|
708
978
|
timestamp = value;
|
|
709
979
|
} else {
|
|
710
980
|
console.warn(`Invalid type for ${paramName}: ${typeof value}`);
|
|
711
|
-
return;
|
|
981
|
+
return void 0;
|
|
712
982
|
}
|
|
713
983
|
return timestamp.toString();
|
|
714
984
|
}
|
|
@@ -717,23 +987,48 @@ function validateRequiredParam(value, paramName) {
|
|
|
717
987
|
throw new Error(`${paramName} is required and cannot be empty`);
|
|
718
988
|
}
|
|
719
989
|
}
|
|
720
|
-
|
|
721
|
-
|
|
990
|
+
var SessionsService = class extends BaseApiClient {
|
|
991
|
+
/**
|
|
992
|
+
* Get health status of the sessions service
|
|
993
|
+
* @returns Health check response
|
|
994
|
+
*/
|
|
722
995
|
async checkHealth() {
|
|
723
996
|
return this.get("/api/messaging/sessions/health");
|
|
724
997
|
}
|
|
998
|
+
/**
|
|
999
|
+
* Create a new messaging session
|
|
1000
|
+
* @param params Session creation parameters
|
|
1001
|
+
* @returns Created session response
|
|
1002
|
+
*/
|
|
725
1003
|
async createSession(params) {
|
|
726
1004
|
return this.post("/api/messaging/sessions", params);
|
|
727
1005
|
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Get session details
|
|
1008
|
+
* @param sessionId Session ID
|
|
1009
|
+
* @returns Session information
|
|
1010
|
+
*/
|
|
728
1011
|
async getSession(sessionId) {
|
|
729
1012
|
validateRequiredParam(sessionId, "sessionId");
|
|
730
1013
|
return this.get(`/api/messaging/sessions/${sessionId}`);
|
|
731
1014
|
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Send a message in a session
|
|
1017
|
+
* @param sessionId Session ID
|
|
1018
|
+
* @param params Message parameters
|
|
1019
|
+
* @returns Message response
|
|
1020
|
+
*/
|
|
732
1021
|
async sendMessage(sessionId, params) {
|
|
733
1022
|
validateRequiredParam(sessionId, "sessionId");
|
|
734
1023
|
validateRequiredParam(params?.content, "content");
|
|
735
1024
|
return this.post(`/api/messaging/sessions/${sessionId}/messages`, params);
|
|
736
1025
|
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Get messages from a session
|
|
1028
|
+
* @param sessionId Session ID
|
|
1029
|
+
* @param params Query parameters for pagination and filtering
|
|
1030
|
+
* @returns Messages response
|
|
1031
|
+
*/
|
|
737
1032
|
async getMessages(sessionId, params) {
|
|
738
1033
|
validateRequiredParam(sessionId, "sessionId");
|
|
739
1034
|
const queryParams = {};
|
|
@@ -752,17 +1047,26 @@ class SessionsService extends BaseApiClient {
|
|
|
752
1047
|
params: queryParams
|
|
753
1048
|
});
|
|
754
1049
|
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Delete a session
|
|
1052
|
+
* @param sessionId Session ID
|
|
1053
|
+
* @returns Success response
|
|
1054
|
+
*/
|
|
755
1055
|
async deleteSession(sessionId) {
|
|
756
1056
|
validateRequiredParam(sessionId, "sessionId");
|
|
757
1057
|
return this.delete(`/api/messaging/sessions/${sessionId}`);
|
|
758
1058
|
}
|
|
1059
|
+
/**
|
|
1060
|
+
* List all active sessions (admin endpoint)
|
|
1061
|
+
* @returns List of active sessions
|
|
1062
|
+
*/
|
|
759
1063
|
async listSessions() {
|
|
760
1064
|
return this.get("/api/messaging/sessions");
|
|
761
1065
|
}
|
|
762
|
-
}
|
|
1066
|
+
};
|
|
763
1067
|
|
|
764
1068
|
// src/client.ts
|
|
765
|
-
|
|
1069
|
+
var ElizaClient = class _ElizaClient {
|
|
766
1070
|
agents;
|
|
767
1071
|
messaging;
|
|
768
1072
|
memory;
|
|
@@ -781,23 +1085,24 @@ class ElizaClient {
|
|
|
781
1085
|
this.system = new SystemService(config);
|
|
782
1086
|
this.sessions = new SessionsService(config);
|
|
783
1087
|
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Create a new ElizaClient instance
|
|
1090
|
+
*/
|
|
784
1091
|
static create(config) {
|
|
785
|
-
return new
|
|
1092
|
+
return new _ElizaClient(config);
|
|
786
1093
|
}
|
|
787
|
-
}
|
|
1094
|
+
};
|
|
788
1095
|
export {
|
|
789
|
-
|
|
790
|
-
SessionsService,
|
|
791
|
-
ServerService,
|
|
792
|
-
MessagingService,
|
|
793
|
-
MemoryService,
|
|
794
|
-
MediaService,
|
|
795
|
-
ElizaClient,
|
|
796
|
-
BaseApiClient,
|
|
797
|
-
AudioService,
|
|
1096
|
+
AgentsService,
|
|
798
1097
|
ApiError,
|
|
799
|
-
|
|
1098
|
+
AudioService,
|
|
1099
|
+
BaseApiClient,
|
|
1100
|
+
ElizaClient,
|
|
1101
|
+
MediaService,
|
|
1102
|
+
MemoryService,
|
|
1103
|
+
MessagingService,
|
|
1104
|
+
ServerService,
|
|
1105
|
+
SessionsService,
|
|
1106
|
+
SystemService
|
|
800
1107
|
};
|
|
801
|
-
|
|
802
|
-
//# debugId=382A61D602B6BD5A64756E2164756E21
|
|
803
|
-
//# sourceMappingURL=index.js.map
|
|
1108
|
+
//# sourceMappingURL=index.js.map
|