@shadowob/sdk 1.1.0 → 1.1.3
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.cjs +745 -92
- package/dist/index.d.cts +1536 -116
- package/dist/index.d.ts +1536 -116
- package/dist/index.js +745 -92
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -41,12 +41,48 @@ __export(index_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(index_exports);
|
|
42
42
|
|
|
43
43
|
// src/client.ts
|
|
44
|
+
function sanitizeErrorBody(body) {
|
|
45
|
+
if (!body) return "(empty response)";
|
|
46
|
+
if (!/<[^>]+>/.test(body)) return body.slice(0, 500);
|
|
47
|
+
const titleMatch = /<title>([^<]+)<\/title>/i.exec(body);
|
|
48
|
+
if (titleMatch?.[1]) return titleMatch[1].trim();
|
|
49
|
+
const text = body.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
50
|
+
return text.slice(0, 200) || "(HTML error page)";
|
|
51
|
+
}
|
|
52
|
+
function contentDispositionFilename(header) {
|
|
53
|
+
if (!header) return null;
|
|
54
|
+
const utf8Match = /filename\*=UTF-8''([^;]+)/i.exec(header);
|
|
55
|
+
if (utf8Match?.[1]) {
|
|
56
|
+
try {
|
|
57
|
+
return decodeURIComponent(utf8Match[1].trim());
|
|
58
|
+
} catch {
|
|
59
|
+
return utf8Match[1].trim();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const quotedMatch = /filename="([^"]+)"/i.exec(header);
|
|
63
|
+
if (quotedMatch?.[1]) return quotedMatch[1];
|
|
64
|
+
const bareMatch = /filename=([^;]+)/i.exec(header);
|
|
65
|
+
return bareMatch?.[1]?.trim() ?? null;
|
|
66
|
+
}
|
|
44
67
|
var ShadowClient = class {
|
|
45
68
|
constructor(baseUrl, token) {
|
|
46
69
|
this.token = token;
|
|
47
70
|
this.baseUrl = baseUrl.replace(/\/api\/?$/, "");
|
|
48
71
|
}
|
|
49
72
|
baseUrl;
|
|
73
|
+
isShadowPrivateMediaUrl(value) {
|
|
74
|
+
if (value.startsWith("/shadow/uploads/") || value.startsWith("/api/media/signed/")) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
if (!/^https?:\/\//.test(value)) return false;
|
|
78
|
+
try {
|
|
79
|
+
const url = new URL(value);
|
|
80
|
+
const base = new URL(this.baseUrl);
|
|
81
|
+
return url.origin === base.origin && (url.pathname.startsWith("/shadow/uploads/") || url.pathname.startsWith("/api/media/signed/"));
|
|
82
|
+
} catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
50
86
|
async request(path, init) {
|
|
51
87
|
const url = `${this.baseUrl}${path}`;
|
|
52
88
|
const controller = new AbortController();
|
|
@@ -63,11 +99,19 @@ var ShadowClient = class {
|
|
|
63
99
|
});
|
|
64
100
|
if (!res.ok) {
|
|
65
101
|
const body = await res.text().catch(() => "");
|
|
102
|
+
const message = sanitizeErrorBody(body);
|
|
66
103
|
throw new Error(
|
|
67
|
-
`Shadow API ${init?.method ?? "GET"} ${path} failed (${res.status}): ${
|
|
104
|
+
`Shadow API ${init?.method ?? "GET"} ${path} failed (${res.status}): ${message}`
|
|
68
105
|
);
|
|
69
106
|
}
|
|
70
|
-
|
|
107
|
+
const payload = await res.json();
|
|
108
|
+
if (payload && typeof payload === "object" && !Array.isArray(payload) && "ok" in payload && !("success" in payload)) {
|
|
109
|
+
return {
|
|
110
|
+
...payload,
|
|
111
|
+
success: Boolean(payload.ok)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return payload;
|
|
71
115
|
} finally {
|
|
72
116
|
clearTimeout(timeout);
|
|
73
117
|
}
|
|
@@ -83,7 +127,10 @@ var ShadowClient = class {
|
|
|
83
127
|
});
|
|
84
128
|
if (!res.ok) {
|
|
85
129
|
const body = await res.text().catch(() => "");
|
|
86
|
-
|
|
130
|
+
const message = sanitizeErrorBody(body);
|
|
131
|
+
throw new Error(
|
|
132
|
+
`Shadow API ${init?.method ?? "GET"} ${path} failed (${res.status}): ${message}`
|
|
133
|
+
);
|
|
87
134
|
}
|
|
88
135
|
return res;
|
|
89
136
|
}
|
|
@@ -100,8 +147,23 @@ var ShadowClient = class {
|
|
|
100
147
|
body: JSON.stringify(data)
|
|
101
148
|
});
|
|
102
149
|
}
|
|
103
|
-
async
|
|
104
|
-
return this.request("/api/auth/
|
|
150
|
+
async startEmailLogin(data) {
|
|
151
|
+
return this.request("/api/auth/email/start", {
|
|
152
|
+
method: "POST",
|
|
153
|
+
body: JSON.stringify(data)
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
async verifyEmailLogin(data) {
|
|
157
|
+
return this.request("/api/auth/email/verify", {
|
|
158
|
+
method: "POST",
|
|
159
|
+
body: JSON.stringify(data)
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
async refreshToken(refreshToken) {
|
|
163
|
+
return this.request("/api/auth/refresh", {
|
|
164
|
+
method: "POST",
|
|
165
|
+
body: JSON.stringify({ refreshToken })
|
|
166
|
+
});
|
|
105
167
|
}
|
|
106
168
|
async getMe() {
|
|
107
169
|
return this.request("/api/auth/me");
|
|
@@ -115,6 +177,45 @@ var ShadowClient = class {
|
|
|
115
177
|
async disconnect() {
|
|
116
178
|
return this.request("/api/auth/disconnect", { method: "POST" });
|
|
117
179
|
}
|
|
180
|
+
async getMembership() {
|
|
181
|
+
return this.request("/api/membership/me");
|
|
182
|
+
}
|
|
183
|
+
async redeemInviteCode(code) {
|
|
184
|
+
return this.request("/api/membership/redeem-invite", {
|
|
185
|
+
method: "POST",
|
|
186
|
+
body: JSON.stringify({ code })
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
async launchPlay(data) {
|
|
190
|
+
return this.request("/api/play/launch", {
|
|
191
|
+
method: "POST",
|
|
192
|
+
body: JSON.stringify(data)
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async getPlayCatalog() {
|
|
196
|
+
const response = await this.request("/api/play/catalog");
|
|
197
|
+
return response.plays;
|
|
198
|
+
}
|
|
199
|
+
// ── Official Model Proxy ──────────────────────────────────────────────
|
|
200
|
+
async listOfficialModelProxyModels() {
|
|
201
|
+
return this.request("/api/ai/v1/models");
|
|
202
|
+
}
|
|
203
|
+
async getOfficialModelProxyBilling() {
|
|
204
|
+
return this.request("/api/ai/v1/billing");
|
|
205
|
+
}
|
|
206
|
+
async createOfficialChatCompletion(data) {
|
|
207
|
+
return this.request("/api/ai/v1/chat/completions", {
|
|
208
|
+
method: "POST",
|
|
209
|
+
body: JSON.stringify(data)
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
async createOfficialChatCompletionStream(data) {
|
|
213
|
+
return this.requestRaw("/api/ai/v1/chat/completions", {
|
|
214
|
+
method: "POST",
|
|
215
|
+
headers: { "Content-Type": "application/json" },
|
|
216
|
+
body: JSON.stringify({ ...data, stream: true })
|
|
217
|
+
});
|
|
218
|
+
}
|
|
118
219
|
// ── Agents ────────────────────────────────────────────────────────────
|
|
119
220
|
async listAgents() {
|
|
120
221
|
return this.request("/api/agents");
|
|
@@ -152,21 +253,62 @@ var ShadowClient = class {
|
|
|
152
253
|
body: JSON.stringify({})
|
|
153
254
|
});
|
|
154
255
|
}
|
|
256
|
+
async reportAgentUsageSnapshot(agentId, snapshot) {
|
|
257
|
+
return this.request(`/api/agents/${agentId}/usage-snapshot`, {
|
|
258
|
+
method: "POST",
|
|
259
|
+
body: JSON.stringify(snapshot)
|
|
260
|
+
});
|
|
261
|
+
}
|
|
155
262
|
async getAgentConfig(agentId) {
|
|
156
263
|
return this.request(`/api/agents/${agentId}/config`);
|
|
157
264
|
}
|
|
265
|
+
async updateAgentSlashCommands(agentId, commands) {
|
|
266
|
+
return this.request(`/api/agents/${agentId}/slash-commands`, {
|
|
267
|
+
method: "PUT",
|
|
268
|
+
body: JSON.stringify({ commands })
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
async getAgentSlashCommands(agentId) {
|
|
272
|
+
return this.request(`/api/agents/${agentId}/slash-commands`);
|
|
273
|
+
}
|
|
274
|
+
async listChannelSlashCommands(channelId) {
|
|
275
|
+
return this.request(
|
|
276
|
+
`/api/channels/${channelId}/slash-commands`
|
|
277
|
+
);
|
|
278
|
+
}
|
|
158
279
|
// ── Agent Policies ────────────────────────────────────────────────────
|
|
159
280
|
async listPolicies(agentId, serverId) {
|
|
160
|
-
|
|
281
|
+
const policies = await this.request(`/api/agents/${agentId}/policies`);
|
|
282
|
+
if (!serverId) return policies;
|
|
283
|
+
return policies.filter((policy) => policy.serverId === serverId);
|
|
161
284
|
}
|
|
162
285
|
async upsertPolicy(agentId, serverId, data) {
|
|
163
|
-
|
|
286
|
+
const policy = {
|
|
287
|
+
serverId,
|
|
288
|
+
...data.channelId !== void 0 ? { channelId: data.channelId } : {},
|
|
289
|
+
...data.mentionOnly !== void 0 ? { mentionOnly: data.mentionOnly } : {},
|
|
290
|
+
...data.reply !== void 0 ? { reply: data.reply } : {},
|
|
291
|
+
...data.config !== void 0 ? { config: data.config } : {}
|
|
292
|
+
};
|
|
293
|
+
const results = await this.request(`/api/agents/${agentId}/policies`, {
|
|
164
294
|
method: "PUT",
|
|
165
|
-
body: JSON.stringify(
|
|
295
|
+
body: JSON.stringify({ policies: [policy] })
|
|
166
296
|
});
|
|
297
|
+
const [result] = results;
|
|
298
|
+
if (!result) {
|
|
299
|
+
throw new Error(`Shadow API PUT /api/agents/${agentId}/policies returned no policy result`);
|
|
300
|
+
}
|
|
301
|
+
return result;
|
|
167
302
|
}
|
|
168
303
|
async deletePolicy(agentId, serverId, channelId) {
|
|
169
|
-
|
|
304
|
+
const policies = await this.listPolicies(agentId, serverId);
|
|
305
|
+
const policy = policies.find((entry) => entry.channelId === channelId);
|
|
306
|
+
if (!policy?.id) {
|
|
307
|
+
throw new Error(
|
|
308
|
+
`Shadow policy not found for agent ${agentId} in server ${serverId} channel ${channelId}`
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
return this.request(`/api/agents/${agentId}/policies/${policy.id}`, {
|
|
170
312
|
method: "DELETE"
|
|
171
313
|
});
|
|
172
314
|
}
|
|
@@ -189,6 +331,9 @@ var ShadowClient = class {
|
|
|
189
331
|
async getServer(serverIdOrSlug) {
|
|
190
332
|
return this.request(`/api/servers/${serverIdOrSlug}`);
|
|
191
333
|
}
|
|
334
|
+
async getServerAccess(serverIdOrSlug) {
|
|
335
|
+
return this.request(`/api/servers/${serverIdOrSlug}/access`);
|
|
336
|
+
}
|
|
192
337
|
async updateServer(serverIdOrSlug, data) {
|
|
193
338
|
return this.request(`/api/servers/${serverIdOrSlug}`, {
|
|
194
339
|
method: "PATCH",
|
|
@@ -207,6 +352,20 @@ var ShadowClient = class {
|
|
|
207
352
|
body: JSON.stringify(inviteCode ? { inviteCode } : {})
|
|
208
353
|
});
|
|
209
354
|
}
|
|
355
|
+
async requestServerAccess(serverIdOrSlug) {
|
|
356
|
+
return this.request(
|
|
357
|
+
`/api/servers/${serverIdOrSlug}/join-requests`,
|
|
358
|
+
{
|
|
359
|
+
method: "POST"
|
|
360
|
+
}
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
async reviewServerJoinRequest(requestId, status) {
|
|
364
|
+
return this.request(`/api/servers/join-requests/${requestId}`, {
|
|
365
|
+
method: "PATCH",
|
|
366
|
+
body: JSON.stringify({ status })
|
|
367
|
+
});
|
|
368
|
+
}
|
|
210
369
|
async leaveServer(serverId) {
|
|
211
370
|
return this.request(`/api/servers/${serverId}/leave`, { method: "POST" });
|
|
212
371
|
}
|
|
@@ -223,7 +382,7 @@ var ShadowClient = class {
|
|
|
223
382
|
return this.request(`/api/servers/${serverId}/members/${userId}`, { method: "DELETE" });
|
|
224
383
|
}
|
|
225
384
|
async regenerateInviteCode(serverId) {
|
|
226
|
-
return this.request(`/api/servers/${serverId}/invite`, { method: "POST" });
|
|
385
|
+
return this.request(`/api/servers/${serverId}/invite/regenerate`, { method: "POST" });
|
|
227
386
|
}
|
|
228
387
|
async addAgentsToServer(serverId, agentIds) {
|
|
229
388
|
return this.request(`/api/servers/${serverId}/agents`, {
|
|
@@ -248,6 +407,9 @@ var ShadowClient = class {
|
|
|
248
407
|
const ch = await this.request(`/api/channels/${channelId}`);
|
|
249
408
|
return { ...ch, description: ch.topic };
|
|
250
409
|
}
|
|
410
|
+
async getChannelAccess(channelId) {
|
|
411
|
+
return this.request(`/api/channels/${channelId}/access`);
|
|
412
|
+
}
|
|
251
413
|
async getChannelMembers(channelId) {
|
|
252
414
|
return this.request(`/api/channels/${channelId}/members`);
|
|
253
415
|
}
|
|
@@ -264,8 +426,8 @@ var ShadowClient = class {
|
|
|
264
426
|
return this.request(`/api/channels/${channelId}`, { method: "DELETE" });
|
|
265
427
|
}
|
|
266
428
|
async reorderChannels(serverId, channelIds) {
|
|
267
|
-
return this.request(`/api/servers/${serverId}/channels/
|
|
268
|
-
method: "
|
|
429
|
+
return this.request(`/api/servers/${serverId}/channels/positions`, {
|
|
430
|
+
method: "PATCH",
|
|
269
431
|
body: JSON.stringify({ channelIds })
|
|
270
432
|
});
|
|
271
433
|
}
|
|
@@ -275,18 +437,32 @@ var ShadowClient = class {
|
|
|
275
437
|
body: JSON.stringify({ userId })
|
|
276
438
|
});
|
|
277
439
|
}
|
|
440
|
+
async requestChannelAccess(channelId) {
|
|
441
|
+
return this.request(
|
|
442
|
+
`/api/channels/${channelId}/join-requests`,
|
|
443
|
+
{
|
|
444
|
+
method: "POST"
|
|
445
|
+
}
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
async reviewChannelJoinRequest(requestId, status) {
|
|
449
|
+
return this.request(`/api/channel-join-requests/${requestId}`, {
|
|
450
|
+
method: "PATCH",
|
|
451
|
+
body: JSON.stringify({ status })
|
|
452
|
+
});
|
|
453
|
+
}
|
|
278
454
|
async removeChannelMember(channelId, userId) {
|
|
279
455
|
return this.request(`/api/channels/${channelId}/members/${userId}`, { method: "DELETE" });
|
|
280
456
|
}
|
|
281
457
|
// ── Channel Buddy Policy ─────────────────────────────────────────────
|
|
282
|
-
async setBuddyPolicy(channelId, data) {
|
|
283
|
-
return this.request(`/api/channels/${channelId}/
|
|
458
|
+
async setBuddyPolicy(channelId, agentId, data) {
|
|
459
|
+
return this.request(`/api/channels/${channelId}/agents/${agentId}/policy`, {
|
|
284
460
|
method: "PUT",
|
|
285
461
|
body: JSON.stringify(data)
|
|
286
462
|
});
|
|
287
463
|
}
|
|
288
|
-
async getBuddyPolicy(channelId) {
|
|
289
|
-
return this.request(`/api/channels/${channelId}/
|
|
464
|
+
async getBuddyPolicy(channelId, agentId) {
|
|
465
|
+
return this.request(`/api/channels/${channelId}/agents/${agentId}/policy`);
|
|
290
466
|
}
|
|
291
467
|
// ── Messages ──────────────────────────────────────────────────────────
|
|
292
468
|
async sendMessage(channelId, content, opts) {
|
|
@@ -296,10 +472,27 @@ var ShadowClient = class {
|
|
|
296
472
|
content,
|
|
297
473
|
...opts?.threadId ? { threadId: opts.threadId } : {},
|
|
298
474
|
...opts?.replyToId ? { replyToId: opts.replyToId } : {},
|
|
299
|
-
...opts?.
|
|
475
|
+
...opts?.mentions ? { mentions: opts.mentions } : {},
|
|
476
|
+
...opts?.metadata ? { metadata: opts.metadata } : {},
|
|
477
|
+
...opts?.attachments ? { attachments: opts.attachments } : {}
|
|
300
478
|
})
|
|
301
479
|
});
|
|
302
480
|
}
|
|
481
|
+
async suggestMentions(input) {
|
|
482
|
+
const params = new URLSearchParams({
|
|
483
|
+
channelId: input.channelId,
|
|
484
|
+
trigger: input.trigger
|
|
485
|
+
});
|
|
486
|
+
if (input.query) params.set("q", input.query);
|
|
487
|
+
if (input.limit) params.set("limit", String(input.limit));
|
|
488
|
+
return this.request(`/api/mentions/suggest?${params}`);
|
|
489
|
+
}
|
|
490
|
+
async resolveMentions(input) {
|
|
491
|
+
return this.request("/api/mentions/resolve", {
|
|
492
|
+
method: "POST",
|
|
493
|
+
body: JSON.stringify(input)
|
|
494
|
+
});
|
|
495
|
+
}
|
|
303
496
|
async getMessages(channelId, limit = 50, cursor) {
|
|
304
497
|
const params = new URLSearchParams({ limit: String(limit) });
|
|
305
498
|
if (cursor) params.set("cursor", cursor);
|
|
@@ -310,6 +503,20 @@ var ShadowClient = class {
|
|
|
310
503
|
async getMessage(messageId) {
|
|
311
504
|
return this.request(`/api/messages/${messageId}`);
|
|
312
505
|
}
|
|
506
|
+
async submitInteractiveAction(messageId, input) {
|
|
507
|
+
return this.request(`/api/messages/${messageId}/interactive`, {
|
|
508
|
+
method: "POST",
|
|
509
|
+
body: JSON.stringify(input)
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
async getInteractiveState(messageId, blockId) {
|
|
513
|
+
const params = new URLSearchParams();
|
|
514
|
+
if (blockId) params.set("blockId", blockId);
|
|
515
|
+
const query = params.toString();
|
|
516
|
+
return this.request(
|
|
517
|
+
`/api/messages/${messageId}/interactive-state${query ? `?${query}` : ""}`
|
|
518
|
+
);
|
|
519
|
+
}
|
|
313
520
|
async editMessage(messageId, content) {
|
|
314
521
|
return this.request(`/api/messages/${messageId}`, {
|
|
315
522
|
method: "PATCH",
|
|
@@ -323,16 +530,10 @@ var ShadowClient = class {
|
|
|
323
530
|
}
|
|
324
531
|
// ── Pins ──────────────────────────────────────────────────────────────
|
|
325
532
|
async pinMessage(messageId, channelId) {
|
|
326
|
-
|
|
327
|
-
return this.request(`/api/channels/${channelId}/pins/${messageId}`, { method: "PUT" });
|
|
328
|
-
}
|
|
329
|
-
return this.request(`/api/messages/${messageId}/pin`, { method: "POST" });
|
|
533
|
+
return this.request(`/api/channels/${channelId}/pins/${messageId}`, { method: "PUT" });
|
|
330
534
|
}
|
|
331
535
|
async unpinMessage(messageId, channelId) {
|
|
332
|
-
|
|
333
|
-
return this.request(`/api/channels/${channelId}/pins/${messageId}`, { method: "DELETE" });
|
|
334
|
-
}
|
|
335
|
-
return this.request(`/api/messages/${messageId}/pin`, { method: "DELETE" });
|
|
536
|
+
return this.request(`/api/channels/${channelId}/pins/${messageId}`, { method: "DELETE" });
|
|
336
537
|
}
|
|
337
538
|
async getPinnedMessages(channelId) {
|
|
338
539
|
return this.request(`/api/channels/${channelId}/pins`);
|
|
@@ -379,36 +580,26 @@ var ShadowClient = class {
|
|
|
379
580
|
if (cursor) params.set("cursor", cursor);
|
|
380
581
|
return this.request(`/api/threads/${threadId}/messages?${params}`);
|
|
381
582
|
}
|
|
382
|
-
async sendToThread(threadId, content) {
|
|
583
|
+
async sendToThread(threadId, content, options) {
|
|
383
584
|
return this.request(`/api/threads/${threadId}/messages`, {
|
|
384
585
|
method: "POST",
|
|
385
|
-
body: JSON.stringify({
|
|
586
|
+
body: JSON.stringify({
|
|
587
|
+
content,
|
|
588
|
+
...options?.replyToId ? { replyToId: options.replyToId } : {},
|
|
589
|
+
...options?.mentions ? { mentions: options.mentions } : {},
|
|
590
|
+
...options?.metadata ? { metadata: options.metadata } : {}
|
|
591
|
+
})
|
|
386
592
|
});
|
|
387
593
|
}
|
|
388
|
-
// ──
|
|
389
|
-
async
|
|
390
|
-
return this.request("/api/dm
|
|
594
|
+
// ── Direct channels ──────────────────────────────────────────────────
|
|
595
|
+
async createDirectChannel(userId) {
|
|
596
|
+
return this.request("/api/channels/dm", {
|
|
391
597
|
method: "POST",
|
|
392
598
|
body: JSON.stringify({ userId })
|
|
393
599
|
});
|
|
394
600
|
}
|
|
395
|
-
async
|
|
396
|
-
return this.request("/api/dm
|
|
397
|
-
}
|
|
398
|
-
async getDmMessages(channelId, limit = 50, cursor) {
|
|
399
|
-
const params = new URLSearchParams({ limit: String(limit) });
|
|
400
|
-
if (cursor) params.set("cursor", cursor);
|
|
401
|
-
return this.request(`/api/dm/channels/${channelId}/messages?${params}`);
|
|
402
|
-
}
|
|
403
|
-
async sendDmMessage(channelId, content, options) {
|
|
404
|
-
return this.request(`/api/dm/channels/${channelId}/messages`, {
|
|
405
|
-
method: "POST",
|
|
406
|
-
body: JSON.stringify({
|
|
407
|
-
content,
|
|
408
|
-
replyToId: options?.replyToId,
|
|
409
|
-
...options?.metadata ? { metadata: options.metadata } : {}
|
|
410
|
-
})
|
|
411
|
-
});
|
|
601
|
+
async listDirectChannels() {
|
|
602
|
+
return this.request("/api/channels/dm");
|
|
412
603
|
}
|
|
413
604
|
// ── Notifications ─────────────────────────────────────────────────────
|
|
414
605
|
async listNotifications(limit = 50, offset = 0) {
|
|
@@ -459,8 +650,10 @@ var ShadowClient = class {
|
|
|
459
650
|
const formData = new FormData();
|
|
460
651
|
const blob = file instanceof Blob ? file : new Blob([file], { type: contentType });
|
|
461
652
|
formData.append("file", blob, filename);
|
|
462
|
-
if (messageId) {
|
|
653
|
+
if (typeof messageId === "string") {
|
|
463
654
|
formData.append("messageId", messageId);
|
|
655
|
+
} else if (messageId) {
|
|
656
|
+
if (messageId.messageId) formData.append("messageId", messageId.messageId);
|
|
464
657
|
}
|
|
465
658
|
const url = `${this.baseUrl}/api/media/upload`;
|
|
466
659
|
const res = await fetch(url, {
|
|
@@ -476,6 +669,12 @@ var ShadowClient = class {
|
|
|
476
669
|
}
|
|
477
670
|
return res.json();
|
|
478
671
|
}
|
|
672
|
+
async resolveAttachmentMediaUrl(attachmentId, options) {
|
|
673
|
+
const disposition = options?.disposition ?? "inline";
|
|
674
|
+
return this.request(
|
|
675
|
+
`/api/attachments/${attachmentId}/media-url?disposition=${disposition}`
|
|
676
|
+
);
|
|
677
|
+
}
|
|
479
678
|
/**
|
|
480
679
|
* Download a file from a URL and upload it to the Shadow media service.
|
|
481
680
|
* Supports local filesystem paths, file:// URLs, tilde paths, and HTTP(S) URLs.
|
|
@@ -491,6 +690,15 @@ var ShadowClient = class {
|
|
|
491
690
|
if (normalizedUrl.startsWith("~")) {
|
|
492
691
|
normalizedUrl = normalizedUrl.replace(/^~/, homedir());
|
|
493
692
|
}
|
|
693
|
+
if (this.isShadowPrivateMediaUrl(normalizedUrl)) {
|
|
694
|
+
const downloaded = await this.downloadFile(normalizedUrl);
|
|
695
|
+
return this.uploadMedia(
|
|
696
|
+
downloaded.buffer,
|
|
697
|
+
downloaded.filename,
|
|
698
|
+
downloaded.contentType,
|
|
699
|
+
messageId
|
|
700
|
+
);
|
|
701
|
+
}
|
|
494
702
|
if (!normalizedUrl.startsWith("/") && !normalizedUrl.startsWith("http://") && !normalizedUrl.startsWith("https://") && !normalizedUrl.startsWith("//")) {
|
|
495
703
|
const { existsSync } = await import("fs");
|
|
496
704
|
const { resolve } = await import("path");
|
|
@@ -565,7 +773,7 @@ var ShadowClient = class {
|
|
|
565
773
|
const buffer = await res.arrayBuffer();
|
|
566
774
|
const contentType = res.headers.get("content-type") ?? "application/octet-stream";
|
|
567
775
|
const urlPath = new URL(fullUrl).pathname;
|
|
568
|
-
const filename = decodeURIComponent(urlPath.split("/").pop() ?? "file");
|
|
776
|
+
const filename = contentDispositionFilename(res.headers.get("content-disposition")) ?? decodeURIComponent(urlPath.split("/").pop() ?? "file");
|
|
569
777
|
return { buffer, contentType, filename };
|
|
570
778
|
}
|
|
571
779
|
// ── Workspace ─────────────────────────────────────────────────────────
|
|
@@ -693,6 +901,21 @@ var ShadowClient = class {
|
|
|
693
901
|
async unlinkOAuthAccount(accountId) {
|
|
694
902
|
return this.request(`/api/auth/oauth/accounts/${accountId}`, { method: "DELETE" });
|
|
695
903
|
}
|
|
904
|
+
async changePassword(data) {
|
|
905
|
+
return this.request("/api/auth/password", {
|
|
906
|
+
method: "PUT",
|
|
907
|
+
body: JSON.stringify(data)
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
async getDashboard() {
|
|
911
|
+
return this.request("/api/auth/dashboard");
|
|
912
|
+
}
|
|
913
|
+
async loginWithGoogleIdToken(idToken) {
|
|
914
|
+
return this.request("/api/auth/google/id-token", {
|
|
915
|
+
method: "POST",
|
|
916
|
+
body: JSON.stringify({ idToken })
|
|
917
|
+
});
|
|
918
|
+
}
|
|
696
919
|
// ── Friendships ───────────────────────────────────────────────────────
|
|
697
920
|
async sendFriendRequest(username) {
|
|
698
921
|
return this.request("/api/friends/request", {
|
|
@@ -737,6 +960,27 @@ var ShadowClient = class {
|
|
|
737
960
|
body: JSON.stringify(data)
|
|
738
961
|
});
|
|
739
962
|
}
|
|
963
|
+
async getNotificationChannelPreferences() {
|
|
964
|
+
return this.request("/api/notifications/channel-preferences");
|
|
965
|
+
}
|
|
966
|
+
async updateNotificationChannelPreference(data) {
|
|
967
|
+
return this.request("/api/notifications/channel-preferences", {
|
|
968
|
+
method: "PATCH",
|
|
969
|
+
body: JSON.stringify(data)
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
async registerPushToken(data) {
|
|
973
|
+
return this.request("/api/notifications/push-tokens", {
|
|
974
|
+
method: "POST",
|
|
975
|
+
body: JSON.stringify(data)
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
async registerWebPushSubscription(data) {
|
|
979
|
+
return this.request("/api/notifications/web-push-subscriptions", {
|
|
980
|
+
method: "POST",
|
|
981
|
+
body: JSON.stringify(data)
|
|
982
|
+
});
|
|
983
|
+
}
|
|
740
984
|
// ── OAuth Apps ────────────────────────────────────────────────────────
|
|
741
985
|
async createOAuthApp(data) {
|
|
742
986
|
return this.request("/api/oauth/apps", {
|
|
@@ -857,6 +1101,133 @@ var ShadowClient = class {
|
|
|
857
1101
|
async getShop(serverId) {
|
|
858
1102
|
return this.request(`/api/servers/${serverId}/shop`);
|
|
859
1103
|
}
|
|
1104
|
+
async getMyShop() {
|
|
1105
|
+
return this.request("/api/me/shop");
|
|
1106
|
+
}
|
|
1107
|
+
async upsertMyShop(data) {
|
|
1108
|
+
return this.request("/api/me/shop", {
|
|
1109
|
+
method: "POST",
|
|
1110
|
+
body: JSON.stringify(data)
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
async getUserShop(userId) {
|
|
1114
|
+
return this.request(`/api/users/${userId}/shop`);
|
|
1115
|
+
}
|
|
1116
|
+
async getManagedUserShop(userId) {
|
|
1117
|
+
return this.request(`/api/users/${userId}/shop/manage`);
|
|
1118
|
+
}
|
|
1119
|
+
async upsertManagedUserShop(userId, data) {
|
|
1120
|
+
return this.request(`/api/users/${userId}/shop/manage`, {
|
|
1121
|
+
method: "POST",
|
|
1122
|
+
body: JSON.stringify(data)
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
async getShopById(shopId) {
|
|
1126
|
+
return this.request(`/api/shops/${shopId}`);
|
|
1127
|
+
}
|
|
1128
|
+
async listShopProducts(shopId, params) {
|
|
1129
|
+
const qs = new URLSearchParams();
|
|
1130
|
+
if (params?.keyword) qs.set("keyword", params.keyword);
|
|
1131
|
+
if (params?.limit) qs.set("limit", String(params.limit));
|
|
1132
|
+
if (params?.offset) qs.set("offset", String(params.offset));
|
|
1133
|
+
return this.request(`/api/shops/${shopId}/products?${qs}`);
|
|
1134
|
+
}
|
|
1135
|
+
async getScopeNeutralProduct(productId) {
|
|
1136
|
+
return this.request(`/api/products/${productId}`);
|
|
1137
|
+
}
|
|
1138
|
+
async getShopProduct(shopId, productId) {
|
|
1139
|
+
return this.request(`/api/shops/${shopId}/products/${productId}`);
|
|
1140
|
+
}
|
|
1141
|
+
async createShopProduct(shopId, data) {
|
|
1142
|
+
return this.request(`/api/shops/${shopId}/products`, {
|
|
1143
|
+
method: "POST",
|
|
1144
|
+
body: JSON.stringify(data)
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
async updateShopProduct(shopId, productId, data) {
|
|
1148
|
+
return this.request(`/api/shops/${shopId}/products/${productId}`, {
|
|
1149
|
+
method: "PUT",
|
|
1150
|
+
body: JSON.stringify(data)
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
async deleteShopProduct(shopId, productId) {
|
|
1154
|
+
return this.request(`/api/shops/${shopId}/products/${productId}`, { method: "DELETE" });
|
|
1155
|
+
}
|
|
1156
|
+
async purchaseShopProduct(shopId, productId, data) {
|
|
1157
|
+
return this.request(`/api/shops/${shopId}/products/${productId}/purchase`, {
|
|
1158
|
+
method: "POST",
|
|
1159
|
+
body: JSON.stringify(data)
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
async purchaseCommerceOffer(offerId, data) {
|
|
1163
|
+
return this.request(`/api/commerce/offers/${offerId}/purchase`, {
|
|
1164
|
+
method: "POST",
|
|
1165
|
+
body: JSON.stringify(data)
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
async getCommerceOfferCheckoutPreview(offerId, params) {
|
|
1169
|
+
const qs = new URLSearchParams();
|
|
1170
|
+
if (params?.skuId) qs.set("skuId", params.skuId);
|
|
1171
|
+
if (params?.viewerUserId) qs.set("viewerUserId", params.viewerUserId);
|
|
1172
|
+
const suffix = qs.toString() ? `?${qs}` : "";
|
|
1173
|
+
return this.request(`/api/commerce/offers/${offerId}/checkout-preview${suffix}`);
|
|
1174
|
+
}
|
|
1175
|
+
async createCommerceOffer(shopId, data) {
|
|
1176
|
+
return this.request(`/api/shops/${shopId}/offers`, {
|
|
1177
|
+
method: "POST",
|
|
1178
|
+
body: JSON.stringify(data)
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
async listCommerceOffers(shopId, params) {
|
|
1182
|
+
const qs = new URLSearchParams();
|
|
1183
|
+
if (params?.keyword) qs.set("keyword", params.keyword);
|
|
1184
|
+
if (params?.limit) qs.set("limit", String(params.limit));
|
|
1185
|
+
return this.request(`/api/shops/${shopId}/offers?${qs}`);
|
|
1186
|
+
}
|
|
1187
|
+
async createCommerceDeliverable(shopId, offerId, data) {
|
|
1188
|
+
return this.request(`/api/shops/${shopId}/offers/${offerId}/deliverables`, {
|
|
1189
|
+
method: "POST",
|
|
1190
|
+
body: JSON.stringify(data)
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
async listShopAssetDefinitions(shopId) {
|
|
1194
|
+
return this.request(`/api/shops/${shopId}/assets`);
|
|
1195
|
+
}
|
|
1196
|
+
async createShopAssetDefinition(shopId, data) {
|
|
1197
|
+
return this.request(`/api/shops/${shopId}/assets`, {
|
|
1198
|
+
method: "POST",
|
|
1199
|
+
body: JSON.stringify(data)
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
async updateShopAssetDefinition(shopId, assetDefinitionId, data) {
|
|
1203
|
+
return this.request(`/api/shops/${shopId}/assets/${assetDefinitionId}`, {
|
|
1204
|
+
method: "PATCH",
|
|
1205
|
+
body: JSON.stringify(data)
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
async purchaseMessageCommerceCard(messageId, cardId, data) {
|
|
1209
|
+
return this.request(`/api/messages/${messageId}/commerce-cards/${cardId}/purchase`, {
|
|
1210
|
+
method: "POST",
|
|
1211
|
+
body: JSON.stringify(data)
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
async listCommerceProductCards(params) {
|
|
1215
|
+
const qs = new URLSearchParams();
|
|
1216
|
+
qs.set("target", params.target);
|
|
1217
|
+
qs.set("channelId", params.channelId);
|
|
1218
|
+
if (params.keyword) qs.set("keyword", params.keyword);
|
|
1219
|
+
if (params.limit) qs.set("limit", String(params.limit));
|
|
1220
|
+
return this.request(`/api/commerce/product-picker?${qs}`);
|
|
1221
|
+
}
|
|
1222
|
+
async openPaidFile(fileId) {
|
|
1223
|
+
return this.request(`/api/paid-files/${fileId}/open`, { method: "POST" });
|
|
1224
|
+
}
|
|
1225
|
+
async listShopEntitlements(shopId, params) {
|
|
1226
|
+
const qs = new URLSearchParams();
|
|
1227
|
+
if (params?.limit) qs.set("limit", String(params.limit));
|
|
1228
|
+
if (params?.offset) qs.set("offset", String(params.offset));
|
|
1229
|
+
return this.request(`/api/shops/${shopId}/entitlements?${qs}`);
|
|
1230
|
+
}
|
|
860
1231
|
async updateShop(serverId, data) {
|
|
861
1232
|
return this.request(`/api/servers/${serverId}/shop`, {
|
|
862
1233
|
method: "PUT",
|
|
@@ -931,7 +1302,7 @@ var ShadowClient = class {
|
|
|
931
1302
|
async createOrder(serverId, data) {
|
|
932
1303
|
return this.request(`/api/servers/${serverId}/shop/orders`, {
|
|
933
1304
|
method: "POST",
|
|
934
|
-
body: JSON.stringify(data
|
|
1305
|
+
body: JSON.stringify(data)
|
|
935
1306
|
});
|
|
936
1307
|
}
|
|
937
1308
|
async listOrders(serverId) {
|
|
@@ -972,18 +1343,232 @@ var ShadowClient = class {
|
|
|
972
1343
|
async getWallet() {
|
|
973
1344
|
return this.request("/api/wallet");
|
|
974
1345
|
}
|
|
975
|
-
async topUpWallet(
|
|
976
|
-
|
|
1346
|
+
async topUpWallet(_amount) {
|
|
1347
|
+
throw new Error(
|
|
1348
|
+
"Public wallet top-up is disabled. Use a verified payment flow, refund, settlement, or admin grant."
|
|
1349
|
+
);
|
|
1350
|
+
}
|
|
1351
|
+
async getWalletTransactions(params) {
|
|
1352
|
+
const qs = new URLSearchParams();
|
|
1353
|
+
if (params?.audience) qs.set("audience", params.audience);
|
|
1354
|
+
if (params?.direction) qs.set("direction", params.direction);
|
|
1355
|
+
if (params?.limit != null) qs.set("limit", String(params.limit));
|
|
1356
|
+
if (params?.offset != null) qs.set("offset", String(params.offset));
|
|
1357
|
+
const suffix = qs.toString() ? `?${qs}` : "";
|
|
1358
|
+
return this.request(`/api/wallet/transactions${suffix}`);
|
|
1359
|
+
}
|
|
1360
|
+
// ── Community Economy ────────────────────────────────────────────────
|
|
1361
|
+
async listCommunityAssets() {
|
|
1362
|
+
return this.request("/api/economy/assets");
|
|
1363
|
+
}
|
|
1364
|
+
async getCommunityAsset(grantId) {
|
|
1365
|
+
return this.request(`/api/economy/assets/${grantId}`);
|
|
1366
|
+
}
|
|
1367
|
+
async consumeCommunityAsset(grantId, data) {
|
|
1368
|
+
return this.request(`/api/economy/assets/${grantId}/consume`, {
|
|
1369
|
+
method: "POST",
|
|
1370
|
+
body: JSON.stringify(data)
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
async lockCommunityAsset(grantId, data) {
|
|
1374
|
+
return this.request(`/api/economy/assets/${grantId}/lock`, {
|
|
1375
|
+
method: "POST",
|
|
1376
|
+
body: JSON.stringify(data)
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
async unlockCommunityAsset(grantId, data) {
|
|
1380
|
+
return this.request(`/api/economy/assets/${grantId}/unlock`, {
|
|
1381
|
+
method: "POST",
|
|
1382
|
+
body: JSON.stringify(data)
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
async revokeCommunityAsset(grantId, data) {
|
|
1386
|
+
return this.request(`/api/economy/assets/${grantId}/revoke`, {
|
|
1387
|
+
method: "POST",
|
|
1388
|
+
body: JSON.stringify(data)
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
async sendTip(data) {
|
|
1392
|
+
return this.request("/api/economy/tips", {
|
|
1393
|
+
method: "POST",
|
|
1394
|
+
body: JSON.stringify(data)
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
async listTips() {
|
|
1398
|
+
return this.request("/api/economy/tips");
|
|
1399
|
+
}
|
|
1400
|
+
async sendGift(data) {
|
|
1401
|
+
return this.request("/api/economy/gifts", {
|
|
1402
|
+
method: "POST",
|
|
1403
|
+
body: JSON.stringify(data)
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
async listGifts() {
|
|
1407
|
+
return this.request("/api/economy/gifts");
|
|
1408
|
+
}
|
|
1409
|
+
async listSettlements(params) {
|
|
1410
|
+
const qs = new URLSearchParams();
|
|
1411
|
+
if (params?.limit != null) qs.set("limit", String(params.limit));
|
|
1412
|
+
if (params?.offset != null) qs.set("offset", String(params.offset));
|
|
1413
|
+
const suffix = qs.toString() ? `?${qs}` : "";
|
|
1414
|
+
return this.request(`/api/economy/settlements${suffix}`);
|
|
1415
|
+
}
|
|
1416
|
+
async settleAvailableSettlements() {
|
|
1417
|
+
return this.request("/api/economy/settlements/settle", { method: "POST" });
|
|
1418
|
+
}
|
|
1419
|
+
// ── Cloud SaaS DIY Generation ───────────────────────────────────────
|
|
1420
|
+
async createDiyCloudRun(data) {
|
|
1421
|
+
return this.request("/api/cloud-saas/diy/runs", {
|
|
1422
|
+
method: "POST",
|
|
1423
|
+
body: JSON.stringify(data)
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
async getDiyCloudRun(runId) {
|
|
1427
|
+
return this.request(`/api/cloud-saas/diy/runs/${encodeURIComponent(runId)}`);
|
|
1428
|
+
}
|
|
1429
|
+
async createDiyCloudFeedbackRun(runId, data) {
|
|
1430
|
+
return this.request(`/api/cloud-saas/diy/runs/${encodeURIComponent(runId)}/feedback`, {
|
|
1431
|
+
method: "POST",
|
|
1432
|
+
body: JSON.stringify(data)
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
async streamDiyCloudRun(runId, options = {}) {
|
|
1436
|
+
const qs = new URLSearchParams();
|
|
1437
|
+
if (options.afterSeq != null) qs.set("afterSeq", String(options.afterSeq));
|
|
1438
|
+
const suffix = qs.toString() ? `?${qs}` : "";
|
|
1439
|
+
return this.requestRaw(
|
|
1440
|
+
`/api/cloud-saas/diy/runs/${encodeURIComponent(runId)}/stream${suffix}`,
|
|
1441
|
+
{
|
|
1442
|
+
headers: { Accept: "text/event-stream" }
|
|
1443
|
+
}
|
|
1444
|
+
);
|
|
1445
|
+
}
|
|
1446
|
+
async cancelDiyCloudRun(runId) {
|
|
1447
|
+
return this.request(`/api/cloud-saas/diy/runs/${encodeURIComponent(runId)}/cancel`, {
|
|
1448
|
+
method: "POST"
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
// ── Cloud SaaS Deployment Runtime ──────────────────────────────────
|
|
1452
|
+
async getCloudDeploymentManifest(deploymentId) {
|
|
1453
|
+
return this.request(`/api/cloud-saas/deployments/${encodeURIComponent(deploymentId)}/manifest`);
|
|
1454
|
+
}
|
|
1455
|
+
async syncCloudDeploymentTemplate(deploymentId, data = {}) {
|
|
1456
|
+
return this.request(
|
|
1457
|
+
`/api/cloud-saas/deployments/${encodeURIComponent(deploymentId)}/template`,
|
|
1458
|
+
{
|
|
1459
|
+
method: "POST",
|
|
1460
|
+
body: JSON.stringify(data)
|
|
1461
|
+
}
|
|
1462
|
+
);
|
|
1463
|
+
}
|
|
1464
|
+
async redeployCloudDeployment(deploymentId, data = {}) {
|
|
1465
|
+
return this.request(
|
|
1466
|
+
`/api/cloud-saas/deployments/${encodeURIComponent(deploymentId)}/redeploy`,
|
|
1467
|
+
{
|
|
1468
|
+
method: "POST",
|
|
1469
|
+
body: JSON.stringify(data)
|
|
1470
|
+
}
|
|
1471
|
+
);
|
|
1472
|
+
}
|
|
1473
|
+
async pauseCloudDeployment(deploymentId, data = {}) {
|
|
1474
|
+
return this.request(`/api/cloud-saas/deployments/${encodeURIComponent(deploymentId)}/pause`, {
|
|
1475
|
+
method: "POST",
|
|
1476
|
+
body: JSON.stringify(data)
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
async resumeCloudDeployment(deploymentId, data = {}) {
|
|
1480
|
+
return this.request(`/api/cloud-saas/deployments/${encodeURIComponent(deploymentId)}/resume`, {
|
|
1481
|
+
method: "POST",
|
|
1482
|
+
body: JSON.stringify(data)
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
async listCloudDeploymentBackups(deploymentId, params = {}) {
|
|
1486
|
+
const qs = new URLSearchParams();
|
|
1487
|
+
if (params.agentId) qs.set("agentId", params.agentId);
|
|
1488
|
+
const suffix = qs.toString() ? `?${qs}` : "";
|
|
1489
|
+
return this.request(
|
|
1490
|
+
`/api/cloud-saas/deployments/${encodeURIComponent(deploymentId)}/backups${suffix}`
|
|
1491
|
+
);
|
|
1492
|
+
}
|
|
1493
|
+
async createCloudDeploymentBackup(deploymentId, data = {}) {
|
|
1494
|
+
return this.request(`/api/cloud-saas/deployments/${encodeURIComponent(deploymentId)}/backups`, {
|
|
977
1495
|
method: "POST",
|
|
978
|
-
body: JSON.stringify(
|
|
1496
|
+
body: JSON.stringify(data)
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
async restoreCloudDeploymentBackup(deploymentId, data = {}) {
|
|
1500
|
+
return this.request(`/api/cloud-saas/deployments/${encodeURIComponent(deploymentId)}/restore`, {
|
|
1501
|
+
method: "POST",
|
|
1502
|
+
body: JSON.stringify(data)
|
|
979
1503
|
});
|
|
980
1504
|
}
|
|
981
|
-
|
|
982
|
-
|
|
1505
|
+
// ── Cloud SaaS Provider Gateway ─────────────────────────────────────
|
|
1506
|
+
async listCloudProviderCatalogs() {
|
|
1507
|
+
return this.request("/api/cloud-saas/provider-catalogs");
|
|
1508
|
+
}
|
|
1509
|
+
async listCloudProviderProfiles() {
|
|
1510
|
+
return this.request("/api/cloud-saas/provider-profiles");
|
|
1511
|
+
}
|
|
1512
|
+
async upsertCloudProviderProfile(data) {
|
|
1513
|
+
return this.request("/api/cloud-saas/provider-profiles", {
|
|
1514
|
+
method: "PUT",
|
|
1515
|
+
body: JSON.stringify(data)
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
async testCloudProviderProfile(profileId) {
|
|
1519
|
+
return this.request(`/api/cloud-saas/provider-profiles/${encodeURIComponent(profileId)}/test`, {
|
|
1520
|
+
method: "POST"
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
async refreshCloudProviderProfileModels(profileId) {
|
|
1524
|
+
return this.request(
|
|
1525
|
+
`/api/cloud-saas/provider-profiles/${encodeURIComponent(profileId)}/models/refresh`,
|
|
1526
|
+
{ method: "POST" }
|
|
1527
|
+
);
|
|
1528
|
+
}
|
|
1529
|
+
async deleteCloudProviderProfile(profileId) {
|
|
1530
|
+
return this.request(`/api/cloud-saas/provider-profiles/${encodeURIComponent(profileId)}`, {
|
|
1531
|
+
method: "DELETE"
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
// ── Recharge (Stripe) ───────────────────────────────────────────────
|
|
1535
|
+
async getRechargeConfig() {
|
|
1536
|
+
return this.request("/api/v1/recharge/config");
|
|
1537
|
+
}
|
|
1538
|
+
async createRechargeIntent(params) {
|
|
1539
|
+
return this.request("/api/v1/recharge/create-intent", {
|
|
1540
|
+
method: "POST",
|
|
1541
|
+
body: JSON.stringify(params)
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
async getRechargeHistory(params) {
|
|
1545
|
+
const qs = new URLSearchParams();
|
|
1546
|
+
if (params?.limit) qs.set("limit", String(params.limit));
|
|
1547
|
+
if (params?.offset) qs.set("offset", String(params.offset));
|
|
1548
|
+
const query = qs.toString();
|
|
1549
|
+
return this.request(`/api/v1/recharge/history${query ? `?${query}` : ""}`);
|
|
1550
|
+
}
|
|
1551
|
+
async confirmRechargePayment(paymentIntentId) {
|
|
1552
|
+
return this.request("/api/v1/recharge/confirm", {
|
|
1553
|
+
method: "POST",
|
|
1554
|
+
body: JSON.stringify({ paymentIntentId })
|
|
1555
|
+
});
|
|
983
1556
|
}
|
|
984
1557
|
async getEntitlements(serverId) {
|
|
985
1558
|
return this.request(`/api/servers/${serverId}/shop/entitlements`);
|
|
986
1559
|
}
|
|
1560
|
+
async getAllEntitlements() {
|
|
1561
|
+
return this.request("/api/entitlements");
|
|
1562
|
+
}
|
|
1563
|
+
async verifyEntitlement(entitlementId) {
|
|
1564
|
+
return this.request(`/api/entitlements/${entitlementId}/verify`);
|
|
1565
|
+
}
|
|
1566
|
+
async cancelEntitlement(entitlementId, reason) {
|
|
1567
|
+
return this.request(`/api/entitlements/${entitlementId}/cancel`, {
|
|
1568
|
+
method: "POST",
|
|
1569
|
+
body: JSON.stringify({ reason })
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
987
1572
|
// ── Task Center ───────────────────────────────────────────────────────
|
|
988
1573
|
async getTaskCenter() {
|
|
989
1574
|
return this.request("/api/tasks");
|
|
@@ -997,41 +1582,126 @@ var ShadowClient = class {
|
|
|
997
1582
|
async getRewardHistory() {
|
|
998
1583
|
return this.request("/api/tasks/rewards");
|
|
999
1584
|
}
|
|
1000
|
-
// ──
|
|
1001
|
-
async
|
|
1585
|
+
// ── API Tokens ────────────────────────────────────────────────────────
|
|
1586
|
+
async createApiToken(data) {
|
|
1587
|
+
return this.request("/api/tokens", {
|
|
1588
|
+
method: "POST",
|
|
1589
|
+
body: JSON.stringify(data)
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
async listApiTokens() {
|
|
1593
|
+
return this.request("/api/tokens");
|
|
1594
|
+
}
|
|
1595
|
+
async deleteApiToken(tokenId) {
|
|
1596
|
+
return this.request(`/api/tokens/${tokenId}`, { method: "DELETE" });
|
|
1597
|
+
}
|
|
1598
|
+
// ── Discover ──────────────────────────────────────────────────────────
|
|
1599
|
+
async discoverFeed(params) {
|
|
1002
1600
|
const qs = new URLSearchParams();
|
|
1003
|
-
if (params?.
|
|
1601
|
+
if (params?.type) qs.set("type", params.type);
|
|
1004
1602
|
if (params?.limit) qs.set("limit", String(params.limit));
|
|
1005
1603
|
if (params?.offset) qs.set("offset", String(params.offset));
|
|
1006
|
-
return this.request(`/api/
|
|
1604
|
+
return this.request(`/api/discover/feed?${qs}`);
|
|
1007
1605
|
}
|
|
1008
|
-
async
|
|
1009
|
-
|
|
1606
|
+
async discoverSearch(params) {
|
|
1607
|
+
const qs = new URLSearchParams({ q: params.q });
|
|
1608
|
+
if (params?.type) qs.set("type", params.type);
|
|
1609
|
+
if (params?.limit) qs.set("limit", String(params.limit));
|
|
1610
|
+
return this.request(`/api/discover/search?${qs}`);
|
|
1010
1611
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1612
|
+
// ── Voice Enhance ─────────────────────────────────────────────────────
|
|
1613
|
+
async enhanceVoice(data) {
|
|
1614
|
+
return this.request("/api/voice/enhance", {
|
|
1615
|
+
method: "POST",
|
|
1616
|
+
body: JSON.stringify(data)
|
|
1617
|
+
});
|
|
1013
1618
|
}
|
|
1014
|
-
async
|
|
1015
|
-
|
|
1619
|
+
async enhanceVoiceQuery(params) {
|
|
1620
|
+
const qs = new URLSearchParams({ transcript: params.transcript });
|
|
1621
|
+
if (params.language) qs.set("language", params.language);
|
|
1622
|
+
if (params.enableSelfCorrection !== void 0)
|
|
1623
|
+
qs.set("enableSelfCorrection", String(params.enableSelfCorrection));
|
|
1624
|
+
if (params.enableListFormatting !== void 0)
|
|
1625
|
+
qs.set("enableListFormatting", String(params.enableListFormatting));
|
|
1626
|
+
if (params.enableFillerRemoval !== void 0)
|
|
1627
|
+
qs.set("enableFillerRemoval", String(params.enableFillerRemoval));
|
|
1628
|
+
if (params.enableToneAdjustment !== void 0)
|
|
1629
|
+
qs.set("enableToneAdjustment", String(params.enableToneAdjustment));
|
|
1630
|
+
if (params.targetTone) qs.set("targetTone", params.targetTone);
|
|
1631
|
+
return this.request(`/api/voice/enhance?${qs}`);
|
|
1632
|
+
}
|
|
1633
|
+
async getVoiceConfig() {
|
|
1634
|
+
return this.request("/api/voice/config");
|
|
1635
|
+
}
|
|
1636
|
+
async updateVoiceConfig(data) {
|
|
1637
|
+
return this.request("/api/voice/config", {
|
|
1016
1638
|
method: "POST",
|
|
1017
1639
|
body: JSON.stringify(data)
|
|
1018
1640
|
});
|
|
1019
1641
|
}
|
|
1020
|
-
async
|
|
1021
|
-
return this.request(
|
|
1022
|
-
|
|
1642
|
+
async voiceHealthCheck() {
|
|
1643
|
+
return this.request("/api/voice/health");
|
|
1644
|
+
}
|
|
1645
|
+
// ── Profile Comments ──────────────────────────────────────────────────
|
|
1646
|
+
async getProfileComments(profileUserId, params) {
|
|
1647
|
+
const qs = new URLSearchParams();
|
|
1648
|
+
if (params?.limit) qs.set("limit", String(params.limit));
|
|
1649
|
+
if (params?.offset) qs.set("offset", String(params.offset));
|
|
1650
|
+
return this.request(`/api/profile-comments/${profileUserId}?${qs}`);
|
|
1651
|
+
}
|
|
1652
|
+
async getProfileCommentStats(profileUserId) {
|
|
1653
|
+
return this.request(`/api/profile-comments/${profileUserId}/stats`);
|
|
1654
|
+
}
|
|
1655
|
+
async getCommentReplies(parentId, params) {
|
|
1656
|
+
const qs = new URLSearchParams();
|
|
1657
|
+
if (params?.limit) qs.set("limit", String(params.limit));
|
|
1658
|
+
if (params?.offset) qs.set("offset", String(params.offset));
|
|
1659
|
+
return this.request(`/api/profile-comments/replies/${parentId}?${qs}`);
|
|
1660
|
+
}
|
|
1661
|
+
async createProfileComment(data) {
|
|
1662
|
+
return this.request("/api/profile-comments", {
|
|
1663
|
+
method: "POST",
|
|
1023
1664
|
body: JSON.stringify(data)
|
|
1024
1665
|
});
|
|
1025
1666
|
}
|
|
1026
|
-
async
|
|
1027
|
-
return this.request(`/api/
|
|
1667
|
+
async deleteProfileComment(commentId) {
|
|
1668
|
+
return this.request(`/api/profile-comments/${commentId}`, { method: "DELETE" });
|
|
1028
1669
|
}
|
|
1029
|
-
async
|
|
1030
|
-
return this.request(`/api/
|
|
1670
|
+
async addProfileCommentReaction(commentId, emoji) {
|
|
1671
|
+
return this.request(`/api/profile-comments/${commentId}/reactions`, {
|
|
1672
|
+
method: "POST",
|
|
1673
|
+
body: JSON.stringify({ emoji })
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
async removeProfileCommentReaction(commentId, emoji) {
|
|
1677
|
+
return this.request(`/api/profile-comments/${commentId}/reactions`, {
|
|
1678
|
+
method: "DELETE",
|
|
1679
|
+
body: JSON.stringify({ emoji })
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
// ── Agent Dashboard ───────────────────────────────────────────────────
|
|
1683
|
+
async getAgentDashboard(agentId) {
|
|
1684
|
+
return this.request(`/api/agents/${agentId}/dashboard`);
|
|
1685
|
+
}
|
|
1686
|
+
async addAgentDashboardEvent(agentId, data) {
|
|
1687
|
+
return this.request(`/api/agents/${agentId}/dashboard/events`, {
|
|
1031
1688
|
method: "POST",
|
|
1032
1689
|
body: JSON.stringify(data)
|
|
1033
1690
|
});
|
|
1034
1691
|
}
|
|
1692
|
+
// ── Channel Archive ───────────────────────────────────────────────────
|
|
1693
|
+
async archiveChannel(channelId, reason) {
|
|
1694
|
+
return this.request(`/api/channels/${channelId}/archive`, {
|
|
1695
|
+
method: "POST",
|
|
1696
|
+
body: JSON.stringify(reason ? { reason } : {})
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1699
|
+
async unarchiveChannel(channelId) {
|
|
1700
|
+
return this.request(`/api/channels/${channelId}/unarchive`, { method: "POST" });
|
|
1701
|
+
}
|
|
1702
|
+
async getArchivedChannels(serverId) {
|
|
1703
|
+
return this.request(`/api/servers/${serverId}/channels/archived`);
|
|
1704
|
+
}
|
|
1035
1705
|
};
|
|
1036
1706
|
|
|
1037
1707
|
// src/constants.ts
|
|
@@ -1153,9 +1823,9 @@ var ShadowSocket = class {
|
|
|
1153
1823
|
sendMessage(data) {
|
|
1154
1824
|
this.socket.emit("message:send", data);
|
|
1155
1825
|
}
|
|
1156
|
-
/** Send a typing indicator */
|
|
1157
|
-
sendTyping(channelId) {
|
|
1158
|
-
this.socket.emit("message:typing", { channelId });
|
|
1826
|
+
/** Send or clear a typing indicator */
|
|
1827
|
+
sendTyping(channelId, typing = true) {
|
|
1828
|
+
this.socket.emit("message:typing", { channelId, typing });
|
|
1159
1829
|
}
|
|
1160
1830
|
/** Update user presence status */
|
|
1161
1831
|
updatePresence(status) {
|
|
@@ -1165,23 +1835,6 @@ var ShadowSocket = class {
|
|
|
1165
1835
|
updateActivity(channelId, activity) {
|
|
1166
1836
|
this.socket.emit("presence:activity", { channelId, activity });
|
|
1167
1837
|
}
|
|
1168
|
-
// ── DM actions ────────────────────────────────────────────────────────
|
|
1169
|
-
/** Join a DM channel room */
|
|
1170
|
-
joinDmChannel(dmChannelId) {
|
|
1171
|
-
this.socket.emit("dm:join", { dmChannelId });
|
|
1172
|
-
}
|
|
1173
|
-
/** Leave a DM channel room */
|
|
1174
|
-
leaveDmChannel(dmChannelId) {
|
|
1175
|
-
this.socket.emit("dm:leave", { dmChannelId });
|
|
1176
|
-
}
|
|
1177
|
-
/** Send a DM message via WebSocket */
|
|
1178
|
-
sendDmMessage(data) {
|
|
1179
|
-
this.socket.emit("dm:send", data);
|
|
1180
|
-
}
|
|
1181
|
-
/** Send a DM typing indicator */
|
|
1182
|
-
sendDmTyping(dmChannelId) {
|
|
1183
|
-
this.socket.emit("dm:typing", { dmChannelId });
|
|
1184
|
-
}
|
|
1185
1838
|
};
|
|
1186
1839
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1187
1840
|
0 && (module.exports = {
|