@shadowob/sdk 1.1.3 → 1.1.4
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 +155 -8
- package/dist/index.d.cts +262 -9
- package/dist/index.d.ts +262 -9
- package/dist/index.js +155 -8
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -87,12 +87,13 @@ var ShadowClient = class {
|
|
|
87
87
|
const url = `${this.baseUrl}${path}`;
|
|
88
88
|
const controller = new AbortController();
|
|
89
89
|
const timeout = setTimeout(() => controller.abort(), 6e4);
|
|
90
|
+
const isFormData = init?.body instanceof FormData;
|
|
90
91
|
try {
|
|
91
92
|
const res = await fetch(url, {
|
|
92
93
|
...init,
|
|
93
94
|
signal: init?.signal ?? controller.signal,
|
|
94
95
|
headers: {
|
|
95
|
-
"Content-Type": "application/json",
|
|
96
|
+
...!isFormData ? { "Content-Type": "application/json" } : {},
|
|
96
97
|
Authorization: `Bearer ${this.token}`,
|
|
97
98
|
...init?.headers
|
|
98
99
|
}
|
|
@@ -217,8 +218,11 @@ var ShadowClient = class {
|
|
|
217
218
|
});
|
|
218
219
|
}
|
|
219
220
|
// ── Agents ────────────────────────────────────────────────────────────
|
|
220
|
-
async listAgents() {
|
|
221
|
-
|
|
221
|
+
async listAgents(options) {
|
|
222
|
+
const params = new URLSearchParams();
|
|
223
|
+
if (options?.includeRentals) params.set("includeRentals", "true");
|
|
224
|
+
const query = params.toString();
|
|
225
|
+
return this.request(`/api/agents${query ? `?${query}` : ""}`);
|
|
222
226
|
}
|
|
223
227
|
async createAgent(data) {
|
|
224
228
|
return this.request("/api/agents", {
|
|
@@ -334,15 +338,113 @@ var ShadowClient = class {
|
|
|
334
338
|
async getServerAccess(serverIdOrSlug) {
|
|
335
339
|
return this.request(`/api/servers/${serverIdOrSlug}/access`);
|
|
336
340
|
}
|
|
341
|
+
// ── Server App Integrations ───────────────────────────────────────────
|
|
342
|
+
async listServerApps(serverIdOrSlug) {
|
|
343
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps`);
|
|
344
|
+
}
|
|
345
|
+
async listServerAppCatalog(serverIdOrSlug) {
|
|
346
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps/catalog`);
|
|
347
|
+
}
|
|
348
|
+
async discoverServerApp(serverIdOrSlug, data) {
|
|
349
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps/discover`, {
|
|
350
|
+
method: "POST",
|
|
351
|
+
body: JSON.stringify(data)
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
async installServerApp(serverIdOrSlug, data) {
|
|
355
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps`, {
|
|
356
|
+
method: "POST",
|
|
357
|
+
body: JSON.stringify(data)
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
async installServerAppFromCatalog(serverIdOrSlug, catalogEntryId, data = {}) {
|
|
361
|
+
return this.request(
|
|
362
|
+
`/api/servers/${serverIdOrSlug}/apps/catalog/${encodeURIComponent(catalogEntryId)}/install`,
|
|
363
|
+
{
|
|
364
|
+
method: "POST",
|
|
365
|
+
body: JSON.stringify(data)
|
|
366
|
+
}
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
async getServerApp(serverIdOrSlug, appKey) {
|
|
370
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}`);
|
|
371
|
+
}
|
|
372
|
+
async deleteServerApp(serverIdOrSlug, appKey) {
|
|
373
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}`, {
|
|
374
|
+
method: "DELETE"
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
async grantServerAppToBuddy(serverIdOrSlug, appKey, data) {
|
|
378
|
+
return this.request(
|
|
379
|
+
`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}/grants`,
|
|
380
|
+
{
|
|
381
|
+
method: "POST",
|
|
382
|
+
body: JSON.stringify(data)
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
async getServerAppSkills(serverIdOrSlug, appKey) {
|
|
387
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}/skills`);
|
|
388
|
+
}
|
|
389
|
+
async createServerAppLaunch(serverIdOrSlug, appKey) {
|
|
390
|
+
return this.request(
|
|
391
|
+
`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}/launch`,
|
|
392
|
+
{
|
|
393
|
+
method: "POST"
|
|
394
|
+
}
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
async introspectServerAppToken(serverIdOrSlug, appKey, token) {
|
|
398
|
+
const url = `${this.baseUrl}/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(
|
|
399
|
+
appKey
|
|
400
|
+
)}/oauth/introspect`;
|
|
401
|
+
const res = await fetch(url, {
|
|
402
|
+
method: "POST",
|
|
403
|
+
headers: {
|
|
404
|
+
Authorization: `Bearer ${token}`,
|
|
405
|
+
"Content-Type": "application/json"
|
|
406
|
+
},
|
|
407
|
+
body: JSON.stringify({ token })
|
|
408
|
+
});
|
|
409
|
+
if (!res.ok) {
|
|
410
|
+
const body = await res.text().catch(() => "");
|
|
411
|
+
const message = sanitizeErrorBody(body);
|
|
412
|
+
throw new Error(`Shadow API POST /oauth/introspect failed (${res.status}): ${message}`);
|
|
413
|
+
}
|
|
414
|
+
return await res.json();
|
|
415
|
+
}
|
|
416
|
+
async callServerAppCommand(serverIdOrSlug, appKey, commandName, data) {
|
|
417
|
+
return this.request(
|
|
418
|
+
`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}/commands/${encodeURIComponent(
|
|
419
|
+
commandName
|
|
420
|
+
)}`,
|
|
421
|
+
{
|
|
422
|
+
method: "POST",
|
|
423
|
+
body: JSON.stringify(data ?? {})
|
|
424
|
+
}
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
async callServerAppCommandMultipart(serverIdOrSlug, appKey, commandName, data) {
|
|
428
|
+
const form = new FormData();
|
|
429
|
+
form.set("input", JSON.stringify(data.input ?? {}));
|
|
430
|
+
if (data.channelId) form.set("channelId", data.channelId);
|
|
431
|
+
form.set(data.field ?? "file", data.file, data.filename);
|
|
432
|
+
return this.request(
|
|
433
|
+
`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}/commands/${encodeURIComponent(
|
|
434
|
+
commandName
|
|
435
|
+
)}`,
|
|
436
|
+
{
|
|
437
|
+
method: "POST",
|
|
438
|
+
body: form
|
|
439
|
+
}
|
|
440
|
+
);
|
|
441
|
+
}
|
|
337
442
|
async updateServer(serverIdOrSlug, data) {
|
|
338
443
|
return this.request(`/api/servers/${serverIdOrSlug}`, {
|
|
339
444
|
method: "PATCH",
|
|
340
445
|
body: JSON.stringify(data)
|
|
341
446
|
});
|
|
342
447
|
}
|
|
343
|
-
async updateServerHomepage(serverIdOrSlug, homepageHtml) {
|
|
344
|
-
return this.updateServer(serverIdOrSlug, { homepageHtml });
|
|
345
|
-
}
|
|
346
448
|
async deleteServer(serverId) {
|
|
347
449
|
return this.request(`/api/servers/${serverId}`, { method: "DELETE" });
|
|
348
450
|
}
|
|
@@ -407,6 +509,14 @@ var ShadowClient = class {
|
|
|
407
509
|
const ch = await this.request(`/api/channels/${channelId}`);
|
|
408
510
|
return { ...ch, description: ch.topic };
|
|
409
511
|
}
|
|
512
|
+
async getChannelBootstrap(channelId, options) {
|
|
513
|
+
const params = new URLSearchParams();
|
|
514
|
+
if (options?.messagesLimit) params.set("messagesLimit", String(options.messagesLimit));
|
|
515
|
+
const query = params.toString();
|
|
516
|
+
return this.request(
|
|
517
|
+
`/api/channels/${channelId}/bootstrap${query ? `?${query}` : ""}`
|
|
518
|
+
);
|
|
519
|
+
}
|
|
410
520
|
async getChannelAccess(channelId) {
|
|
411
521
|
return this.request(`/api/channels/${channelId}/access`);
|
|
412
522
|
}
|
|
@@ -670,9 +780,19 @@ var ShadowClient = class {
|
|
|
670
780
|
return res.json();
|
|
671
781
|
}
|
|
672
782
|
async resolveAttachmentMediaUrl(attachmentId, options) {
|
|
673
|
-
const
|
|
783
|
+
const params = new URLSearchParams();
|
|
784
|
+
params.set("disposition", options?.disposition ?? "inline");
|
|
785
|
+
if (options?.variant) params.set("variant", options.variant);
|
|
786
|
+
return this.request(
|
|
787
|
+
`/api/attachments/${attachmentId}/media-url?${params}`
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
async resolveWorkspaceMediaUrl(serverId, fileId, options) {
|
|
791
|
+
const params = new URLSearchParams();
|
|
792
|
+
params.set("disposition", options?.disposition ?? "inline");
|
|
793
|
+
if (options?.contentRef) params.set("contentRef", options.contentRef);
|
|
674
794
|
return this.request(
|
|
675
|
-
`/api/
|
|
795
|
+
`/api/servers/${serverId}/workspace/files/${fileId}/media-url?${params}`
|
|
676
796
|
);
|
|
677
797
|
}
|
|
678
798
|
/**
|
|
@@ -898,9 +1018,21 @@ var ShadowClient = class {
|
|
|
898
1018
|
async listOAuthAccounts() {
|
|
899
1019
|
return this.request("/api/auth/oauth/accounts");
|
|
900
1020
|
}
|
|
1021
|
+
async createOAuthConnectUrl(provider, redirect) {
|
|
1022
|
+
return this.request(`/api/auth/oauth/${provider}/link`, {
|
|
1023
|
+
method: "POST",
|
|
1024
|
+
body: JSON.stringify({ redirect })
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
901
1027
|
async unlinkOAuthAccount(accountId) {
|
|
902
1028
|
return this.request(`/api/auth/oauth/accounts/${accountId}`, { method: "DELETE" });
|
|
903
1029
|
}
|
|
1030
|
+
async listAuthSessions() {
|
|
1031
|
+
return this.request("/api/auth/sessions");
|
|
1032
|
+
}
|
|
1033
|
+
async revokeAuthSession(sessionId) {
|
|
1034
|
+
return this.request(`/api/auth/sessions/${sessionId}`, { method: "DELETE" });
|
|
1035
|
+
}
|
|
904
1036
|
async changePassword(data) {
|
|
905
1037
|
return this.request("/api/auth/password", {
|
|
906
1038
|
method: "PUT",
|
|
@@ -1028,6 +1160,21 @@ var ShadowClient = class {
|
|
|
1028
1160
|
body: JSON.stringify({ appId })
|
|
1029
1161
|
});
|
|
1030
1162
|
}
|
|
1163
|
+
async sendOAuthChannelMessage(channelId, content, opts) {
|
|
1164
|
+
return this.request(`/api/oauth/channels/${channelId}/messages`, {
|
|
1165
|
+
method: "POST",
|
|
1166
|
+
body: JSON.stringify({
|
|
1167
|
+
content,
|
|
1168
|
+
...opts?.metadata ? { metadata: opts.metadata } : {}
|
|
1169
|
+
})
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
async sendOAuthBuddyMessage(buddyId, data) {
|
|
1173
|
+
return this.request(`/api/oauth/buddies/${buddyId}/messages`, {
|
|
1174
|
+
method: "POST",
|
|
1175
|
+
body: JSON.stringify(data)
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1031
1178
|
// ── Marketplace / Rentals ─────────────────────────────────────────────
|
|
1032
1179
|
async browseListings(params) {
|
|
1033
1180
|
const qs = new URLSearchParams();
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessageMention, MentionSuggestionTrigger, MentionSuggestion } from '@shadowob/shared';
|
|
1
|
+
import { MessageMention, OAuthLinkCard, MentionSuggestionTrigger, MentionSuggestion } from '@shadowob/shared';
|
|
2
2
|
export { CLIENT_EVENTS, ClientEvent, SERVER_EVENTS, ServerEvent } from '@shadowob/shared';
|
|
3
3
|
import { Socket } from 'socket.io-client';
|
|
4
4
|
|
|
@@ -94,6 +94,7 @@ interface ShadowMessageMetadata {
|
|
|
94
94
|
interactiveResponse?: ShadowInteractiveResponse;
|
|
95
95
|
interactiveState?: ShadowInteractiveState;
|
|
96
96
|
commerceCards?: Array<ShadowCommerceProductCard | ShadowCommerceOfferCardInput>;
|
|
97
|
+
oauthLinkCards?: ShadowOAuthLinkCard[];
|
|
97
98
|
[key: string]: unknown;
|
|
98
99
|
}
|
|
99
100
|
interface ShadowCommerceOfferCardInput {
|
|
@@ -102,6 +103,7 @@ interface ShadowCommerceOfferCardInput {
|
|
|
102
103
|
offerId: string;
|
|
103
104
|
}
|
|
104
105
|
type ShadowMessageMention = MessageMention;
|
|
106
|
+
type ShadowOAuthLinkCard = OAuthLinkCard;
|
|
105
107
|
type ShadowMentionSuggestion = MentionSuggestion;
|
|
106
108
|
type ShadowMentionSuggestionTrigger = MentionSuggestionTrigger;
|
|
107
109
|
interface ShadowAttachment {
|
|
@@ -118,6 +120,149 @@ interface ShadowSignedMediaUrl {
|
|
|
118
120
|
url: string;
|
|
119
121
|
expiresAt: string;
|
|
120
122
|
}
|
|
123
|
+
type ShadowMediaVariant = 'avatar' | 'preview' | 'banner';
|
|
124
|
+
type ShadowServerAppAction = 'read' | 'write' | 'manage' | 'delete' | 'generate';
|
|
125
|
+
type ShadowServerAppDataClass = 'public' | 'server-private' | 'channel-private' | 'financial' | 'secret' | 'cloud-secret';
|
|
126
|
+
interface ShadowServerAppCommand {
|
|
127
|
+
name: string;
|
|
128
|
+
title?: string;
|
|
129
|
+
description?: string;
|
|
130
|
+
path: string;
|
|
131
|
+
method?: 'POST';
|
|
132
|
+
input?: 'json' | 'multipart';
|
|
133
|
+
inputSchema?: Record<string, unknown>;
|
|
134
|
+
permission: string;
|
|
135
|
+
action: ShadowServerAppAction;
|
|
136
|
+
dataClass: ShadowServerAppDataClass;
|
|
137
|
+
approvalMode?: 'none' | 'first_time' | 'every_time' | 'policy';
|
|
138
|
+
binary?: {
|
|
139
|
+
supported?: boolean;
|
|
140
|
+
field?: string;
|
|
141
|
+
maxBytes?: number;
|
|
142
|
+
contentTypes?: string[];
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
interface ShadowServerAppManifest {
|
|
146
|
+
schemaVersion: 'shadow.app/1';
|
|
147
|
+
appKey: string;
|
|
148
|
+
name: string;
|
|
149
|
+
description?: string;
|
|
150
|
+
version?: string;
|
|
151
|
+
iconUrl: string;
|
|
152
|
+
iframe?: {
|
|
153
|
+
entry: string;
|
|
154
|
+
allowedOrigins: string[];
|
|
155
|
+
};
|
|
156
|
+
api: {
|
|
157
|
+
baseUrl: string;
|
|
158
|
+
auth?: {
|
|
159
|
+
type: 'oauth2-bearer';
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
commands: ShadowServerAppCommand[];
|
|
163
|
+
skills?: Array<{
|
|
164
|
+
name: string;
|
|
165
|
+
description: string;
|
|
166
|
+
commandHints?: string[];
|
|
167
|
+
}>;
|
|
168
|
+
events?: string[];
|
|
169
|
+
binary?: {
|
|
170
|
+
supported: boolean;
|
|
171
|
+
maxBytes?: number;
|
|
172
|
+
contentTypes?: string[];
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
interface ShadowServerAppIntegration {
|
|
176
|
+
id: string;
|
|
177
|
+
serverId: string;
|
|
178
|
+
appKey: string;
|
|
179
|
+
name: string;
|
|
180
|
+
description?: string | null;
|
|
181
|
+
iconUrl?: string | null;
|
|
182
|
+
manifestUrl?: string | null;
|
|
183
|
+
manifest: ShadowServerAppManifest;
|
|
184
|
+
iframeEntry?: string | null;
|
|
185
|
+
allowedOrigins: string[];
|
|
186
|
+
apiBaseUrl: string;
|
|
187
|
+
status: string;
|
|
188
|
+
installedByUserId: string;
|
|
189
|
+
createdAt: string;
|
|
190
|
+
updatedAt: string;
|
|
191
|
+
}
|
|
192
|
+
interface ShadowServerAppDiscovery {
|
|
193
|
+
manifest: ShadowServerAppManifest;
|
|
194
|
+
installed: ShadowServerAppIntegration | null;
|
|
195
|
+
permissions: Array<{
|
|
196
|
+
name: string;
|
|
197
|
+
title: string;
|
|
198
|
+
description?: string | null;
|
|
199
|
+
permission: string;
|
|
200
|
+
action: ShadowServerAppAction;
|
|
201
|
+
dataClass: ShadowServerAppDataClass;
|
|
202
|
+
approvalMode: 'none' | 'first_time' | 'every_time' | 'policy';
|
|
203
|
+
}>;
|
|
204
|
+
}
|
|
205
|
+
interface ShadowServerAppCatalogEntry {
|
|
206
|
+
id: string;
|
|
207
|
+
appKey: string;
|
|
208
|
+
name: string;
|
|
209
|
+
description?: string | null;
|
|
210
|
+
iconUrl?: string | null;
|
|
211
|
+
manifestUrl?: string | null;
|
|
212
|
+
manifest: ShadowServerAppManifest;
|
|
213
|
+
status: string;
|
|
214
|
+
installed?: ShadowServerAppIntegration | null;
|
|
215
|
+
permissions?: ShadowServerAppDiscovery['permissions'];
|
|
216
|
+
createdAt: string;
|
|
217
|
+
updatedAt: string;
|
|
218
|
+
}
|
|
219
|
+
interface ShadowServerAppLaunchContext {
|
|
220
|
+
serverId: string;
|
|
221
|
+
serverAppId: string;
|
|
222
|
+
appKey: string;
|
|
223
|
+
iframeEntry: string | null;
|
|
224
|
+
allowedOrigins: string[];
|
|
225
|
+
launchToken: string;
|
|
226
|
+
eventStreamPath: string;
|
|
227
|
+
expiresIn: number;
|
|
228
|
+
}
|
|
229
|
+
interface ShadowServerAppSkillDocument {
|
|
230
|
+
appKey: string;
|
|
231
|
+
markdown: string;
|
|
232
|
+
skills: Array<{
|
|
233
|
+
name: string;
|
|
234
|
+
description: string;
|
|
235
|
+
commandHints?: string[];
|
|
236
|
+
}>;
|
|
237
|
+
}
|
|
238
|
+
interface ShadowServerAppTokenIntrospection {
|
|
239
|
+
active: boolean;
|
|
240
|
+
token_type?: 'Bearer';
|
|
241
|
+
iss?: string;
|
|
242
|
+
aud?: string;
|
|
243
|
+
sub?: string;
|
|
244
|
+
scope?: string;
|
|
245
|
+
client_id?: string;
|
|
246
|
+
exp?: number;
|
|
247
|
+
iat?: number;
|
|
248
|
+
shadow?: {
|
|
249
|
+
protocol: 'shadow.app/1';
|
|
250
|
+
serverId: string;
|
|
251
|
+
serverAppId: string;
|
|
252
|
+
appKey: string;
|
|
253
|
+
command?: string;
|
|
254
|
+
actor: {
|
|
255
|
+
kind?: string;
|
|
256
|
+
userId?: string | null;
|
|
257
|
+
buddyAgentId?: string | null;
|
|
258
|
+
ownerId?: string | null;
|
|
259
|
+
};
|
|
260
|
+
channelId?: string | null;
|
|
261
|
+
permission?: string;
|
|
262
|
+
action?: string;
|
|
263
|
+
dataClass?: string;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
121
266
|
interface ShadowChannel {
|
|
122
267
|
id: string;
|
|
123
268
|
name: string;
|
|
@@ -215,7 +360,6 @@ interface ShadowServer {
|
|
|
215
360
|
description: string | null;
|
|
216
361
|
iconUrl: string | null;
|
|
217
362
|
bannerUrl: string | null;
|
|
218
|
-
homepageHtml: string | null;
|
|
219
363
|
isPublic: boolean;
|
|
220
364
|
}
|
|
221
365
|
interface ShadowUser {
|
|
@@ -385,7 +529,15 @@ interface ShadowChannelPolicy {
|
|
|
385
529
|
listen: boolean;
|
|
386
530
|
reply: boolean;
|
|
387
531
|
mentionOnly: boolean;
|
|
388
|
-
config:
|
|
532
|
+
config: ShadowChannelPolicyConfig;
|
|
533
|
+
}
|
|
534
|
+
interface ShadowChannelPolicyConfig {
|
|
535
|
+
allowedTriggerUserIds?: string[];
|
|
536
|
+
triggerUserIds?: string[];
|
|
537
|
+
ownerId?: string;
|
|
538
|
+
activeTenantIds?: string[];
|
|
539
|
+
replyRequiresMention?: boolean;
|
|
540
|
+
[key: string]: unknown;
|
|
389
541
|
}
|
|
390
542
|
interface ShadowSlashCommand {
|
|
391
543
|
name: string;
|
|
@@ -401,6 +553,20 @@ interface ShadowChannelSlashCommand extends ShadowSlashCommand {
|
|
|
401
553
|
botUsername: string;
|
|
402
554
|
botDisplayName?: string | null;
|
|
403
555
|
}
|
|
556
|
+
interface ShadowChannelBootstrap {
|
|
557
|
+
access: ShadowChannelAccess;
|
|
558
|
+
channel: ShadowChannel;
|
|
559
|
+
server: ShadowServer | null;
|
|
560
|
+
channels: ShadowChannel[];
|
|
561
|
+
members: ShadowMember[];
|
|
562
|
+
messages: {
|
|
563
|
+
messages: ShadowMessage[];
|
|
564
|
+
hasMore: boolean;
|
|
565
|
+
};
|
|
566
|
+
slashCommands: {
|
|
567
|
+
commands: ShadowChannelSlashCommand[];
|
|
568
|
+
};
|
|
569
|
+
}
|
|
404
570
|
interface ShadowRemoteChannel {
|
|
405
571
|
id: string;
|
|
406
572
|
name: string;
|
|
@@ -418,6 +584,11 @@ interface ShadowRemoteServer {
|
|
|
418
584
|
interface ShadowRemoteConfig {
|
|
419
585
|
agentId: string;
|
|
420
586
|
botUserId: string;
|
|
587
|
+
ownerId?: string;
|
|
588
|
+
buddyMode?: 'private' | 'shareable';
|
|
589
|
+
allowedServerIds?: string[];
|
|
590
|
+
activeTenantIds?: string[];
|
|
591
|
+
allowedTriggerUserIds?: string[];
|
|
421
592
|
slashCommands?: ShadowSlashCommand[];
|
|
422
593
|
servers: ShadowRemoteServer[];
|
|
423
594
|
}
|
|
@@ -1426,10 +1597,15 @@ declare class ShadowClient {
|
|
|
1426
1597
|
getOfficialModelProxyBilling(): Promise<ShadowModelProxyBilling>;
|
|
1427
1598
|
createOfficialChatCompletion(data: ShadowModelProxyChatCompletionRequest): Promise<ShadowModelProxyChatCompletionResponse>;
|
|
1428
1599
|
createOfficialChatCompletionStream(data: ShadowModelProxyChatCompletionRequest): Promise<Response>;
|
|
1429
|
-
listAgents(
|
|
1600
|
+
listAgents(options?: {
|
|
1601
|
+
includeRentals?: boolean;
|
|
1602
|
+
}): Promise<{
|
|
1430
1603
|
id: string;
|
|
1431
|
-
name
|
|
1604
|
+
name?: string;
|
|
1432
1605
|
status: string;
|
|
1606
|
+
accessRole?: 'owner' | 'tenant';
|
|
1607
|
+
activeContractId?: string | null;
|
|
1608
|
+
config?: Record<string, unknown>;
|
|
1433
1609
|
}[]>;
|
|
1434
1610
|
createAgent(data: {
|
|
1435
1611
|
name: string;
|
|
@@ -1439,6 +1615,8 @@ declare class ShadowClient {
|
|
|
1439
1615
|
avatarUrl?: string | null;
|
|
1440
1616
|
kernelType?: string;
|
|
1441
1617
|
config?: Record<string, unknown>;
|
|
1618
|
+
buddyMode?: 'private' | 'shareable';
|
|
1619
|
+
allowedServerIds?: string[];
|
|
1442
1620
|
}): Promise<{
|
|
1443
1621
|
id: string;
|
|
1444
1622
|
token: string;
|
|
@@ -1454,6 +1632,8 @@ declare class ShadowClient {
|
|
|
1454
1632
|
name?: string;
|
|
1455
1633
|
displayName?: string;
|
|
1456
1634
|
avatarUrl?: string | null;
|
|
1635
|
+
buddyMode?: 'private' | 'shareable';
|
|
1636
|
+
allowedServerIds?: string[];
|
|
1457
1637
|
}): Promise<{
|
|
1458
1638
|
id: string;
|
|
1459
1639
|
name: string;
|
|
@@ -1524,14 +1704,50 @@ declare class ShadowClient {
|
|
|
1524
1704
|
listServers(): Promise<ShadowServer[]>;
|
|
1525
1705
|
getServer(serverIdOrSlug: string): Promise<ShadowServer>;
|
|
1526
1706
|
getServerAccess(serverIdOrSlug: string): Promise<ShadowServerAccess>;
|
|
1707
|
+
listServerApps(serverIdOrSlug: string): Promise<ShadowServerAppIntegration[]>;
|
|
1708
|
+
listServerAppCatalog(serverIdOrSlug: string): Promise<ShadowServerAppCatalogEntry[]>;
|
|
1709
|
+
discoverServerApp(serverIdOrSlug: string, data: {
|
|
1710
|
+
manifestUrl?: string;
|
|
1711
|
+
manifest?: ShadowServerAppManifest;
|
|
1712
|
+
}): Promise<ShadowServerAppDiscovery>;
|
|
1713
|
+
installServerApp(serverIdOrSlug: string, data: {
|
|
1714
|
+
manifestUrl?: string;
|
|
1715
|
+
manifest?: ShadowServerAppManifest;
|
|
1716
|
+
}): Promise<ShadowServerAppIntegration>;
|
|
1717
|
+
installServerAppFromCatalog(serverIdOrSlug: string, catalogEntryId: string, data?: Record<string, never>): Promise<ShadowServerAppIntegration>;
|
|
1718
|
+
getServerApp(serverIdOrSlug: string, appKey: string): Promise<ShadowServerAppIntegration & {
|
|
1719
|
+
grants?: Record<string, unknown>[];
|
|
1720
|
+
}>;
|
|
1721
|
+
deleteServerApp(serverIdOrSlug: string, appKey: string): Promise<{
|
|
1722
|
+
ok: boolean;
|
|
1723
|
+
}>;
|
|
1724
|
+
grantServerAppToBuddy(serverIdOrSlug: string, appKey: string, data: {
|
|
1725
|
+
buddyAgentId: string;
|
|
1726
|
+
permissions: string[];
|
|
1727
|
+
resourceRules?: Record<string, unknown>;
|
|
1728
|
+
approvalMode?: 'none' | 'first_time' | 'every_time' | 'policy';
|
|
1729
|
+
expiresAt?: string;
|
|
1730
|
+
}): Promise<Record<string, unknown>>;
|
|
1731
|
+
getServerAppSkills(serverIdOrSlug: string, appKey: string): Promise<ShadowServerAppSkillDocument>;
|
|
1732
|
+
createServerAppLaunch(serverIdOrSlug: string, appKey: string): Promise<ShadowServerAppLaunchContext>;
|
|
1733
|
+
introspectServerAppToken(serverIdOrSlug: string, appKey: string, token: string): Promise<ShadowServerAppTokenIntrospection>;
|
|
1734
|
+
callServerAppCommand(serverIdOrSlug: string, appKey: string, commandName: string, data?: {
|
|
1735
|
+
input?: unknown;
|
|
1736
|
+
channelId?: string;
|
|
1737
|
+
}): Promise<unknown>;
|
|
1738
|
+
callServerAppCommandMultipart(serverIdOrSlug: string, appKey: string, commandName: string, data: {
|
|
1739
|
+
input?: unknown;
|
|
1740
|
+
channelId?: string;
|
|
1741
|
+
file: Blob;
|
|
1742
|
+
filename: string;
|
|
1743
|
+
field?: string;
|
|
1744
|
+
}): Promise<unknown>;
|
|
1527
1745
|
updateServer(serverIdOrSlug: string, data: {
|
|
1528
1746
|
name?: string;
|
|
1529
1747
|
description?: string | null;
|
|
1530
1748
|
slug?: string | null;
|
|
1531
|
-
homepageHtml?: string | null;
|
|
1532
1749
|
isPublic?: boolean;
|
|
1533
1750
|
}): Promise<ShadowServer>;
|
|
1534
|
-
updateServerHomepage(serverIdOrSlug: string, homepageHtml: string | null): Promise<ShadowServer>;
|
|
1535
1751
|
deleteServer(serverId: string): Promise<{
|
|
1536
1752
|
success: boolean;
|
|
1537
1753
|
}>;
|
|
@@ -1564,6 +1780,9 @@ declare class ShadowClient {
|
|
|
1564
1780
|
isPrivate?: boolean;
|
|
1565
1781
|
}): Promise<ShadowChannel>;
|
|
1566
1782
|
getChannel(channelId: string): Promise<ShadowChannel>;
|
|
1783
|
+
getChannelBootstrap(channelId: string, options?: {
|
|
1784
|
+
messagesLimit?: number;
|
|
1785
|
+
}): Promise<ShadowChannelBootstrap>;
|
|
1567
1786
|
getChannelAccess(channelId: string): Promise<ShadowChannelAccess>;
|
|
1568
1787
|
getChannelMembers(channelId: string): Promise<ShadowMember[]>;
|
|
1569
1788
|
updateChannel(channelId: string, data: {
|
|
@@ -1699,6 +1918,11 @@ declare class ShadowClient {
|
|
|
1699
1918
|
}>;
|
|
1700
1919
|
resolveAttachmentMediaUrl(attachmentId: string, options?: {
|
|
1701
1920
|
disposition?: 'inline' | 'attachment';
|
|
1921
|
+
variant?: ShadowMediaVariant;
|
|
1922
|
+
}): Promise<ShadowSignedMediaUrl>;
|
|
1923
|
+
resolveWorkspaceMediaUrl(serverId: string, fileId: string, options?: {
|
|
1924
|
+
disposition?: 'inline' | 'attachment';
|
|
1925
|
+
contentRef?: string;
|
|
1702
1926
|
}): Promise<ShadowSignedMediaUrl>;
|
|
1703
1927
|
/**
|
|
1704
1928
|
* Download a file from a URL and upload it to the Shadow media service.
|
|
@@ -1788,11 +2012,28 @@ declare class ShadowClient {
|
|
|
1788
2012
|
listOAuthAccounts(): Promise<{
|
|
1789
2013
|
id: string;
|
|
1790
2014
|
provider: string;
|
|
1791
|
-
|
|
2015
|
+
providerEmail: string | null;
|
|
2016
|
+
createdAt: string;
|
|
1792
2017
|
}[]>;
|
|
2018
|
+
createOAuthConnectUrl(provider: 'google' | 'github', redirect?: string): Promise<{
|
|
2019
|
+
url: string;
|
|
2020
|
+
}>;
|
|
1793
2021
|
unlinkOAuthAccount(accountId: string): Promise<{
|
|
1794
2022
|
success: boolean;
|
|
1795
2023
|
}>;
|
|
2024
|
+
listAuthSessions(): Promise<Array<{
|
|
2025
|
+
id: string;
|
|
2026
|
+
deviceName: string | null;
|
|
2027
|
+
userAgent: string | null;
|
|
2028
|
+
ipAddress: string | null;
|
|
2029
|
+
lastSeenAt: string;
|
|
2030
|
+
createdAt: string;
|
|
2031
|
+
revokedAt: string | null;
|
|
2032
|
+
current: boolean;
|
|
2033
|
+
}>>;
|
|
2034
|
+
revokeAuthSession(sessionId: string): Promise<{
|
|
2035
|
+
ok: boolean;
|
|
2036
|
+
}>;
|
|
1796
2037
|
changePassword(data: {
|
|
1797
2038
|
currentPassword: string;
|
|
1798
2039
|
newPassword: string;
|
|
@@ -1883,6 +2124,18 @@ declare class ShadowClient {
|
|
|
1883
2124
|
revokeOAuthConsent(appId: string): Promise<{
|
|
1884
2125
|
success: boolean;
|
|
1885
2126
|
}>;
|
|
2127
|
+
sendOAuthChannelMessage(channelId: string, content: string, opts?: {
|
|
2128
|
+
metadata?: {
|
|
2129
|
+
oauthLinkCards?: ShadowOAuthLinkCard[];
|
|
2130
|
+
};
|
|
2131
|
+
}): Promise<ShadowMessage>;
|
|
2132
|
+
sendOAuthBuddyMessage(buddyId: string, data: {
|
|
2133
|
+
channelId: string;
|
|
2134
|
+
content: string;
|
|
2135
|
+
metadata?: {
|
|
2136
|
+
oauthLinkCards?: ShadowOAuthLinkCard[];
|
|
2137
|
+
};
|
|
2138
|
+
}): Promise<ShadowMessage>;
|
|
1886
2139
|
browseListings(params?: {
|
|
1887
2140
|
search?: string;
|
|
1888
2141
|
tags?: string[];
|
|
@@ -2502,4 +2755,4 @@ declare class ShadowSocket {
|
|
|
2502
2755
|
updateActivity(channelId: string, activity: string | null): void;
|
|
2503
2756
|
}
|
|
2504
2757
|
|
|
2505
|
-
export { type ChannelCreatedPayload, type ChannelMemberAddedPayload, type ChannelMemberRemovedPayload, type ClientEventMap, type MemberJoinPayload, type MemberLeavePayload, type MessageDeletedPayload, type PolicyChangedPayload, type PresenceActivityPayload, type PresenceChangePayload, type ReactionPayload, type ServerEventMap, type ServerJoinedPayload, type ShadowAddAgentsToServerResult, type ShadowAgentUsageSnapshotInput, type ShadowAttachment, type ShadowCartItem, type ShadowCategory, type ShadowChannel, type ShadowChannelAccess, type ShadowChannelJoinRequestResult, type ShadowChannelJoinRequestStatus, type ShadowChannelPolicy, type ShadowChannelSlashCommand, ShadowClient, type ShadowCloudDeploymentBackup, type ShadowCloudDeploymentRuntimeResponse, type ShadowCloudDeploymentStatus, type ShadowCloudProviderCatalog, type ShadowCloudProviderEnvVar, type ShadowCloudProviderModel, type ShadowCloudProviderProfile, type ShadowContract, type ShadowDiyCloudRun, type ShadowDiyCloudRunEvent, type ShadowDiyCloudRunStatus, type ShadowFriendship, type ShadowInteractiveActionInput, type ShadowInteractiveActionResult, type ShadowInteractiveBlock, type ShadowInteractiveResponse, type ShadowInteractiveState, type ShadowInteractiveSubmissionPending, type ShadowInviteCode, type ShadowListing, type ShadowMember, type ShadowMentionSuggestion, type ShadowMentionSuggestionTrigger, type ShadowMessage, type ShadowMessageMention, type ShadowModelProxyBilling, type ShadowModelProxyChatCompletionRequest, type ShadowModelProxyChatCompletionResponse, type ShadowModelProxyModel, type ShadowModelProxyModelsResponse, type ShadowNotification, type ShadowNotificationPreferences, type ShadowOAuthApp, type ShadowOAuthConsent, type ShadowOAuthToken, type ShadowOrder, type ShadowProduct, type ShadowRemoteChannel, type ShadowRemoteConfig, type ShadowRemoteServer, type ShadowReview, type ShadowServer, type ShadowServerAccess, type ShadowServerJoinRequestResult, type ShadowServerJoinRequestStatus, type ShadowShop, type ShadowSlashCommand, ShadowSocket, type ShadowSocketOptions, type ShadowTask, type ShadowThread, type ShadowTransaction, type ShadowUsageProviderSnapshot, type ShadowUser, type ShadowWallet, type TypingPayload, channelRoom, threadRoom, userRoom };
|
|
2758
|
+
export { type ChannelCreatedPayload, type ChannelMemberAddedPayload, type ChannelMemberRemovedPayload, type ClientEventMap, type MemberJoinPayload, type MemberLeavePayload, type MessageDeletedPayload, type PolicyChangedPayload, type PresenceActivityPayload, type PresenceChangePayload, type ReactionPayload, type ServerEventMap, type ServerJoinedPayload, type ShadowAddAgentsToServerResult, type ShadowAgentUsageSnapshotInput, type ShadowAttachment, type ShadowCartItem, type ShadowCategory, type ShadowChannel, type ShadowChannelAccess, type ShadowChannelBootstrap, type ShadowChannelJoinRequestResult, type ShadowChannelJoinRequestStatus, type ShadowChannelPolicy, type ShadowChannelSlashCommand, ShadowClient, type ShadowCloudDeploymentBackup, type ShadowCloudDeploymentRuntimeResponse, type ShadowCloudDeploymentStatus, type ShadowCloudProviderCatalog, type ShadowCloudProviderEnvVar, type ShadowCloudProviderModel, type ShadowCloudProviderProfile, type ShadowContract, type ShadowDiyCloudRun, type ShadowDiyCloudRunEvent, type ShadowDiyCloudRunStatus, type ShadowFriendship, type ShadowInteractiveActionInput, type ShadowInteractiveActionResult, type ShadowInteractiveBlock, type ShadowInteractiveResponse, type ShadowInteractiveState, type ShadowInteractiveSubmissionPending, type ShadowInviteCode, type ShadowListing, type ShadowMediaVariant, type ShadowMember, type ShadowMentionSuggestion, type ShadowMentionSuggestionTrigger, type ShadowMessage, type ShadowMessageMention, type ShadowModelProxyBilling, type ShadowModelProxyChatCompletionRequest, type ShadowModelProxyChatCompletionResponse, type ShadowModelProxyModel, type ShadowModelProxyModelsResponse, type ShadowNotification, type ShadowNotificationPreferences, type ShadowOAuthApp, type ShadowOAuthConsent, type ShadowOAuthToken, type ShadowOrder, type ShadowProduct, type ShadowRemoteChannel, type ShadowRemoteConfig, type ShadowRemoteServer, type ShadowReview, type ShadowServer, type ShadowServerAccess, type ShadowServerAppCatalogEntry, type ShadowServerAppCommand, type ShadowServerAppDiscovery, type ShadowServerAppIntegration, type ShadowServerAppLaunchContext, type ShadowServerAppManifest, type ShadowServerAppSkillDocument, type ShadowServerAppTokenIntrospection, type ShadowServerJoinRequestResult, type ShadowServerJoinRequestStatus, type ShadowShop, type ShadowSlashCommand, ShadowSocket, type ShadowSocketOptions, type ShadowTask, type ShadowThread, type ShadowTransaction, type ShadowUsageProviderSnapshot, type ShadowUser, type ShadowWallet, type TypingPayload, channelRoom, threadRoom, userRoom };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessageMention, MentionSuggestionTrigger, MentionSuggestion } from '@shadowob/shared';
|
|
1
|
+
import { MessageMention, OAuthLinkCard, MentionSuggestionTrigger, MentionSuggestion } from '@shadowob/shared';
|
|
2
2
|
export { CLIENT_EVENTS, ClientEvent, SERVER_EVENTS, ServerEvent } from '@shadowob/shared';
|
|
3
3
|
import { Socket } from 'socket.io-client';
|
|
4
4
|
|
|
@@ -94,6 +94,7 @@ interface ShadowMessageMetadata {
|
|
|
94
94
|
interactiveResponse?: ShadowInteractiveResponse;
|
|
95
95
|
interactiveState?: ShadowInteractiveState;
|
|
96
96
|
commerceCards?: Array<ShadowCommerceProductCard | ShadowCommerceOfferCardInput>;
|
|
97
|
+
oauthLinkCards?: ShadowOAuthLinkCard[];
|
|
97
98
|
[key: string]: unknown;
|
|
98
99
|
}
|
|
99
100
|
interface ShadowCommerceOfferCardInput {
|
|
@@ -102,6 +103,7 @@ interface ShadowCommerceOfferCardInput {
|
|
|
102
103
|
offerId: string;
|
|
103
104
|
}
|
|
104
105
|
type ShadowMessageMention = MessageMention;
|
|
106
|
+
type ShadowOAuthLinkCard = OAuthLinkCard;
|
|
105
107
|
type ShadowMentionSuggestion = MentionSuggestion;
|
|
106
108
|
type ShadowMentionSuggestionTrigger = MentionSuggestionTrigger;
|
|
107
109
|
interface ShadowAttachment {
|
|
@@ -118,6 +120,149 @@ interface ShadowSignedMediaUrl {
|
|
|
118
120
|
url: string;
|
|
119
121
|
expiresAt: string;
|
|
120
122
|
}
|
|
123
|
+
type ShadowMediaVariant = 'avatar' | 'preview' | 'banner';
|
|
124
|
+
type ShadowServerAppAction = 'read' | 'write' | 'manage' | 'delete' | 'generate';
|
|
125
|
+
type ShadowServerAppDataClass = 'public' | 'server-private' | 'channel-private' | 'financial' | 'secret' | 'cloud-secret';
|
|
126
|
+
interface ShadowServerAppCommand {
|
|
127
|
+
name: string;
|
|
128
|
+
title?: string;
|
|
129
|
+
description?: string;
|
|
130
|
+
path: string;
|
|
131
|
+
method?: 'POST';
|
|
132
|
+
input?: 'json' | 'multipart';
|
|
133
|
+
inputSchema?: Record<string, unknown>;
|
|
134
|
+
permission: string;
|
|
135
|
+
action: ShadowServerAppAction;
|
|
136
|
+
dataClass: ShadowServerAppDataClass;
|
|
137
|
+
approvalMode?: 'none' | 'first_time' | 'every_time' | 'policy';
|
|
138
|
+
binary?: {
|
|
139
|
+
supported?: boolean;
|
|
140
|
+
field?: string;
|
|
141
|
+
maxBytes?: number;
|
|
142
|
+
contentTypes?: string[];
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
interface ShadowServerAppManifest {
|
|
146
|
+
schemaVersion: 'shadow.app/1';
|
|
147
|
+
appKey: string;
|
|
148
|
+
name: string;
|
|
149
|
+
description?: string;
|
|
150
|
+
version?: string;
|
|
151
|
+
iconUrl: string;
|
|
152
|
+
iframe?: {
|
|
153
|
+
entry: string;
|
|
154
|
+
allowedOrigins: string[];
|
|
155
|
+
};
|
|
156
|
+
api: {
|
|
157
|
+
baseUrl: string;
|
|
158
|
+
auth?: {
|
|
159
|
+
type: 'oauth2-bearer';
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
commands: ShadowServerAppCommand[];
|
|
163
|
+
skills?: Array<{
|
|
164
|
+
name: string;
|
|
165
|
+
description: string;
|
|
166
|
+
commandHints?: string[];
|
|
167
|
+
}>;
|
|
168
|
+
events?: string[];
|
|
169
|
+
binary?: {
|
|
170
|
+
supported: boolean;
|
|
171
|
+
maxBytes?: number;
|
|
172
|
+
contentTypes?: string[];
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
interface ShadowServerAppIntegration {
|
|
176
|
+
id: string;
|
|
177
|
+
serverId: string;
|
|
178
|
+
appKey: string;
|
|
179
|
+
name: string;
|
|
180
|
+
description?: string | null;
|
|
181
|
+
iconUrl?: string | null;
|
|
182
|
+
manifestUrl?: string | null;
|
|
183
|
+
manifest: ShadowServerAppManifest;
|
|
184
|
+
iframeEntry?: string | null;
|
|
185
|
+
allowedOrigins: string[];
|
|
186
|
+
apiBaseUrl: string;
|
|
187
|
+
status: string;
|
|
188
|
+
installedByUserId: string;
|
|
189
|
+
createdAt: string;
|
|
190
|
+
updatedAt: string;
|
|
191
|
+
}
|
|
192
|
+
interface ShadowServerAppDiscovery {
|
|
193
|
+
manifest: ShadowServerAppManifest;
|
|
194
|
+
installed: ShadowServerAppIntegration | null;
|
|
195
|
+
permissions: Array<{
|
|
196
|
+
name: string;
|
|
197
|
+
title: string;
|
|
198
|
+
description?: string | null;
|
|
199
|
+
permission: string;
|
|
200
|
+
action: ShadowServerAppAction;
|
|
201
|
+
dataClass: ShadowServerAppDataClass;
|
|
202
|
+
approvalMode: 'none' | 'first_time' | 'every_time' | 'policy';
|
|
203
|
+
}>;
|
|
204
|
+
}
|
|
205
|
+
interface ShadowServerAppCatalogEntry {
|
|
206
|
+
id: string;
|
|
207
|
+
appKey: string;
|
|
208
|
+
name: string;
|
|
209
|
+
description?: string | null;
|
|
210
|
+
iconUrl?: string | null;
|
|
211
|
+
manifestUrl?: string | null;
|
|
212
|
+
manifest: ShadowServerAppManifest;
|
|
213
|
+
status: string;
|
|
214
|
+
installed?: ShadowServerAppIntegration | null;
|
|
215
|
+
permissions?: ShadowServerAppDiscovery['permissions'];
|
|
216
|
+
createdAt: string;
|
|
217
|
+
updatedAt: string;
|
|
218
|
+
}
|
|
219
|
+
interface ShadowServerAppLaunchContext {
|
|
220
|
+
serverId: string;
|
|
221
|
+
serverAppId: string;
|
|
222
|
+
appKey: string;
|
|
223
|
+
iframeEntry: string | null;
|
|
224
|
+
allowedOrigins: string[];
|
|
225
|
+
launchToken: string;
|
|
226
|
+
eventStreamPath: string;
|
|
227
|
+
expiresIn: number;
|
|
228
|
+
}
|
|
229
|
+
interface ShadowServerAppSkillDocument {
|
|
230
|
+
appKey: string;
|
|
231
|
+
markdown: string;
|
|
232
|
+
skills: Array<{
|
|
233
|
+
name: string;
|
|
234
|
+
description: string;
|
|
235
|
+
commandHints?: string[];
|
|
236
|
+
}>;
|
|
237
|
+
}
|
|
238
|
+
interface ShadowServerAppTokenIntrospection {
|
|
239
|
+
active: boolean;
|
|
240
|
+
token_type?: 'Bearer';
|
|
241
|
+
iss?: string;
|
|
242
|
+
aud?: string;
|
|
243
|
+
sub?: string;
|
|
244
|
+
scope?: string;
|
|
245
|
+
client_id?: string;
|
|
246
|
+
exp?: number;
|
|
247
|
+
iat?: number;
|
|
248
|
+
shadow?: {
|
|
249
|
+
protocol: 'shadow.app/1';
|
|
250
|
+
serverId: string;
|
|
251
|
+
serverAppId: string;
|
|
252
|
+
appKey: string;
|
|
253
|
+
command?: string;
|
|
254
|
+
actor: {
|
|
255
|
+
kind?: string;
|
|
256
|
+
userId?: string | null;
|
|
257
|
+
buddyAgentId?: string | null;
|
|
258
|
+
ownerId?: string | null;
|
|
259
|
+
};
|
|
260
|
+
channelId?: string | null;
|
|
261
|
+
permission?: string;
|
|
262
|
+
action?: string;
|
|
263
|
+
dataClass?: string;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
121
266
|
interface ShadowChannel {
|
|
122
267
|
id: string;
|
|
123
268
|
name: string;
|
|
@@ -215,7 +360,6 @@ interface ShadowServer {
|
|
|
215
360
|
description: string | null;
|
|
216
361
|
iconUrl: string | null;
|
|
217
362
|
bannerUrl: string | null;
|
|
218
|
-
homepageHtml: string | null;
|
|
219
363
|
isPublic: boolean;
|
|
220
364
|
}
|
|
221
365
|
interface ShadowUser {
|
|
@@ -385,7 +529,15 @@ interface ShadowChannelPolicy {
|
|
|
385
529
|
listen: boolean;
|
|
386
530
|
reply: boolean;
|
|
387
531
|
mentionOnly: boolean;
|
|
388
|
-
config:
|
|
532
|
+
config: ShadowChannelPolicyConfig;
|
|
533
|
+
}
|
|
534
|
+
interface ShadowChannelPolicyConfig {
|
|
535
|
+
allowedTriggerUserIds?: string[];
|
|
536
|
+
triggerUserIds?: string[];
|
|
537
|
+
ownerId?: string;
|
|
538
|
+
activeTenantIds?: string[];
|
|
539
|
+
replyRequiresMention?: boolean;
|
|
540
|
+
[key: string]: unknown;
|
|
389
541
|
}
|
|
390
542
|
interface ShadowSlashCommand {
|
|
391
543
|
name: string;
|
|
@@ -401,6 +553,20 @@ interface ShadowChannelSlashCommand extends ShadowSlashCommand {
|
|
|
401
553
|
botUsername: string;
|
|
402
554
|
botDisplayName?: string | null;
|
|
403
555
|
}
|
|
556
|
+
interface ShadowChannelBootstrap {
|
|
557
|
+
access: ShadowChannelAccess;
|
|
558
|
+
channel: ShadowChannel;
|
|
559
|
+
server: ShadowServer | null;
|
|
560
|
+
channels: ShadowChannel[];
|
|
561
|
+
members: ShadowMember[];
|
|
562
|
+
messages: {
|
|
563
|
+
messages: ShadowMessage[];
|
|
564
|
+
hasMore: boolean;
|
|
565
|
+
};
|
|
566
|
+
slashCommands: {
|
|
567
|
+
commands: ShadowChannelSlashCommand[];
|
|
568
|
+
};
|
|
569
|
+
}
|
|
404
570
|
interface ShadowRemoteChannel {
|
|
405
571
|
id: string;
|
|
406
572
|
name: string;
|
|
@@ -418,6 +584,11 @@ interface ShadowRemoteServer {
|
|
|
418
584
|
interface ShadowRemoteConfig {
|
|
419
585
|
agentId: string;
|
|
420
586
|
botUserId: string;
|
|
587
|
+
ownerId?: string;
|
|
588
|
+
buddyMode?: 'private' | 'shareable';
|
|
589
|
+
allowedServerIds?: string[];
|
|
590
|
+
activeTenantIds?: string[];
|
|
591
|
+
allowedTriggerUserIds?: string[];
|
|
421
592
|
slashCommands?: ShadowSlashCommand[];
|
|
422
593
|
servers: ShadowRemoteServer[];
|
|
423
594
|
}
|
|
@@ -1426,10 +1597,15 @@ declare class ShadowClient {
|
|
|
1426
1597
|
getOfficialModelProxyBilling(): Promise<ShadowModelProxyBilling>;
|
|
1427
1598
|
createOfficialChatCompletion(data: ShadowModelProxyChatCompletionRequest): Promise<ShadowModelProxyChatCompletionResponse>;
|
|
1428
1599
|
createOfficialChatCompletionStream(data: ShadowModelProxyChatCompletionRequest): Promise<Response>;
|
|
1429
|
-
listAgents(
|
|
1600
|
+
listAgents(options?: {
|
|
1601
|
+
includeRentals?: boolean;
|
|
1602
|
+
}): Promise<{
|
|
1430
1603
|
id: string;
|
|
1431
|
-
name
|
|
1604
|
+
name?: string;
|
|
1432
1605
|
status: string;
|
|
1606
|
+
accessRole?: 'owner' | 'tenant';
|
|
1607
|
+
activeContractId?: string | null;
|
|
1608
|
+
config?: Record<string, unknown>;
|
|
1433
1609
|
}[]>;
|
|
1434
1610
|
createAgent(data: {
|
|
1435
1611
|
name: string;
|
|
@@ -1439,6 +1615,8 @@ declare class ShadowClient {
|
|
|
1439
1615
|
avatarUrl?: string | null;
|
|
1440
1616
|
kernelType?: string;
|
|
1441
1617
|
config?: Record<string, unknown>;
|
|
1618
|
+
buddyMode?: 'private' | 'shareable';
|
|
1619
|
+
allowedServerIds?: string[];
|
|
1442
1620
|
}): Promise<{
|
|
1443
1621
|
id: string;
|
|
1444
1622
|
token: string;
|
|
@@ -1454,6 +1632,8 @@ declare class ShadowClient {
|
|
|
1454
1632
|
name?: string;
|
|
1455
1633
|
displayName?: string;
|
|
1456
1634
|
avatarUrl?: string | null;
|
|
1635
|
+
buddyMode?: 'private' | 'shareable';
|
|
1636
|
+
allowedServerIds?: string[];
|
|
1457
1637
|
}): Promise<{
|
|
1458
1638
|
id: string;
|
|
1459
1639
|
name: string;
|
|
@@ -1524,14 +1704,50 @@ declare class ShadowClient {
|
|
|
1524
1704
|
listServers(): Promise<ShadowServer[]>;
|
|
1525
1705
|
getServer(serverIdOrSlug: string): Promise<ShadowServer>;
|
|
1526
1706
|
getServerAccess(serverIdOrSlug: string): Promise<ShadowServerAccess>;
|
|
1707
|
+
listServerApps(serverIdOrSlug: string): Promise<ShadowServerAppIntegration[]>;
|
|
1708
|
+
listServerAppCatalog(serverIdOrSlug: string): Promise<ShadowServerAppCatalogEntry[]>;
|
|
1709
|
+
discoverServerApp(serverIdOrSlug: string, data: {
|
|
1710
|
+
manifestUrl?: string;
|
|
1711
|
+
manifest?: ShadowServerAppManifest;
|
|
1712
|
+
}): Promise<ShadowServerAppDiscovery>;
|
|
1713
|
+
installServerApp(serverIdOrSlug: string, data: {
|
|
1714
|
+
manifestUrl?: string;
|
|
1715
|
+
manifest?: ShadowServerAppManifest;
|
|
1716
|
+
}): Promise<ShadowServerAppIntegration>;
|
|
1717
|
+
installServerAppFromCatalog(serverIdOrSlug: string, catalogEntryId: string, data?: Record<string, never>): Promise<ShadowServerAppIntegration>;
|
|
1718
|
+
getServerApp(serverIdOrSlug: string, appKey: string): Promise<ShadowServerAppIntegration & {
|
|
1719
|
+
grants?: Record<string, unknown>[];
|
|
1720
|
+
}>;
|
|
1721
|
+
deleteServerApp(serverIdOrSlug: string, appKey: string): Promise<{
|
|
1722
|
+
ok: boolean;
|
|
1723
|
+
}>;
|
|
1724
|
+
grantServerAppToBuddy(serverIdOrSlug: string, appKey: string, data: {
|
|
1725
|
+
buddyAgentId: string;
|
|
1726
|
+
permissions: string[];
|
|
1727
|
+
resourceRules?: Record<string, unknown>;
|
|
1728
|
+
approvalMode?: 'none' | 'first_time' | 'every_time' | 'policy';
|
|
1729
|
+
expiresAt?: string;
|
|
1730
|
+
}): Promise<Record<string, unknown>>;
|
|
1731
|
+
getServerAppSkills(serverIdOrSlug: string, appKey: string): Promise<ShadowServerAppSkillDocument>;
|
|
1732
|
+
createServerAppLaunch(serverIdOrSlug: string, appKey: string): Promise<ShadowServerAppLaunchContext>;
|
|
1733
|
+
introspectServerAppToken(serverIdOrSlug: string, appKey: string, token: string): Promise<ShadowServerAppTokenIntrospection>;
|
|
1734
|
+
callServerAppCommand(serverIdOrSlug: string, appKey: string, commandName: string, data?: {
|
|
1735
|
+
input?: unknown;
|
|
1736
|
+
channelId?: string;
|
|
1737
|
+
}): Promise<unknown>;
|
|
1738
|
+
callServerAppCommandMultipart(serverIdOrSlug: string, appKey: string, commandName: string, data: {
|
|
1739
|
+
input?: unknown;
|
|
1740
|
+
channelId?: string;
|
|
1741
|
+
file: Blob;
|
|
1742
|
+
filename: string;
|
|
1743
|
+
field?: string;
|
|
1744
|
+
}): Promise<unknown>;
|
|
1527
1745
|
updateServer(serverIdOrSlug: string, data: {
|
|
1528
1746
|
name?: string;
|
|
1529
1747
|
description?: string | null;
|
|
1530
1748
|
slug?: string | null;
|
|
1531
|
-
homepageHtml?: string | null;
|
|
1532
1749
|
isPublic?: boolean;
|
|
1533
1750
|
}): Promise<ShadowServer>;
|
|
1534
|
-
updateServerHomepage(serverIdOrSlug: string, homepageHtml: string | null): Promise<ShadowServer>;
|
|
1535
1751
|
deleteServer(serverId: string): Promise<{
|
|
1536
1752
|
success: boolean;
|
|
1537
1753
|
}>;
|
|
@@ -1564,6 +1780,9 @@ declare class ShadowClient {
|
|
|
1564
1780
|
isPrivate?: boolean;
|
|
1565
1781
|
}): Promise<ShadowChannel>;
|
|
1566
1782
|
getChannel(channelId: string): Promise<ShadowChannel>;
|
|
1783
|
+
getChannelBootstrap(channelId: string, options?: {
|
|
1784
|
+
messagesLimit?: number;
|
|
1785
|
+
}): Promise<ShadowChannelBootstrap>;
|
|
1567
1786
|
getChannelAccess(channelId: string): Promise<ShadowChannelAccess>;
|
|
1568
1787
|
getChannelMembers(channelId: string): Promise<ShadowMember[]>;
|
|
1569
1788
|
updateChannel(channelId: string, data: {
|
|
@@ -1699,6 +1918,11 @@ declare class ShadowClient {
|
|
|
1699
1918
|
}>;
|
|
1700
1919
|
resolveAttachmentMediaUrl(attachmentId: string, options?: {
|
|
1701
1920
|
disposition?: 'inline' | 'attachment';
|
|
1921
|
+
variant?: ShadowMediaVariant;
|
|
1922
|
+
}): Promise<ShadowSignedMediaUrl>;
|
|
1923
|
+
resolveWorkspaceMediaUrl(serverId: string, fileId: string, options?: {
|
|
1924
|
+
disposition?: 'inline' | 'attachment';
|
|
1925
|
+
contentRef?: string;
|
|
1702
1926
|
}): Promise<ShadowSignedMediaUrl>;
|
|
1703
1927
|
/**
|
|
1704
1928
|
* Download a file from a URL and upload it to the Shadow media service.
|
|
@@ -1788,11 +2012,28 @@ declare class ShadowClient {
|
|
|
1788
2012
|
listOAuthAccounts(): Promise<{
|
|
1789
2013
|
id: string;
|
|
1790
2014
|
provider: string;
|
|
1791
|
-
|
|
2015
|
+
providerEmail: string | null;
|
|
2016
|
+
createdAt: string;
|
|
1792
2017
|
}[]>;
|
|
2018
|
+
createOAuthConnectUrl(provider: 'google' | 'github', redirect?: string): Promise<{
|
|
2019
|
+
url: string;
|
|
2020
|
+
}>;
|
|
1793
2021
|
unlinkOAuthAccount(accountId: string): Promise<{
|
|
1794
2022
|
success: boolean;
|
|
1795
2023
|
}>;
|
|
2024
|
+
listAuthSessions(): Promise<Array<{
|
|
2025
|
+
id: string;
|
|
2026
|
+
deviceName: string | null;
|
|
2027
|
+
userAgent: string | null;
|
|
2028
|
+
ipAddress: string | null;
|
|
2029
|
+
lastSeenAt: string;
|
|
2030
|
+
createdAt: string;
|
|
2031
|
+
revokedAt: string | null;
|
|
2032
|
+
current: boolean;
|
|
2033
|
+
}>>;
|
|
2034
|
+
revokeAuthSession(sessionId: string): Promise<{
|
|
2035
|
+
ok: boolean;
|
|
2036
|
+
}>;
|
|
1796
2037
|
changePassword(data: {
|
|
1797
2038
|
currentPassword: string;
|
|
1798
2039
|
newPassword: string;
|
|
@@ -1883,6 +2124,18 @@ declare class ShadowClient {
|
|
|
1883
2124
|
revokeOAuthConsent(appId: string): Promise<{
|
|
1884
2125
|
success: boolean;
|
|
1885
2126
|
}>;
|
|
2127
|
+
sendOAuthChannelMessage(channelId: string, content: string, opts?: {
|
|
2128
|
+
metadata?: {
|
|
2129
|
+
oauthLinkCards?: ShadowOAuthLinkCard[];
|
|
2130
|
+
};
|
|
2131
|
+
}): Promise<ShadowMessage>;
|
|
2132
|
+
sendOAuthBuddyMessage(buddyId: string, data: {
|
|
2133
|
+
channelId: string;
|
|
2134
|
+
content: string;
|
|
2135
|
+
metadata?: {
|
|
2136
|
+
oauthLinkCards?: ShadowOAuthLinkCard[];
|
|
2137
|
+
};
|
|
2138
|
+
}): Promise<ShadowMessage>;
|
|
1886
2139
|
browseListings(params?: {
|
|
1887
2140
|
search?: string;
|
|
1888
2141
|
tags?: string[];
|
|
@@ -2502,4 +2755,4 @@ declare class ShadowSocket {
|
|
|
2502
2755
|
updateActivity(channelId: string, activity: string | null): void;
|
|
2503
2756
|
}
|
|
2504
2757
|
|
|
2505
|
-
export { type ChannelCreatedPayload, type ChannelMemberAddedPayload, type ChannelMemberRemovedPayload, type ClientEventMap, type MemberJoinPayload, type MemberLeavePayload, type MessageDeletedPayload, type PolicyChangedPayload, type PresenceActivityPayload, type PresenceChangePayload, type ReactionPayload, type ServerEventMap, type ServerJoinedPayload, type ShadowAddAgentsToServerResult, type ShadowAgentUsageSnapshotInput, type ShadowAttachment, type ShadowCartItem, type ShadowCategory, type ShadowChannel, type ShadowChannelAccess, type ShadowChannelJoinRequestResult, type ShadowChannelJoinRequestStatus, type ShadowChannelPolicy, type ShadowChannelSlashCommand, ShadowClient, type ShadowCloudDeploymentBackup, type ShadowCloudDeploymentRuntimeResponse, type ShadowCloudDeploymentStatus, type ShadowCloudProviderCatalog, type ShadowCloudProviderEnvVar, type ShadowCloudProviderModel, type ShadowCloudProviderProfile, type ShadowContract, type ShadowDiyCloudRun, type ShadowDiyCloudRunEvent, type ShadowDiyCloudRunStatus, type ShadowFriendship, type ShadowInteractiveActionInput, type ShadowInteractiveActionResult, type ShadowInteractiveBlock, type ShadowInteractiveResponse, type ShadowInteractiveState, type ShadowInteractiveSubmissionPending, type ShadowInviteCode, type ShadowListing, type ShadowMember, type ShadowMentionSuggestion, type ShadowMentionSuggestionTrigger, type ShadowMessage, type ShadowMessageMention, type ShadowModelProxyBilling, type ShadowModelProxyChatCompletionRequest, type ShadowModelProxyChatCompletionResponse, type ShadowModelProxyModel, type ShadowModelProxyModelsResponse, type ShadowNotification, type ShadowNotificationPreferences, type ShadowOAuthApp, type ShadowOAuthConsent, type ShadowOAuthToken, type ShadowOrder, type ShadowProduct, type ShadowRemoteChannel, type ShadowRemoteConfig, type ShadowRemoteServer, type ShadowReview, type ShadowServer, type ShadowServerAccess, type ShadowServerJoinRequestResult, type ShadowServerJoinRequestStatus, type ShadowShop, type ShadowSlashCommand, ShadowSocket, type ShadowSocketOptions, type ShadowTask, type ShadowThread, type ShadowTransaction, type ShadowUsageProviderSnapshot, type ShadowUser, type ShadowWallet, type TypingPayload, channelRoom, threadRoom, userRoom };
|
|
2758
|
+
export { type ChannelCreatedPayload, type ChannelMemberAddedPayload, type ChannelMemberRemovedPayload, type ClientEventMap, type MemberJoinPayload, type MemberLeavePayload, type MessageDeletedPayload, type PolicyChangedPayload, type PresenceActivityPayload, type PresenceChangePayload, type ReactionPayload, type ServerEventMap, type ServerJoinedPayload, type ShadowAddAgentsToServerResult, type ShadowAgentUsageSnapshotInput, type ShadowAttachment, type ShadowCartItem, type ShadowCategory, type ShadowChannel, type ShadowChannelAccess, type ShadowChannelBootstrap, type ShadowChannelJoinRequestResult, type ShadowChannelJoinRequestStatus, type ShadowChannelPolicy, type ShadowChannelSlashCommand, ShadowClient, type ShadowCloudDeploymentBackup, type ShadowCloudDeploymentRuntimeResponse, type ShadowCloudDeploymentStatus, type ShadowCloudProviderCatalog, type ShadowCloudProviderEnvVar, type ShadowCloudProviderModel, type ShadowCloudProviderProfile, type ShadowContract, type ShadowDiyCloudRun, type ShadowDiyCloudRunEvent, type ShadowDiyCloudRunStatus, type ShadowFriendship, type ShadowInteractiveActionInput, type ShadowInteractiveActionResult, type ShadowInteractiveBlock, type ShadowInteractiveResponse, type ShadowInteractiveState, type ShadowInteractiveSubmissionPending, type ShadowInviteCode, type ShadowListing, type ShadowMediaVariant, type ShadowMember, type ShadowMentionSuggestion, type ShadowMentionSuggestionTrigger, type ShadowMessage, type ShadowMessageMention, type ShadowModelProxyBilling, type ShadowModelProxyChatCompletionRequest, type ShadowModelProxyChatCompletionResponse, type ShadowModelProxyModel, type ShadowModelProxyModelsResponse, type ShadowNotification, type ShadowNotificationPreferences, type ShadowOAuthApp, type ShadowOAuthConsent, type ShadowOAuthToken, type ShadowOrder, type ShadowProduct, type ShadowRemoteChannel, type ShadowRemoteConfig, type ShadowRemoteServer, type ShadowReview, type ShadowServer, type ShadowServerAccess, type ShadowServerAppCatalogEntry, type ShadowServerAppCommand, type ShadowServerAppDiscovery, type ShadowServerAppIntegration, type ShadowServerAppLaunchContext, type ShadowServerAppManifest, type ShadowServerAppSkillDocument, type ShadowServerAppTokenIntrospection, type ShadowServerJoinRequestResult, type ShadowServerJoinRequestStatus, type ShadowShop, type ShadowSlashCommand, ShadowSocket, type ShadowSocketOptions, type ShadowTask, type ShadowThread, type ShadowTransaction, type ShadowUsageProviderSnapshot, type ShadowUser, type ShadowWallet, type TypingPayload, channelRoom, threadRoom, userRoom };
|
package/dist/index.js
CHANGED
|
@@ -45,12 +45,13 @@ var ShadowClient = class {
|
|
|
45
45
|
const url = `${this.baseUrl}${path}`;
|
|
46
46
|
const controller = new AbortController();
|
|
47
47
|
const timeout = setTimeout(() => controller.abort(), 6e4);
|
|
48
|
+
const isFormData = init?.body instanceof FormData;
|
|
48
49
|
try {
|
|
49
50
|
const res = await fetch(url, {
|
|
50
51
|
...init,
|
|
51
52
|
signal: init?.signal ?? controller.signal,
|
|
52
53
|
headers: {
|
|
53
|
-
"Content-Type": "application/json",
|
|
54
|
+
...!isFormData ? { "Content-Type": "application/json" } : {},
|
|
54
55
|
Authorization: `Bearer ${this.token}`,
|
|
55
56
|
...init?.headers
|
|
56
57
|
}
|
|
@@ -175,8 +176,11 @@ var ShadowClient = class {
|
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
// ── Agents ────────────────────────────────────────────────────────────
|
|
178
|
-
async listAgents() {
|
|
179
|
-
|
|
179
|
+
async listAgents(options) {
|
|
180
|
+
const params = new URLSearchParams();
|
|
181
|
+
if (options?.includeRentals) params.set("includeRentals", "true");
|
|
182
|
+
const query = params.toString();
|
|
183
|
+
return this.request(`/api/agents${query ? `?${query}` : ""}`);
|
|
180
184
|
}
|
|
181
185
|
async createAgent(data) {
|
|
182
186
|
return this.request("/api/agents", {
|
|
@@ -292,15 +296,113 @@ var ShadowClient = class {
|
|
|
292
296
|
async getServerAccess(serverIdOrSlug) {
|
|
293
297
|
return this.request(`/api/servers/${serverIdOrSlug}/access`);
|
|
294
298
|
}
|
|
299
|
+
// ── Server App Integrations ───────────────────────────────────────────
|
|
300
|
+
async listServerApps(serverIdOrSlug) {
|
|
301
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps`);
|
|
302
|
+
}
|
|
303
|
+
async listServerAppCatalog(serverIdOrSlug) {
|
|
304
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps/catalog`);
|
|
305
|
+
}
|
|
306
|
+
async discoverServerApp(serverIdOrSlug, data) {
|
|
307
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps/discover`, {
|
|
308
|
+
method: "POST",
|
|
309
|
+
body: JSON.stringify(data)
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
async installServerApp(serverIdOrSlug, data) {
|
|
313
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps`, {
|
|
314
|
+
method: "POST",
|
|
315
|
+
body: JSON.stringify(data)
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
async installServerAppFromCatalog(serverIdOrSlug, catalogEntryId, data = {}) {
|
|
319
|
+
return this.request(
|
|
320
|
+
`/api/servers/${serverIdOrSlug}/apps/catalog/${encodeURIComponent(catalogEntryId)}/install`,
|
|
321
|
+
{
|
|
322
|
+
method: "POST",
|
|
323
|
+
body: JSON.stringify(data)
|
|
324
|
+
}
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
async getServerApp(serverIdOrSlug, appKey) {
|
|
328
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}`);
|
|
329
|
+
}
|
|
330
|
+
async deleteServerApp(serverIdOrSlug, appKey) {
|
|
331
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}`, {
|
|
332
|
+
method: "DELETE"
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
async grantServerAppToBuddy(serverIdOrSlug, appKey, data) {
|
|
336
|
+
return this.request(
|
|
337
|
+
`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}/grants`,
|
|
338
|
+
{
|
|
339
|
+
method: "POST",
|
|
340
|
+
body: JSON.stringify(data)
|
|
341
|
+
}
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
async getServerAppSkills(serverIdOrSlug, appKey) {
|
|
345
|
+
return this.request(`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}/skills`);
|
|
346
|
+
}
|
|
347
|
+
async createServerAppLaunch(serverIdOrSlug, appKey) {
|
|
348
|
+
return this.request(
|
|
349
|
+
`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}/launch`,
|
|
350
|
+
{
|
|
351
|
+
method: "POST"
|
|
352
|
+
}
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
async introspectServerAppToken(serverIdOrSlug, appKey, token) {
|
|
356
|
+
const url = `${this.baseUrl}/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(
|
|
357
|
+
appKey
|
|
358
|
+
)}/oauth/introspect`;
|
|
359
|
+
const res = await fetch(url, {
|
|
360
|
+
method: "POST",
|
|
361
|
+
headers: {
|
|
362
|
+
Authorization: `Bearer ${token}`,
|
|
363
|
+
"Content-Type": "application/json"
|
|
364
|
+
},
|
|
365
|
+
body: JSON.stringify({ token })
|
|
366
|
+
});
|
|
367
|
+
if (!res.ok) {
|
|
368
|
+
const body = await res.text().catch(() => "");
|
|
369
|
+
const message = sanitizeErrorBody(body);
|
|
370
|
+
throw new Error(`Shadow API POST /oauth/introspect failed (${res.status}): ${message}`);
|
|
371
|
+
}
|
|
372
|
+
return await res.json();
|
|
373
|
+
}
|
|
374
|
+
async callServerAppCommand(serverIdOrSlug, appKey, commandName, data) {
|
|
375
|
+
return this.request(
|
|
376
|
+
`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}/commands/${encodeURIComponent(
|
|
377
|
+
commandName
|
|
378
|
+
)}`,
|
|
379
|
+
{
|
|
380
|
+
method: "POST",
|
|
381
|
+
body: JSON.stringify(data ?? {})
|
|
382
|
+
}
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
async callServerAppCommandMultipart(serverIdOrSlug, appKey, commandName, data) {
|
|
386
|
+
const form = new FormData();
|
|
387
|
+
form.set("input", JSON.stringify(data.input ?? {}));
|
|
388
|
+
if (data.channelId) form.set("channelId", data.channelId);
|
|
389
|
+
form.set(data.field ?? "file", data.file, data.filename);
|
|
390
|
+
return this.request(
|
|
391
|
+
`/api/servers/${serverIdOrSlug}/apps/${encodeURIComponent(appKey)}/commands/${encodeURIComponent(
|
|
392
|
+
commandName
|
|
393
|
+
)}`,
|
|
394
|
+
{
|
|
395
|
+
method: "POST",
|
|
396
|
+
body: form
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
}
|
|
295
400
|
async updateServer(serverIdOrSlug, data) {
|
|
296
401
|
return this.request(`/api/servers/${serverIdOrSlug}`, {
|
|
297
402
|
method: "PATCH",
|
|
298
403
|
body: JSON.stringify(data)
|
|
299
404
|
});
|
|
300
405
|
}
|
|
301
|
-
async updateServerHomepage(serverIdOrSlug, homepageHtml) {
|
|
302
|
-
return this.updateServer(serverIdOrSlug, { homepageHtml });
|
|
303
|
-
}
|
|
304
406
|
async deleteServer(serverId) {
|
|
305
407
|
return this.request(`/api/servers/${serverId}`, { method: "DELETE" });
|
|
306
408
|
}
|
|
@@ -365,6 +467,14 @@ var ShadowClient = class {
|
|
|
365
467
|
const ch = await this.request(`/api/channels/${channelId}`);
|
|
366
468
|
return { ...ch, description: ch.topic };
|
|
367
469
|
}
|
|
470
|
+
async getChannelBootstrap(channelId, options) {
|
|
471
|
+
const params = new URLSearchParams();
|
|
472
|
+
if (options?.messagesLimit) params.set("messagesLimit", String(options.messagesLimit));
|
|
473
|
+
const query = params.toString();
|
|
474
|
+
return this.request(
|
|
475
|
+
`/api/channels/${channelId}/bootstrap${query ? `?${query}` : ""}`
|
|
476
|
+
);
|
|
477
|
+
}
|
|
368
478
|
async getChannelAccess(channelId) {
|
|
369
479
|
return this.request(`/api/channels/${channelId}/access`);
|
|
370
480
|
}
|
|
@@ -628,9 +738,19 @@ var ShadowClient = class {
|
|
|
628
738
|
return res.json();
|
|
629
739
|
}
|
|
630
740
|
async resolveAttachmentMediaUrl(attachmentId, options) {
|
|
631
|
-
const
|
|
741
|
+
const params = new URLSearchParams();
|
|
742
|
+
params.set("disposition", options?.disposition ?? "inline");
|
|
743
|
+
if (options?.variant) params.set("variant", options.variant);
|
|
744
|
+
return this.request(
|
|
745
|
+
`/api/attachments/${attachmentId}/media-url?${params}`
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
async resolveWorkspaceMediaUrl(serverId, fileId, options) {
|
|
749
|
+
const params = new URLSearchParams();
|
|
750
|
+
params.set("disposition", options?.disposition ?? "inline");
|
|
751
|
+
if (options?.contentRef) params.set("contentRef", options.contentRef);
|
|
632
752
|
return this.request(
|
|
633
|
-
`/api/
|
|
753
|
+
`/api/servers/${serverId}/workspace/files/${fileId}/media-url?${params}`
|
|
634
754
|
);
|
|
635
755
|
}
|
|
636
756
|
/**
|
|
@@ -856,9 +976,21 @@ var ShadowClient = class {
|
|
|
856
976
|
async listOAuthAccounts() {
|
|
857
977
|
return this.request("/api/auth/oauth/accounts");
|
|
858
978
|
}
|
|
979
|
+
async createOAuthConnectUrl(provider, redirect) {
|
|
980
|
+
return this.request(`/api/auth/oauth/${provider}/link`, {
|
|
981
|
+
method: "POST",
|
|
982
|
+
body: JSON.stringify({ redirect })
|
|
983
|
+
});
|
|
984
|
+
}
|
|
859
985
|
async unlinkOAuthAccount(accountId) {
|
|
860
986
|
return this.request(`/api/auth/oauth/accounts/${accountId}`, { method: "DELETE" });
|
|
861
987
|
}
|
|
988
|
+
async listAuthSessions() {
|
|
989
|
+
return this.request("/api/auth/sessions");
|
|
990
|
+
}
|
|
991
|
+
async revokeAuthSession(sessionId) {
|
|
992
|
+
return this.request(`/api/auth/sessions/${sessionId}`, { method: "DELETE" });
|
|
993
|
+
}
|
|
862
994
|
async changePassword(data) {
|
|
863
995
|
return this.request("/api/auth/password", {
|
|
864
996
|
method: "PUT",
|
|
@@ -986,6 +1118,21 @@ var ShadowClient = class {
|
|
|
986
1118
|
body: JSON.stringify({ appId })
|
|
987
1119
|
});
|
|
988
1120
|
}
|
|
1121
|
+
async sendOAuthChannelMessage(channelId, content, opts) {
|
|
1122
|
+
return this.request(`/api/oauth/channels/${channelId}/messages`, {
|
|
1123
|
+
method: "POST",
|
|
1124
|
+
body: JSON.stringify({
|
|
1125
|
+
content,
|
|
1126
|
+
...opts?.metadata ? { metadata: opts.metadata } : {}
|
|
1127
|
+
})
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
async sendOAuthBuddyMessage(buddyId, data) {
|
|
1131
|
+
return this.request(`/api/oauth/buddies/${buddyId}/messages`, {
|
|
1132
|
+
method: "POST",
|
|
1133
|
+
body: JSON.stringify(data)
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
989
1136
|
// ── Marketplace / Rentals ─────────────────────────────────────────────
|
|
990
1137
|
async browseListings(params) {
|
|
991
1138
|
const qs = new URLSearchParams();
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shadowob/sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Shadow SDK — typed REST client and real-time Socket.IO event listener for Shadow servers",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "./dist/index.js",
|
|
7
8
|
"module": "./dist/index.js",
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
],
|
|
22
23
|
"dependencies": {
|
|
23
24
|
"socket.io-client": "^4.8.1",
|
|
24
|
-
"@shadowob/shared": "1.1.
|
|
25
|
+
"@shadowob/shared": "1.1.4"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"tsup": "^8.5.0",
|