glitch-javascript-sdk 3.3.4 → 3.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -5200,6 +5200,14 @@ declare class Campaigns {
5200
5200
  * @returns promise
5201
5201
  */
5202
5202
  static sendInfluencerInvite<T>(campaign_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
5203
+ /**
5204
+ * Get creator context used when preparing a personalized invite.
5205
+ */
5206
+ static creatorInviteContext<T>(campaign_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
5207
+ /**
5208
+ * Send a personalized creator invite after review.
5209
+ */
5210
+ static sendCreatorInvite<T>(campaign_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
5203
5211
  /**
5204
5212
  * Invites an influencer to join this campaign.
5205
5213
  *
@@ -9915,7 +9923,20 @@ interface AgentRunRequest {
9915
9923
  agent_run_id?: string | null;
9916
9924
  [key: string]: any;
9917
9925
  }
9926
+ interface AgentStreamAnswerRequest {
9927
+ prompt: string;
9928
+ [key: string]: any;
9929
+ }
9930
+ interface AgentFetchOptions {
9931
+ params?: Record<string, any>;
9932
+ signal?: AbortSignal;
9933
+ headers?: Record<string, string>;
9934
+ fetcher?: typeof fetch;
9935
+ }
9936
+ interface AgentStreamAnswerOptions extends AgentFetchOptions {
9937
+ }
9918
9938
  declare class Agents {
9939
+ private static fetchWithAuth;
9919
9940
  /**
9920
9941
  * List game titles that can be managed in the Agents section.
9921
9942
  */
@@ -9960,6 +9981,15 @@ declare class Agents {
9960
9981
  * Run an agent planning cycle. Returns 402 when subscription or prepaid credits are required.
9961
9982
  */
9962
9983
  static runAgent<T>(title_id: string, agent_id: string, data?: AgentRunRequest, params?: Record<string, any>): AxiosPromise<Response<T>>;
9984
+ /**
9985
+ * Stream a quick advisory answer for the agent workspace.
9986
+ *
9987
+ * This returns the native Fetch API Response so callers can consume the
9988
+ * ReadableStream body incrementally. A 409 response means streaming is
9989
+ * disabled server-side and the caller should fall back to the normal run
9990
+ * flow.
9991
+ */
9992
+ static streamAnswer(title_id: string, agent_id: string, data: AgentStreamAnswerRequest | string, options?: AgentStreamAnswerOptions): Promise<globalThis.Response>;
9963
9993
  /**
9964
9994
  * Upload one file for an agent run. data can include { agent_run_id }.
9965
9995
  */
@@ -9968,6 +9998,25 @@ declare class Agents {
9968
9998
  * Alias for callers that use plural naming while uploading one file at a time.
9969
9999
  */
9970
10000
  static uploadAgentFiles<T>(title_id: string, agent_id: string, file: File | Blob, data?: object, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
10001
+ /**
10002
+ * List Google Drive files/folders available to attach to a title agent.
10003
+ */
10004
+ static listGoogleDriveFiles<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
10005
+ /**
10006
+ * Attach a Google Drive file as a reference file for an agent.
10007
+ */
10008
+ static attachGoogleDriveFile<T>(title_id: string, agent_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
10009
+ /**
10010
+ * Download a protected agent file through the authenticated API route.
10011
+ *
10012
+ * Returns the native Fetch API Response so callers can inspect headers such
10013
+ * as Content-Disposition before creating a browser download or preview blob.
10014
+ */
10015
+ static downloadAgentFile(title_id: string, file_id: string, options?: AgentFetchOptions): Promise<globalThis.Response>;
10016
+ /**
10017
+ * Export a generated agent artifact to Google Drive.
10018
+ */
10019
+ static exportAgentFileToGoogleDrive<T>(title_id: string, file_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
9971
10020
  /**
9972
10021
  * List agent runs for a title.
9973
10022
  */
@@ -10021,10 +10070,41 @@ declare class Agents {
10021
10070
  * Rewrite an editable agent draft for review without executing the parent action.
10022
10071
  */
10023
10072
  static rewriteAgentDraft<T>(title_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
10073
+ /**
10074
+ * Agent workflow convenience wrapper for creator invite context.
10075
+ */
10076
+ static creatorInviteContext<T>(campaign_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
10077
+ /**
10078
+ * Agent workflow convenience wrapper for sending a reviewed creator invite.
10079
+ */
10080
+ static sendCreatorInvite<T>(campaign_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
10081
+ /**
10082
+ * Agent workflow convenience wrapper for updating a drafted social post.
10083
+ */
10084
+ static updateSocialPost<T>(post_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
10085
+ /**
10086
+ * Agent workflow convenience wrapper for updating campaign settings.
10087
+ */
10088
+ static updateCampaign<T>(campaign_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
10089
+ /**
10090
+ * Agent workflow convenience wrapper for saving manual access keys.
10091
+ */
10092
+ static createAccessKeys<T>(title_id: string, data: {
10093
+ platform: string;
10094
+ codes: string;
10095
+ }, params?: Record<string, any>): AxiosPromise<Response<T>>;
10024
10096
  /**
10025
10097
  * List structured agent memories for a title.
10026
10098
  */
10027
10099
  static listMemories<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
10100
+ /**
10101
+ * Update one structured agent memory.
10102
+ */
10103
+ static updateMemory<T>(title_id: string, memory_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
10104
+ /**
10105
+ * Deactivate one structured agent memory.
10106
+ */
10107
+ static deactivateMemory<T>(title_id: string, memory_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
10028
10108
  /**
10029
10109
  * Get results and outcome summary for title agents. Returns 402 until subscription or prepaid credits are active.
10030
10110
  */
@@ -10830,6 +10910,17 @@ declare class AdminUsers {
10830
10910
  * @returns promise
10831
10911
  */
10832
10912
  static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
10913
+ /**
10914
+ * Retrieve aggregated user analytics for the admin directory.
10915
+ *
10916
+ * Supported params include `search`, `is_site_admin`, `is_verified`,
10917
+ * `user_type`, `start_date`, `end_date`, `period`, `sort_by`, and
10918
+ * `sort_order`.
10919
+ *
10920
+ * @param params Optional query parameters.
10921
+ * @returns promise
10922
+ */
10923
+ static analytics<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
10833
10924
  /**
10834
10925
  * Retrieve a comprehensive profile for a single user, including communities,
10835
10926
  * administered titles, games played, roles, billing status, social presence,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "3.3.4",
3
+ "version": "3.3.6",
4
4
  "description": "Javascript SDK for Glitch",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -25,6 +25,20 @@ class AdminUsers {
25
25
  return Requests.processRoute(AdminUsersRoute.routes.list, undefined, undefined, params);
26
26
  }
27
27
 
28
+ /**
29
+ * Retrieve aggregated user analytics for the admin directory.
30
+ *
31
+ * Supported params include `search`, `is_site_admin`, `is_verified`,
32
+ * `user_type`, `start_date`, `end_date`, `period`, `sort_by`, and
33
+ * `sort_order`.
34
+ *
35
+ * @param params Optional query parameters.
36
+ * @returns promise
37
+ */
38
+ public static analytics<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
39
+ return Requests.processRoute(AdminUsersRoute.routes.analytics, undefined, undefined, params);
40
+ }
41
+
28
42
  /**
29
43
  * Retrieve a comprehensive profile for a single user, including communities,
30
44
  * administered titles, games played, roles, billing status, social presence,
package/src/api/Agents.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import AgentsRoute from "../routes/AgentsRoute";
2
+ import AccessKeys from "./AccessKeys";
3
+ import Campaigns from "./Campaigns";
4
+ import Config from "../config/Config";
2
5
  import Requests from "../util/Requests";
3
6
  import Response from "../util/Response";
7
+ import SocialPosts from "./SocialPosts";
4
8
  import { AxiosPromise, AxiosProgressEvent } from "axios";
5
9
 
6
10
  export interface AgentRunRequest {
@@ -15,7 +19,51 @@ export interface AgentRunRequest {
15
19
  [key: string]: any;
16
20
  }
17
21
 
22
+ export interface AgentStreamAnswerRequest {
23
+ prompt: string;
24
+ [key: string]: any;
25
+ }
26
+
27
+ export interface AgentFetchOptions {
28
+ params?: Record<string, any>;
29
+ signal?: AbortSignal;
30
+ headers?: Record<string, string>;
31
+ fetcher?: typeof fetch;
32
+ }
33
+
34
+ export interface AgentStreamAnswerOptions extends AgentFetchOptions {}
35
+
18
36
  class Agents {
37
+ private static fetchWithAuth(
38
+ path: string,
39
+ init: RequestInit,
40
+ options: AgentFetchOptions = {}
41
+ ): Promise<globalThis.Response> {
42
+ const url = Requests.buildUrl(path, options.params);
43
+ const token = Config.getAuthToken?.();
44
+ const headers: Record<string, string> = {
45
+ ...((init.headers || {}) as Record<string, string>),
46
+ };
47
+
48
+ if (token && !headers.Authorization) {
49
+ headers.Authorization = `Bearer ${token}`;
50
+ }
51
+
52
+ Object.assign(headers, options.headers || {});
53
+
54
+ const fetcher = options.fetcher || (typeof globalThis !== "undefined" ? globalThis.fetch : undefined);
55
+
56
+ if (!fetcher) {
57
+ return Promise.reject(new Error("Fetch API is not available in this environment."));
58
+ }
59
+
60
+ return fetcher(url, {
61
+ ...init,
62
+ headers,
63
+ signal: options.signal,
64
+ });
65
+ }
66
+
19
67
  /**
20
68
  * List game titles that can be managed in the Agents section.
21
69
  */
@@ -93,6 +141,35 @@ class Agents {
93
141
  return Requests.processRoute(AgentsRoute.routes.runAgent, data, { title_id, agent_id }, params);
94
142
  }
95
143
 
144
+ /**
145
+ * Stream a quick advisory answer for the agent workspace.
146
+ *
147
+ * This returns the native Fetch API Response so callers can consume the
148
+ * ReadableStream body incrementally. A 409 response means streaming is
149
+ * disabled server-side and the caller should fall back to the normal run
150
+ * flow.
151
+ */
152
+ public static streamAnswer(
153
+ title_id: string,
154
+ agent_id: string,
155
+ data: AgentStreamAnswerRequest | string,
156
+ options: AgentStreamAnswerOptions = {}
157
+ ): Promise<globalThis.Response> {
158
+ const body = typeof data === "string" ? { prompt: data } : data;
159
+ const path = AgentsRoute.routes.streamAnswer.url
160
+ .replace("{title_id}", title_id)
161
+ .replace("{agent_id}", agent_id);
162
+
163
+ return Agents.fetchWithAuth(path, {
164
+ method: AgentsRoute.routes.streamAnswer.method,
165
+ headers: {
166
+ "Content-Type": "application/json",
167
+ Accept: "text/event-stream",
168
+ },
169
+ body: JSON.stringify(body),
170
+ }, options);
171
+ }
172
+
96
173
  /**
97
174
  * Upload one file for an agent run. data can include { agent_run_id }.
98
175
  */
@@ -125,6 +202,50 @@ class Agents {
125
202
  return Agents.uploadAgentFile(title_id, agent_id, file, data, params, onUploadProgress);
126
203
  }
127
204
 
205
+ /**
206
+ * List Google Drive files/folders available to attach to a title agent.
207
+ */
208
+ public static listGoogleDriveFiles<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
209
+ return Requests.processRoute(AgentsRoute.routes.listGoogleDriveFiles, {}, { title_id }, params);
210
+ }
211
+
212
+ /**
213
+ * Attach a Google Drive file as a reference file for an agent.
214
+ */
215
+ public static attachGoogleDriveFile<T>(title_id: string, agent_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
216
+ return Requests.processRoute(AgentsRoute.routes.attachGoogleDriveFile, data || {}, { title_id, agent_id }, params);
217
+ }
218
+
219
+ /**
220
+ * Download a protected agent file through the authenticated API route.
221
+ *
222
+ * Returns the native Fetch API Response so callers can inspect headers such
223
+ * as Content-Disposition before creating a browser download or preview blob.
224
+ */
225
+ public static downloadAgentFile(
226
+ title_id: string,
227
+ file_id: string,
228
+ options: AgentFetchOptions = {}
229
+ ): Promise<globalThis.Response> {
230
+ const path = AgentsRoute.routes.downloadAgentFile.url
231
+ .replace("{title_id}", title_id)
232
+ .replace("{file_id}", file_id);
233
+
234
+ return Agents.fetchWithAuth(path, {
235
+ method: AgentsRoute.routes.downloadAgentFile.method,
236
+ headers: {
237
+ Accept: "application/octet-stream",
238
+ },
239
+ }, options);
240
+ }
241
+
242
+ /**
243
+ * Export a generated agent artifact to Google Drive.
244
+ */
245
+ public static exportAgentFileToGoogleDrive<T>(title_id: string, file_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
246
+ return Requests.processRoute(AgentsRoute.routes.exportAgentFileToGoogleDrive, data || {}, { title_id, file_id }, params);
247
+ }
248
+
128
249
  /**
129
250
  * List agent runs for a title.
130
251
  */
@@ -217,6 +338,41 @@ class Agents {
217
338
  return Requests.processRoute(AgentsRoute.routes.rewriteAgentDraft, data, { title_id }, params);
218
339
  }
219
340
 
341
+ /**
342
+ * Agent workflow convenience wrapper for creator invite context.
343
+ */
344
+ public static creatorInviteContext<T>(campaign_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
345
+ return Campaigns.creatorInviteContext<T>(campaign_id, params);
346
+ }
347
+
348
+ /**
349
+ * Agent workflow convenience wrapper for sending a reviewed creator invite.
350
+ */
351
+ public static sendCreatorInvite<T>(campaign_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
352
+ return Campaigns.sendCreatorInvite<T>(campaign_id, data || {}, params);
353
+ }
354
+
355
+ /**
356
+ * Agent workflow convenience wrapper for updating a drafted social post.
357
+ */
358
+ public static updateSocialPost<T>(post_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
359
+ return SocialPosts.update<T>(post_id, data || {}, params);
360
+ }
361
+
362
+ /**
363
+ * Agent workflow convenience wrapper for updating campaign settings.
364
+ */
365
+ public static updateCampaign<T>(campaign_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
366
+ return Campaigns.update<T>(campaign_id, data || {}, params);
367
+ }
368
+
369
+ /**
370
+ * Agent workflow convenience wrapper for saving manual access keys.
371
+ */
372
+ public static createAccessKeys<T>(title_id: string, data: { platform: string, codes: string }, params?: Record<string, any>): AxiosPromise<Response<T>> {
373
+ return AccessKeys.store<T>(title_id, data, params);
374
+ }
375
+
220
376
  /**
221
377
  * List structured agent memories for a title.
222
378
  */
@@ -224,6 +380,20 @@ class Agents {
224
380
  return Requests.processRoute(AgentsRoute.routes.listMemories, {}, { title_id }, params);
225
381
  }
226
382
 
383
+ /**
384
+ * Update one structured agent memory.
385
+ */
386
+ public static updateMemory<T>(title_id: string, memory_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
387
+ return Requests.processRoute(AgentsRoute.routes.updateMemory, data || {}, { title_id, memory_id }, params);
388
+ }
389
+
390
+ /**
391
+ * Deactivate one structured agent memory.
392
+ */
393
+ public static deactivateMemory<T>(title_id: string, memory_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
394
+ return Requests.processRoute(AgentsRoute.routes.deactivateMemory, {}, { title_id, memory_id }, params);
395
+ }
396
+
227
397
  /**
228
398
  * Get results and outcome summary for title agents. Returns 402 until subscription or prepaid credits are active.
229
399
  */
@@ -560,6 +560,20 @@ class Campaigns {
560
560
  return Requests.processRoute(CampaignsRoute.routes.sendInfluencerInvite, data, { campaign_id: campaign_id }, params);
561
561
  }
562
562
 
563
+ /**
564
+ * Get creator context used when preparing a personalized invite.
565
+ */
566
+ public static creatorInviteContext<T>(campaign_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
567
+ return Requests.processRoute(CampaignsRoute.routes.influencerInviteProfileContext, {}, { campaign_id: campaign_id }, params);
568
+ }
569
+
570
+ /**
571
+ * Send a personalized creator invite after review.
572
+ */
573
+ public static sendCreatorInvite<T>(campaign_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
574
+ return Requests.processRoute(CampaignsRoute.routes.influencerInviteProfileSend, data, { campaign_id: campaign_id }, params);
575
+ }
576
+
563
577
  /**
564
578
  * Invites an influencer to join this campaign.
565
579
  *
@@ -8,6 +8,11 @@ class AdminUsersRoute {
8
8
  url: '/admin/users',
9
9
  method: HTTP_METHODS.GET
10
10
  },
11
+ // Aggregated user analytics for charts on the admin directory.
12
+ analytics: {
13
+ url: '/admin/users/analytics',
14
+ method: HTTP_METHODS.GET
15
+ },
11
16
  // Full profile for a single user (site admin only).
12
17
  view: {
13
18
  url: '/admin/users/{user_id}',
@@ -14,7 +14,12 @@ class AgentsRoute {
14
14
  updateAgent: { url: "/agents/titles/{title_id}/agents/{agent_id}", method: HTTP_METHODS.PUT },
15
15
  deleteAgent: { url: "/agents/titles/{title_id}/agents/{agent_id}", method: HTTP_METHODS.DELETE },
16
16
  runAgent: { url: "/agents/titles/{title_id}/agents/{agent_id}/run", method: HTTP_METHODS.POST },
17
+ streamAnswer: { url: "/agents/titles/{title_id}/agents/{agent_id}/stream-answer", method: HTTP_METHODS.POST },
17
18
  uploadAgentFiles: { url: "/agents/titles/{title_id}/agents/{agent_id}/files", method: HTTP_METHODS.POST },
19
+ listGoogleDriveFiles: { url: "/agents/titles/{title_id}/gmail/drive/files", method: HTTP_METHODS.GET },
20
+ attachGoogleDriveFile: { url: "/agents/titles/{title_id}/agents/{agent_id}/drive/files", method: HTTP_METHODS.POST },
21
+ downloadAgentFile: { url: "/agents/titles/{title_id}/files/{file_id}/download", method: HTTP_METHODS.GET },
22
+ exportAgentFileToGoogleDrive: { url: "/agents/titles/{title_id}/files/{file_id}/export/google-drive", method: HTTP_METHODS.POST },
18
23
  listRuns: { url: "/agents/titles/{title_id}/runs", method: HTTP_METHODS.GET },
19
24
  viewRun: { url: "/agents/titles/{title_id}/runs/{run_id}", method: HTTP_METHODS.GET },
20
25
  listRunEvents: { url: "/agents/titles/{title_id}/runs/{run_id}/events", method: HTTP_METHODS.GET },
@@ -29,6 +34,8 @@ class AgentsRoute {
29
34
  answerGuidance: { url: "/agents/titles/{title_id}/guidance/{guidance_id}/answer", method: HTTP_METHODS.POST },
30
35
  rewriteAgentDraft: { url: "/agents/titles/{title_id}/drafts/rewrite", method: HTTP_METHODS.POST },
31
36
  listMemories: { url: "/agents/titles/{title_id}/memories", method: HTTP_METHODS.GET },
37
+ updateMemory: { url: "/agents/titles/{title_id}/memories/{memory_id}", method: HTTP_METHODS.PATCH },
38
+ deactivateMemory: { url: "/agents/titles/{title_id}/memories/{memory_id}", method: HTTP_METHODS.DELETE },
32
39
  results: { url: "/agents/titles/{title_id}/results", method: HTTP_METHODS.GET },
33
40
  usage: { url: "/agents/titles/{title_id}/usage", method: HTTP_METHODS.GET },
34
41
  credits: { url: "/agents/titles/{title_id}/credits", method: HTTP_METHODS.GET },
@@ -45,6 +45,8 @@ class CampaignsRoute {
45
45
  addType: { url: '/campaigns/{campaign_id}/addType', method: HTTP_METHODS.POST },
46
46
  removeType: { url: '/campaigns/{campaign_id}/removeType/{type_id}', method: HTTP_METHODS.DELETE },
47
47
  inviteInfluencer: { url: '/campaigns/{campaign_id}/influencers/invites', method: HTTP_METHODS.POST },
48
+ influencerInviteProfileContext: { url: '/campaigns/{campaign_id}/influencers/invites/profile-context', method: HTTP_METHODS.GET },
49
+ influencerInviteProfileSend: { url: '/campaigns/{campaign_id}/influencers/invites/profile-send', method: HTTP_METHODS.POST },
48
50
  viewInfluencerInvite: { url: '/campaigns/{campaign_id}/influencers/invites/{influencer_id}', method: HTTP_METHODS.GET },
49
51
  updateInfluencerInvite: { url: '/campaigns/{campaign_id}/influencers/invites/{influencer_id}', method: HTTP_METHODS.PUT },
50
52
  updateInfluencerCompensationInvite: { url: '/campaigns/{campaign_id}/influencers/invites/{influencer_id}/compensation', method: HTTP_METHODS.PUT },