glitch-javascript-sdk 3.2.9 → 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/esm/index.js CHANGED
@@ -5326,6 +5326,35 @@ var Requests = /** @class */ (function () {
5326
5326
  Requests.setCommunityID = function (community_id) {
5327
5327
  Requests.community_id = community_id;
5328
5328
  };
5329
+ /**
5330
+ * Build an absolute API URL using the currently configured base URL.
5331
+ *
5332
+ * This is useful for browser primitives such as EventSource that need a URL
5333
+ * string instead of an Axios request wrapper.
5334
+ */
5335
+ Requests.buildUrl = function (url, params) {
5336
+ var path = url;
5337
+ if (params && Object.keys(params).length > 0) {
5338
+ var queryString = Object.entries(params)
5339
+ .filter(function (_a) {
5340
+ var value = _a[1];
5341
+ return value !== undefined && value !== null && value !== '';
5342
+ })
5343
+ .map(function (_a) {
5344
+ var key = _a[0], value = _a[1];
5345
+ if (Array.isArray(value)) {
5346
+ return value.map(function (item) { return "".concat(key, "[]=").concat(encodeURIComponent(item)); }).join('&');
5347
+ }
5348
+ return "".concat(key, "=").concat(encodeURIComponent(value));
5349
+ })
5350
+ .filter(Boolean)
5351
+ .join('&');
5352
+ if (queryString) {
5353
+ path = "".concat(path).concat(path.includes('?') ? '&' : '?').concat(queryString);
5354
+ }
5355
+ }
5356
+ return Requests.baseUrl.replace(/\/+$/, '') + '/' + path.replace(/^\/+/, '');
5357
+ };
5329
5358
  Requests.request = function (method, url, data, fileData) {
5330
5359
  var headers = {
5331
5360
  'Content-Type': 'application/json',
@@ -8831,6 +8860,7 @@ var UserRoutes = /** @class */ (function () {
8831
8860
  clearTwitchAuth: { url: '/users/clearTwitchAuth', method: HTTP_METHODS.DELETE },
8832
8861
  clearFacebookAuth: { url: '/users/clearFacebookAuth', method: HTTP_METHODS.DELETE },
8833
8862
  clearGoogleAuth: { url: '/users/clearGoogleAuth', method: HTTP_METHODS.DELETE },
8863
+ clearGmailAuth: { url: '/users/clearGmailAuth', method: HTTP_METHODS.DELETE },
8834
8864
  clearStripeAuth: { url: '/users/clearStripeAuth', method: HTTP_METHODS.DELETE },
8835
8865
  clearTikTokAuth: { url: '/users/clearTikTokAuth', method: HTTP_METHODS.DELETE },
8836
8866
  clearYoutubeAuth: { url: '/users/clearYoutubeAuth', method: HTTP_METHODS.DELETE },
@@ -9096,6 +9126,16 @@ var Users = /** @class */ (function () {
9096
9126
  Users.clearGoogleAuth = function () {
9097
9127
  return Requests.processRoute(UserRoutes.routes.clearGoogleAuth, {});
9098
9128
  };
9129
+ /**
9130
+ * Clear Gmail Workspace authentication information from the current user.
9131
+ *
9132
+ * @see https://api.glitch.fun/api/documentation#/Users%20Route/clearGmailAuth
9133
+ *
9134
+ * @returns promise
9135
+ */
9136
+ Users.clearGmailAuth = function () {
9137
+ return Requests.processRoute(UserRoutes.routes.clearGmailAuth, {});
9138
+ };
9099
9139
  /**
9100
9140
  * Clear Stripe authentication information from the current user.
9101
9141
  *
@@ -19066,6 +19106,7 @@ var AgentsRoute = /** @class */ (function () {
19066
19106
  executeAction: { url: "/agents/titles/{title_id}/actions/{action_id}/execute", method: HTTP_METHODS.POST },
19067
19107
  listGuidance: { url: "/agents/titles/{title_id}/guidance", method: HTTP_METHODS.GET },
19068
19108
  answerGuidance: { url: "/agents/titles/{title_id}/guidance/{guidance_id}/answer", method: HTTP_METHODS.POST },
19109
+ rewriteAgentDraft: { url: "/agents/titles/{title_id}/drafts/rewrite", method: HTTP_METHODS.POST },
19069
19110
  listMemories: { url: "/agents/titles/{title_id}/memories", method: HTTP_METHODS.GET },
19070
19111
  results: { url: "/agents/titles/{title_id}/results", method: HTTP_METHODS.GET },
19071
19112
  usage: { url: "/agents/titles/{title_id}/usage", method: HTTP_METHODS.GET },
@@ -19225,6 +19266,12 @@ var Agents = /** @class */ (function () {
19225
19266
  Agents.answerGuidance = function (title_id, guidance_id, data, params) {
19226
19267
  return Requests.processRoute(AgentsRoute.routes.answerGuidance, data, { title_id: title_id, guidance_id: guidance_id }, params);
19227
19268
  };
19269
+ /**
19270
+ * Rewrite an editable agent draft for review without executing the parent action.
19271
+ */
19272
+ Agents.rewriteAgentDraft = function (title_id, data, params) {
19273
+ return Requests.processRoute(AgentsRoute.routes.rewriteAgentDraft, data, { title_id: title_id }, params);
19274
+ };
19228
19275
  /**
19229
19276
  * List structured agent memories for a title.
19230
19277
  */
@@ -19290,6 +19337,267 @@ var Agents = /** @class */ (function () {
19290
19337
  return Agents;
19291
19338
  }());
19292
19339
 
19340
+ /**
19341
+ * Glitch MCP paid facade (/mcp/v1).
19342
+ *
19343
+ * Mirrors the routes served by McpAgentController. These endpoints authenticate
19344
+ * with either a Glitch user JWT or a title-scoped MCP token and keep all planner,
19345
+ * billing, and executor logic server-side. The public @glitch/mcp adapter calls
19346
+ * the same endpoints; this SDK surface lets first-party TypeScript clients reuse them.
19347
+ */
19348
+ var McpRoute = /** @class */ (function () {
19349
+ function McpRoute() {
19350
+ }
19351
+ McpRoute.routes = {
19352
+ authStatus: { url: "/mcp/v1/auth/status", method: HTTP_METHODS.GET },
19353
+ listTitles: { url: "/mcp/v1/titles", method: HTTP_METHODS.GET },
19354
+ titleContext: { url: "/mcp/v1/titles/{title_id}/context", method: HTTP_METHODS.GET },
19355
+ billing: { url: "/mcp/v1/titles/{title_id}/billing", method: HTTP_METHODS.GET },
19356
+ startRun: { url: "/mcp/v1/titles/{title_id}/runs", method: HTTP_METHODS.POST },
19357
+ viewRun: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}", method: HTTP_METHODS.GET },
19358
+ runEvents: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/events", method: HTTP_METHODS.GET },
19359
+ streamRun: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/stream", method: HTTP_METHODS.GET },
19360
+ finalReport: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/report", method: HTTP_METHODS.GET },
19361
+ artifacts: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/artifacts", method: HTTP_METHODS.GET },
19362
+ listActions: { url: "/mcp/v1/titles/{title_id}/actions", method: HTTP_METHODS.GET },
19363
+ approveAction: { url: "/mcp/v1/titles/{title_id}/actions/{action_id}/approve", method: HTTP_METHODS.POST },
19364
+ rejectAction: { url: "/mcp/v1/titles/{title_id}/actions/{action_id}/reject", method: HTTP_METHODS.POST },
19365
+ executeAction: { url: "/mcp/v1/titles/{title_id}/actions/{action_id}/execute", method: HTTP_METHODS.POST },
19366
+ listGuidance: { url: "/mcp/v1/titles/{title_id}/guidance", method: HTTP_METHODS.GET },
19367
+ answerGuidance: { url: "/mcp/v1/titles/{title_id}/guidance/{guidance_id}/answer", method: HTTP_METHODS.POST },
19368
+ createUpload: { url: "/mcp/v1/titles/{title_id}/uploads", method: HTTP_METHODS.POST },
19369
+ uploadFile: { url: "/mcp/v1/titles/{title_id}/files", method: HTTP_METHODS.POST },
19370
+ listTokens: { url: "/mcp/v1/titles/{title_id}/tokens", method: HTTP_METHODS.GET },
19371
+ createToken: { url: "/mcp/v1/titles/{title_id}/tokens", method: HTTP_METHODS.POST },
19372
+ revokeToken: { url: "/mcp/v1/titles/{title_id}/tokens/{token_id}", method: HTTP_METHODS.DELETE },
19373
+ };
19374
+ return McpRoute;
19375
+ }());
19376
+
19377
+ /**
19378
+ * Client for the Glitch MCP paid facade (/mcp/v1).
19379
+ *
19380
+ * Authenticate with a Glitch user JWT or a title-scoped MCP token. The facade
19381
+ * enforces subscription, title permissions, scope, and approval guardrails on
19382
+ * every call; this client only forwards requests.
19383
+ */
19384
+ var Mcp = /** @class */ (function () {
19385
+ function Mcp() {
19386
+ }
19387
+ /** Health/auth probe. Returns authenticated=false (200) when no credential is set. */
19388
+ Mcp.authStatus = function (params) {
19389
+ return Requests.processRoute(McpRoute.routes.authStatus, {}, {}, params);
19390
+ };
19391
+ /** List titles visible to the current user token or title-scoped MCP token. */
19392
+ Mcp.listTitles = function (params) {
19393
+ return Requests.processRoute(McpRoute.routes.listTitles, {}, {}, params);
19394
+ };
19395
+ /** Fetch safe, subscription-gated workspace context for a title. */
19396
+ Mcp.titleContext = function (title_id, params) {
19397
+ return Requests.processRoute(McpRoute.routes.titleContext, {}, { title_id: title_id }, params);
19398
+ };
19399
+ /** Check subscription, trial, plan, and credit state for a title. */
19400
+ Mcp.billing = function (title_id, params) {
19401
+ return Requests.processRoute(McpRoute.routes.billing, {}, { title_id: title_id }, params);
19402
+ };
19403
+ /** Start a paid Glitch Agent run for a title. */
19404
+ Mcp.startRun = function (title_id, data, params) {
19405
+ return Requests.processRoute(McpRoute.routes.startRun, data !== null && data !== void 0 ? data : {}, { title_id: title_id }, params);
19406
+ };
19407
+ /** Fetch a durable run with status, actions, guidance, events, files, and report. */
19408
+ Mcp.viewRun = function (title_id, run_id, params) {
19409
+ return Requests.processRoute(McpRoute.routes.viewRun, {}, { title_id: title_id, run_id: run_id }, params);
19410
+ };
19411
+ /** List user-visible timeline events for a run. */
19412
+ Mcp.runEvents = function (title_id, run_id, params) {
19413
+ return Requests.processRoute(McpRoute.routes.runEvents, {}, { title_id: title_id, run_id: run_id }, params);
19414
+ };
19415
+ /** Fetch the human-friendly final or partial report for a run. */
19416
+ Mcp.finalReport = function (title_id, run_id, params) {
19417
+ return Requests.processRoute(McpRoute.routes.finalReport, {}, { title_id: title_id, run_id: run_id }, params);
19418
+ };
19419
+ /**
19420
+ * Server-Sent Events URL for a run's live event stream.
19421
+ *
19422
+ * Returns the absolute URL to open with an EventSource/fetch reader; the
19423
+ * endpoint emits `status`, `run_event`, and a terminal `settled`/`timeout` event.
19424
+ */
19425
+ Mcp.runStreamUrl = function (title_id, run_id, params) {
19426
+ var url = McpRoute.routes.streamRun.url
19427
+ .replace("{title_id}", encodeURIComponent(title_id))
19428
+ .replace("{run_id}", encodeURIComponent(run_id));
19429
+ return Requests.buildUrl(url, params);
19430
+ };
19431
+ /** List downloadable files and hosted report artifacts for a run. */
19432
+ Mcp.artifacts = function (title_id, run_id, params) {
19433
+ return Requests.processRoute(McpRoute.routes.artifacts, {}, { title_id: title_id, run_id: run_id }, params);
19434
+ };
19435
+ /** List proposed/guidance/approval/executed actions for a title. */
19436
+ Mcp.listActions = function (title_id, params) {
19437
+ return Requests.processRoute(McpRoute.routes.listActions, {}, { title_id: title_id }, params);
19438
+ };
19439
+ /** Approve a reviewable action. Execution remains guarded server-side. */
19440
+ Mcp.approveAction = function (title_id, action_id, data, params) {
19441
+ return Requests.processRoute(McpRoute.routes.approveAction, data !== null && data !== void 0 ? data : {}, { title_id: title_id, action_id: action_id }, params);
19442
+ };
19443
+ /** Reject a proposed or approval-needed action. */
19444
+ Mcp.rejectAction = function (title_id, action_id, data, params) {
19445
+ return Requests.processRoute(McpRoute.routes.rejectAction, data !== null && data !== void 0 ? data : {}, { title_id: title_id, action_id: action_id }, params);
19446
+ };
19447
+ /** Execute an approved action. Public/paid/creator-facing work stays guarded. */
19448
+ Mcp.executeAction = function (title_id, action_id, data, params) {
19449
+ return Requests.processRoute(McpRoute.routes.executeAction, data !== null && data !== void 0 ? data : {}, { title_id: title_id, action_id: action_id }, params);
19450
+ };
19451
+ /** List open or answered guidance requests for a title or run. */
19452
+ Mcp.listGuidance = function (title_id, params) {
19453
+ return Requests.processRoute(McpRoute.routes.listGuidance, {}, { title_id: title_id }, params);
19454
+ };
19455
+ /** Answer a guidance request and resume the server-side workflow when possible. */
19456
+ Mcp.answerGuidance = function (title_id, guidance_id, data, params) {
19457
+ return Requests.processRoute(McpRoute.routes.answerGuidance, data !== null && data !== void 0 ? data : {}, { title_id: title_id, guidance_id: guidance_id }, params);
19458
+ };
19459
+ /** Get instructions for uploading a file (points at uploadFile below). */
19460
+ Mcp.createUpload = function (title_id, data, params) {
19461
+ return Requests.processRoute(McpRoute.routes.createUpload, data !== null && data !== void 0 ? data : {}, { title_id: title_id }, params);
19462
+ };
19463
+ /**
19464
+ * Upload a file (image, video, or document) to a title or run as multipart/form-data.
19465
+ * The facade re-checks the title scope, subscription, and allowed mime types.
19466
+ */
19467
+ Mcp.uploadFile = function (title_id, file, data, params, onUploadProgress) {
19468
+ var url = McpRoute.routes.uploadFile.url.replace("{title_id}", title_id);
19469
+ return Requests.uploadFile(url, "file", file, data, params, onUploadProgress);
19470
+ };
19471
+ /** List MCP title tokens (user JWT only). */
19472
+ Mcp.listTokens = function (title_id, params) {
19473
+ return Requests.processRoute(McpRoute.routes.listTokens, {}, { title_id: title_id }, params);
19474
+ };
19475
+ /** Create a revocable title-scoped MCP token (user JWT only). */
19476
+ Mcp.createToken = function (title_id, data, params) {
19477
+ return Requests.processRoute(McpRoute.routes.createToken, data !== null && data !== void 0 ? data : {}, { title_id: title_id }, params);
19478
+ };
19479
+ /** Revoke a title-scoped MCP token (user JWT only). */
19480
+ Mcp.revokeToken = function (title_id, token_id, params) {
19481
+ return Requests.processRoute(McpRoute.routes.revokeToken, {}, { title_id: title_id, token_id: token_id }, params);
19482
+ };
19483
+ return Mcp;
19484
+ }());
19485
+
19486
+ /**
19487
+ * Route declarations for the PR Directory API.
19488
+ *
19489
+ * These mirror the Laravel routes under `/api/pr/*` and the title-scoped
19490
+ * matcher route under `/api/titles/{title_id}/pr/matches`. Keeping the URL
19491
+ * templates in one place lets the SDK methods stay small and consistent with
19492
+ * the rest of the package's route-wrapper pattern.
19493
+ */
19494
+ var PrDirectoryRoutes = /** @class */ (function () {
19495
+ function PrDirectoryRoutes() {
19496
+ }
19497
+ PrDirectoryRoutes.routes = {
19498
+ listPublications: { url: "/pr/publications", method: HTTP_METHODS.GET },
19499
+ viewPublication: { url: "/pr/publications/{publication_id}", method: HTTP_METHODS.GET },
19500
+ listPeople: { url: "/pr/people", method: HTTP_METHODS.GET },
19501
+ viewPerson: { url: "/pr/people/{person_id}", method: HTTP_METHODS.GET },
19502
+ listTags: { url: "/pr/tags", method: HTTP_METHODS.GET },
19503
+ report: { url: "/pr/report", method: HTTP_METHODS.GET },
19504
+ titleMatches: { url: "/titles/{title_id}/pr/matches", method: HTTP_METHODS.GET },
19505
+ queueVerification: { url: "/admin/pr/verification/queue", method: HTTP_METHODS.POST },
19506
+ };
19507
+ return PrDirectoryRoutes;
19508
+ }());
19509
+
19510
+ /**
19511
+ * SDK wrapper for the PR Directory API.
19512
+ *
19513
+ * The PR directory is read-friendly by default: public endpoints expose
19514
+ * searchable publications, people, tags, and reporting metrics. Authenticated
19515
+ * title admins can request title-specific PR matches, and site admins can queue
19516
+ * monthly-style verification jobs.
19517
+ */
19518
+ var PrDirectory = /** @class */ (function () {
19519
+ function PrDirectory() {
19520
+ }
19521
+ /**
19522
+ * Search gaming-focused PR publications, independent blogs, and podcasts.
19523
+ *
19524
+ * @example
19525
+ * ```ts
19526
+ * Glitch.api.PrDirectory.listPublications({
19527
+ * q: "indie RPG",
19528
+ * has_email: true,
19529
+ * eligibility_status: "eligible",
19530
+ * sort: "-last_verified_at",
19531
+ * });
19532
+ * ```
19533
+ */
19534
+ PrDirectory.listPublications = function (params) {
19535
+ return Requests.processRoute(PrDirectoryRoutes.routes.listPublications, {}, {}, params);
19536
+ };
19537
+ /**
19538
+ * Retrieve one PR publication profile with loaded people, contact points,
19539
+ * evidence links, and tags.
19540
+ */
19541
+ PrDirectory.viewPublication = function (publication_id, params) {
19542
+ return Requests.processRoute(PrDirectoryRoutes.routes.viewPublication, {}, { publication_id: publication_id }, params);
19543
+ };
19544
+ /**
19545
+ * Search PR people and roles across all known publications.
19546
+ *
19547
+ * @example
19548
+ * ```ts
19549
+ * Glitch.api.PrDirectory.listPeople({
19550
+ * q: "reviews editor",
19551
+ * has_email: true,
19552
+ * role_category: "editor",
19553
+ * });
19554
+ * ```
19555
+ */
19556
+ PrDirectory.listPeople = function (params) {
19557
+ return Requests.processRoute(PrDirectoryRoutes.routes.listPeople, {}, {}, params);
19558
+ };
19559
+ /**
19560
+ * Retrieve one PR person profile with their outlet roles, profile links,
19561
+ * contact points, and metadata tags.
19562
+ */
19563
+ PrDirectory.viewPerson = function (person_id, params) {
19564
+ return Requests.processRoute(PrDirectoryRoutes.routes.viewPerson, {}, { person_id: person_id }, params);
19565
+ };
19566
+ /**
19567
+ * List the normalized tag vocabulary used for PR search, filters, matching,
19568
+ * and reporting.
19569
+ */
19570
+ PrDirectory.listTags = function (params) {
19571
+ return Requests.processRoute(PrDirectoryRoutes.routes.listTags, {}, {}, params);
19572
+ };
19573
+ /**
19574
+ * Get aggregate PR directory reporting metrics. Publication filters can be
19575
+ * supplied to scope the outlet portion of the report.
19576
+ */
19577
+ PrDirectory.report = function (params) {
19578
+ return Requests.processRoute(PrDirectoryRoutes.routes.report, {}, {}, params);
19579
+ };
19580
+ /**
19581
+ * Match a registered game title to PR outlets. Requires an auth token for a
19582
+ * user who can administer the requested title.
19583
+ */
19584
+ PrDirectory.titleMatches = function (title_id, params) {
19585
+ return Requests.processRoute(PrDirectoryRoutes.routes.titleMatches, {}, { title_id: title_id }, params);
19586
+ };
19587
+ /**
19588
+ * Queue PR verification jobs. Requires a site-admin auth token.
19589
+ *
19590
+ * @example
19591
+ * ```ts
19592
+ * Glitch.api.PrDirectory.queueVerification({ due: true, limit: 250 });
19593
+ * ```
19594
+ */
19595
+ PrDirectory.queueVerification = function (data, params) {
19596
+ return Requests.processRoute(PrDirectoryRoutes.routes.queueVerification, data || {}, {}, params);
19597
+ };
19598
+ return PrDirectory;
19599
+ }());
19600
+
19293
19601
  var Parser = /** @class */ (function () {
19294
19602
  function Parser() {
19295
19603
  }
@@ -19834,6 +20142,8 @@ var Glitch = /** @class */ (function () {
19834
20142
  Multiplayer: Multiplayer,
19835
20143
  ServerOperations: ServerOperations,
19836
20144
  Agents: Agents,
20145
+ Mcp: Mcp,
20146
+ PrDirectory: PrDirectory,
19837
20147
  };
19838
20148
  Glitch.util = {
19839
20149
  Requests: Requests,