glitch-javascript-sdk 3.2.10 → 3.2.12

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/cjs/index.js CHANGED
@@ -17324,6 +17324,35 @@ var Requests = /** @class */ (function () {
17324
17324
  Requests.setCommunityID = function (community_id) {
17325
17325
  Requests.community_id = community_id;
17326
17326
  };
17327
+ /**
17328
+ * Build an absolute API URL using the currently configured base URL.
17329
+ *
17330
+ * This is useful for browser primitives such as EventSource that need a URL
17331
+ * string instead of an Axios request wrapper.
17332
+ */
17333
+ Requests.buildUrl = function (url, params) {
17334
+ var path = url;
17335
+ if (params && Object.keys(params).length > 0) {
17336
+ var queryString = Object.entries(params)
17337
+ .filter(function (_a) {
17338
+ var value = _a[1];
17339
+ return value !== undefined && value !== null && value !== '';
17340
+ })
17341
+ .map(function (_a) {
17342
+ var key = _a[0], value = _a[1];
17343
+ if (Array.isArray(value)) {
17344
+ return value.map(function (item) { return "".concat(key, "[]=").concat(encodeURIComponent(item)); }).join('&');
17345
+ }
17346
+ return "".concat(key, "=").concat(encodeURIComponent(value));
17347
+ })
17348
+ .filter(Boolean)
17349
+ .join('&');
17350
+ if (queryString) {
17351
+ path = "".concat(path).concat(path.includes('?') ? '&' : '?').concat(queryString);
17352
+ }
17353
+ }
17354
+ return Requests.baseUrl.replace(/\/+$/, '') + '/' + path.replace(/^\/+/, '');
17355
+ };
17327
17356
  Requests.request = function (method, url, data, fileData) {
17328
17357
  var headers = {
17329
17358
  'Content-Type': 'application/json',
@@ -20829,6 +20858,7 @@ var UserRoutes = /** @class */ (function () {
20829
20858
  clearTwitchAuth: { url: '/users/clearTwitchAuth', method: HTTP_METHODS.DELETE },
20830
20859
  clearFacebookAuth: { url: '/users/clearFacebookAuth', method: HTTP_METHODS.DELETE },
20831
20860
  clearGoogleAuth: { url: '/users/clearGoogleAuth', method: HTTP_METHODS.DELETE },
20861
+ clearGmailAuth: { url: '/users/clearGmailAuth', method: HTTP_METHODS.DELETE },
20832
20862
  clearStripeAuth: { url: '/users/clearStripeAuth', method: HTTP_METHODS.DELETE },
20833
20863
  clearTikTokAuth: { url: '/users/clearTikTokAuth', method: HTTP_METHODS.DELETE },
20834
20864
  clearYoutubeAuth: { url: '/users/clearYoutubeAuth', method: HTTP_METHODS.DELETE },
@@ -21094,6 +21124,16 @@ var Users = /** @class */ (function () {
21094
21124
  Users.clearGoogleAuth = function () {
21095
21125
  return Requests.processRoute(UserRoutes.routes.clearGoogleAuth, {});
21096
21126
  };
21127
+ /**
21128
+ * Clear Gmail Workspace authentication information from the current user.
21129
+ *
21130
+ * @see https://api.glitch.fun/api/documentation#/Users%20Route/clearGmailAuth
21131
+ *
21132
+ * @returns promise
21133
+ */
21134
+ Users.clearGmailAuth = function () {
21135
+ return Requests.processRoute(UserRoutes.routes.clearGmailAuth, {});
21136
+ };
21097
21137
  /**
21098
21138
  * Clear Stripe authentication information from the current user.
21099
21139
  *
@@ -31064,6 +31104,7 @@ var AgentsRoute = /** @class */ (function () {
31064
31104
  executeAction: { url: "/agents/titles/{title_id}/actions/{action_id}/execute", method: HTTP_METHODS.POST },
31065
31105
  listGuidance: { url: "/agents/titles/{title_id}/guidance", method: HTTP_METHODS.GET },
31066
31106
  answerGuidance: { url: "/agents/titles/{title_id}/guidance/{guidance_id}/answer", method: HTTP_METHODS.POST },
31107
+ rewriteAgentDraft: { url: "/agents/titles/{title_id}/drafts/rewrite", method: HTTP_METHODS.POST },
31067
31108
  listMemories: { url: "/agents/titles/{title_id}/memories", method: HTTP_METHODS.GET },
31068
31109
  results: { url: "/agents/titles/{title_id}/results", method: HTTP_METHODS.GET },
31069
31110
  usage: { url: "/agents/titles/{title_id}/usage", method: HTTP_METHODS.GET },
@@ -31223,6 +31264,12 @@ var Agents = /** @class */ (function () {
31223
31264
  Agents.answerGuidance = function (title_id, guidance_id, data, params) {
31224
31265
  return Requests.processRoute(AgentsRoute.routes.answerGuidance, data, { title_id: title_id, guidance_id: guidance_id }, params);
31225
31266
  };
31267
+ /**
31268
+ * Rewrite an editable agent draft for review without executing the parent action.
31269
+ */
31270
+ Agents.rewriteAgentDraft = function (title_id, data, params) {
31271
+ return Requests.processRoute(AgentsRoute.routes.rewriteAgentDraft, data, { title_id: title_id }, params);
31272
+ };
31226
31273
  /**
31227
31274
  * List structured agent memories for a title.
31228
31275
  */
@@ -31288,6 +31335,152 @@ var Agents = /** @class */ (function () {
31288
31335
  return Agents;
31289
31336
  }());
31290
31337
 
31338
+ /**
31339
+ * Glitch MCP paid facade (/mcp/v1).
31340
+ *
31341
+ * Mirrors the routes served by McpAgentController. These endpoints authenticate
31342
+ * with either a Glitch user JWT or a title-scoped MCP token and keep all planner,
31343
+ * billing, and executor logic server-side. The public @glitch/mcp adapter calls
31344
+ * the same endpoints; this SDK surface lets first-party TypeScript clients reuse them.
31345
+ */
31346
+ var McpRoute = /** @class */ (function () {
31347
+ function McpRoute() {
31348
+ }
31349
+ McpRoute.routes = {
31350
+ authStatus: { url: "/mcp/v1/auth/status", method: HTTP_METHODS.GET },
31351
+ listTitles: { url: "/mcp/v1/titles", method: HTTP_METHODS.GET },
31352
+ titleContext: { url: "/mcp/v1/titles/{title_id}/context", method: HTTP_METHODS.GET },
31353
+ billing: { url: "/mcp/v1/titles/{title_id}/billing", method: HTTP_METHODS.GET },
31354
+ startRun: { url: "/mcp/v1/titles/{title_id}/runs", method: HTTP_METHODS.POST },
31355
+ viewRun: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}", method: HTTP_METHODS.GET },
31356
+ runEvents: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/events", method: HTTP_METHODS.GET },
31357
+ streamRun: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/stream", method: HTTP_METHODS.GET },
31358
+ finalReport: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/report", method: HTTP_METHODS.GET },
31359
+ artifacts: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/artifacts", method: HTTP_METHODS.GET },
31360
+ listActions: { url: "/mcp/v1/titles/{title_id}/actions", method: HTTP_METHODS.GET },
31361
+ approveAction: { url: "/mcp/v1/titles/{title_id}/actions/{action_id}/approve", method: HTTP_METHODS.POST },
31362
+ rejectAction: { url: "/mcp/v1/titles/{title_id}/actions/{action_id}/reject", method: HTTP_METHODS.POST },
31363
+ executeAction: { url: "/mcp/v1/titles/{title_id}/actions/{action_id}/execute", method: HTTP_METHODS.POST },
31364
+ listGuidance: { url: "/mcp/v1/titles/{title_id}/guidance", method: HTTP_METHODS.GET },
31365
+ answerGuidance: { url: "/mcp/v1/titles/{title_id}/guidance/{guidance_id}/answer", method: HTTP_METHODS.POST },
31366
+ createUpload: { url: "/mcp/v1/titles/{title_id}/uploads", method: HTTP_METHODS.POST },
31367
+ uploadFile: { url: "/mcp/v1/titles/{title_id}/files", method: HTTP_METHODS.POST },
31368
+ listTokens: { url: "/mcp/v1/titles/{title_id}/tokens", method: HTTP_METHODS.GET },
31369
+ createToken: { url: "/mcp/v1/titles/{title_id}/tokens", method: HTTP_METHODS.POST },
31370
+ revokeToken: { url: "/mcp/v1/titles/{title_id}/tokens/{token_id}", method: HTTP_METHODS.DELETE },
31371
+ };
31372
+ return McpRoute;
31373
+ }());
31374
+
31375
+ /**
31376
+ * Client for the Glitch MCP paid facade (/mcp/v1).
31377
+ *
31378
+ * Authenticate with a Glitch user JWT or a title-scoped MCP token. The facade
31379
+ * enforces subscription, title permissions, scope, and approval guardrails on
31380
+ * every call; this client only forwards requests.
31381
+ */
31382
+ var Mcp = /** @class */ (function () {
31383
+ function Mcp() {
31384
+ }
31385
+ /** Health/auth probe. Returns authenticated=false (200) when no credential is set. */
31386
+ Mcp.authStatus = function (params) {
31387
+ return Requests.processRoute(McpRoute.routes.authStatus, {}, {}, params);
31388
+ };
31389
+ /** List titles visible to the current user token or title-scoped MCP token. */
31390
+ Mcp.listTitles = function (params) {
31391
+ return Requests.processRoute(McpRoute.routes.listTitles, {}, {}, params);
31392
+ };
31393
+ /** Fetch safe, subscription-gated workspace context for a title. */
31394
+ Mcp.titleContext = function (title_id, params) {
31395
+ return Requests.processRoute(McpRoute.routes.titleContext, {}, { title_id: title_id }, params);
31396
+ };
31397
+ /** Check subscription, trial, plan, and credit state for a title. */
31398
+ Mcp.billing = function (title_id, params) {
31399
+ return Requests.processRoute(McpRoute.routes.billing, {}, { title_id: title_id }, params);
31400
+ };
31401
+ /** Start a paid Glitch Agent run for a title. */
31402
+ Mcp.startRun = function (title_id, data, params) {
31403
+ return Requests.processRoute(McpRoute.routes.startRun, data !== null && data !== void 0 ? data : {}, { title_id: title_id }, params);
31404
+ };
31405
+ /** Fetch a durable run with status, actions, guidance, events, files, and report. */
31406
+ Mcp.viewRun = function (title_id, run_id, params) {
31407
+ return Requests.processRoute(McpRoute.routes.viewRun, {}, { title_id: title_id, run_id: run_id }, params);
31408
+ };
31409
+ /** List user-visible timeline events for a run. */
31410
+ Mcp.runEvents = function (title_id, run_id, params) {
31411
+ return Requests.processRoute(McpRoute.routes.runEvents, {}, { title_id: title_id, run_id: run_id }, params);
31412
+ };
31413
+ /** Fetch the human-friendly final or partial report for a run. */
31414
+ Mcp.finalReport = function (title_id, run_id, params) {
31415
+ return Requests.processRoute(McpRoute.routes.finalReport, {}, { title_id: title_id, run_id: run_id }, params);
31416
+ };
31417
+ /**
31418
+ * Server-Sent Events URL for a run's live event stream.
31419
+ *
31420
+ * Returns the absolute URL to open with an EventSource/fetch reader; the
31421
+ * endpoint emits `status`, `run_event`, and a terminal `settled`/`timeout` event.
31422
+ */
31423
+ Mcp.runStreamUrl = function (title_id, run_id, params) {
31424
+ var url = McpRoute.routes.streamRun.url
31425
+ .replace("{title_id}", encodeURIComponent(title_id))
31426
+ .replace("{run_id}", encodeURIComponent(run_id));
31427
+ return Requests.buildUrl(url, params);
31428
+ };
31429
+ /** List downloadable files and hosted report artifacts for a run. */
31430
+ Mcp.artifacts = function (title_id, run_id, params) {
31431
+ return Requests.processRoute(McpRoute.routes.artifacts, {}, { title_id: title_id, run_id: run_id }, params);
31432
+ };
31433
+ /** List proposed/guidance/approval/executed actions for a title. */
31434
+ Mcp.listActions = function (title_id, params) {
31435
+ return Requests.processRoute(McpRoute.routes.listActions, {}, { title_id: title_id }, params);
31436
+ };
31437
+ /** Approve a reviewable action. Execution remains guarded server-side. */
31438
+ Mcp.approveAction = function (title_id, action_id, data, params) {
31439
+ return Requests.processRoute(McpRoute.routes.approveAction, data !== null && data !== void 0 ? data : {}, { title_id: title_id, action_id: action_id }, params);
31440
+ };
31441
+ /** Reject a proposed or approval-needed action. */
31442
+ Mcp.rejectAction = function (title_id, action_id, data, params) {
31443
+ return Requests.processRoute(McpRoute.routes.rejectAction, data !== null && data !== void 0 ? data : {}, { title_id: title_id, action_id: action_id }, params);
31444
+ };
31445
+ /** Execute an approved action. Public/paid/creator-facing work stays guarded. */
31446
+ Mcp.executeAction = function (title_id, action_id, data, params) {
31447
+ return Requests.processRoute(McpRoute.routes.executeAction, data !== null && data !== void 0 ? data : {}, { title_id: title_id, action_id: action_id }, params);
31448
+ };
31449
+ /** List open or answered guidance requests for a title or run. */
31450
+ Mcp.listGuidance = function (title_id, params) {
31451
+ return Requests.processRoute(McpRoute.routes.listGuidance, {}, { title_id: title_id }, params);
31452
+ };
31453
+ /** Answer a guidance request and resume the server-side workflow when possible. */
31454
+ Mcp.answerGuidance = function (title_id, guidance_id, data, params) {
31455
+ return Requests.processRoute(McpRoute.routes.answerGuidance, data !== null && data !== void 0 ? data : {}, { title_id: title_id, guidance_id: guidance_id }, params);
31456
+ };
31457
+ /** Get instructions for uploading a file (points at uploadFile below). */
31458
+ Mcp.createUpload = function (title_id, data, params) {
31459
+ return Requests.processRoute(McpRoute.routes.createUpload, data !== null && data !== void 0 ? data : {}, { title_id: title_id }, params);
31460
+ };
31461
+ /**
31462
+ * Upload a file (image, video, or document) to a title or run as multipart/form-data.
31463
+ * The facade re-checks the title scope, subscription, and allowed mime types.
31464
+ */
31465
+ Mcp.uploadFile = function (title_id, file, data, params, onUploadProgress) {
31466
+ var url = McpRoute.routes.uploadFile.url.replace("{title_id}", title_id);
31467
+ return Requests.uploadFile(url, "file", file, data, params, onUploadProgress);
31468
+ };
31469
+ /** List MCP title tokens (user JWT only). */
31470
+ Mcp.listTokens = function (title_id, params) {
31471
+ return Requests.processRoute(McpRoute.routes.listTokens, {}, { title_id: title_id }, params);
31472
+ };
31473
+ /** Create a revocable title-scoped MCP token (user JWT only). */
31474
+ Mcp.createToken = function (title_id, data, params) {
31475
+ return Requests.processRoute(McpRoute.routes.createToken, data !== null && data !== void 0 ? data : {}, { title_id: title_id }, params);
31476
+ };
31477
+ /** Revoke a title-scoped MCP token (user JWT only). */
31478
+ Mcp.revokeToken = function (title_id, token_id, params) {
31479
+ return Requests.processRoute(McpRoute.routes.revokeToken, {}, { title_id: title_id, token_id: token_id }, params);
31480
+ };
31481
+ return Mcp;
31482
+ }());
31483
+
31291
31484
  /**
31292
31485
  * Route declarations for the PR Directory API.
31293
31486
  *
@@ -31947,6 +32140,7 @@ var Glitch = /** @class */ (function () {
31947
32140
  Multiplayer: Multiplayer,
31948
32141
  ServerOperations: ServerOperations,
31949
32142
  Agents: Agents,
32143
+ Mcp: Mcp,
31950
32144
  PrDirectory: PrDirectory,
31951
32145
  };
31952
32146
  Glitch.util = {