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