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 +194 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Agents.d.ts +4 -0
- package/dist/esm/api/Mcp.d.ts +73 -0
- package/dist/esm/api/Users.d.ts +8 -0
- package/dist/esm/api/index.d.ts +2 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +194 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/models/user.d.ts +10 -0
- package/dist/esm/routes/McpRoute.d.ts +15 -0
- package/dist/esm/util/Requests.d.ts +7 -0
- package/dist/index.d.ts +91 -0
- package/package.json +1 -1
- package/src/api/Agents.ts +7 -0
- package/src/api/Mcp.ts +150 -0
- package/src/api/Users.ts +13 -1
- package/src/api/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/models/user.ts +10 -1
- package/src/routes/AgentsRoute.ts +1 -0
- package/src/routes/McpRoute.ts +38 -0
- package/src/routes/UserRoutes.ts +2 -1
- package/src/util/Requests.ts +29 -0
|
@@ -23,6 +23,16 @@ interface User {
|
|
|
23
23
|
twitch_handle?: string;
|
|
24
24
|
youtube_handle?: string;
|
|
25
25
|
paetron_handle?: string;
|
|
26
|
+
gmail_oauth_token?: string;
|
|
27
|
+
gmail_refresh_token?: string;
|
|
28
|
+
gmail_token_expiration?: number;
|
|
29
|
+
gmail_token_expires_at?: string;
|
|
30
|
+
gmail_id?: string;
|
|
31
|
+
gmail_name?: string;
|
|
32
|
+
gmail_email?: string;
|
|
33
|
+
gmail_avatar?: string;
|
|
34
|
+
gmail_scopes?: string[];
|
|
35
|
+
gmail_connected_at?: string;
|
|
26
36
|
created_at?: string;
|
|
27
37
|
updated_at?: string;
|
|
28
38
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Route from "./interface";
|
|
2
|
+
/**
|
|
3
|
+
* Glitch MCP paid facade (/mcp/v1).
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the routes served by McpAgentController. These endpoints authenticate
|
|
6
|
+
* with either a Glitch user JWT or a title-scoped MCP token and keep all planner,
|
|
7
|
+
* billing, and executor logic server-side. The public @glitch/mcp adapter calls
|
|
8
|
+
* the same endpoints; this SDK surface lets first-party TypeScript clients reuse them.
|
|
9
|
+
*/
|
|
10
|
+
declare class McpRoute {
|
|
11
|
+
static routes: {
|
|
12
|
+
[key: string]: Route;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export default McpRoute;
|
|
@@ -11,6 +11,13 @@ declare class Requests {
|
|
|
11
11
|
static setBaseUrl(url: string): void;
|
|
12
12
|
static setAuthToken(token: string): void;
|
|
13
13
|
static setCommunityID(community_id: string | undefined): void;
|
|
14
|
+
/**
|
|
15
|
+
* Build an absolute API URL using the currently configured base URL.
|
|
16
|
+
*
|
|
17
|
+
* This is useful for browser primitives such as EventSource that need a URL
|
|
18
|
+
* string instead of an Axios request wrapper.
|
|
19
|
+
*/
|
|
20
|
+
static buildUrl(url: string, params?: Record<string, any>): string;
|
|
14
21
|
private static request;
|
|
15
22
|
static get<T>(url: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
16
23
|
static post<T>(url: string, data: any, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2060,6 +2060,14 @@ declare class Users {
|
|
|
2060
2060
|
* @returns promise
|
|
2061
2061
|
*/
|
|
2062
2062
|
static clearGoogleAuth<T>(): AxiosPromise<Response<T>>;
|
|
2063
|
+
/**
|
|
2064
|
+
* Clear Gmail Workspace authentication information from the current user.
|
|
2065
|
+
*
|
|
2066
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/clearGmailAuth
|
|
2067
|
+
*
|
|
2068
|
+
* @returns promise
|
|
2069
|
+
*/
|
|
2070
|
+
static clearGmailAuth<T>(): AxiosPromise<Response<T>>;
|
|
2063
2071
|
/**
|
|
2064
2072
|
* Clear Stripe authentication information from the current user.
|
|
2065
2073
|
*
|
|
@@ -9305,6 +9313,10 @@ declare class Agents {
|
|
|
9305
9313
|
* Answer a guidance request and write structured agent memory.
|
|
9306
9314
|
*/
|
|
9307
9315
|
static answerGuidance<T>(title_id: string, guidance_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9316
|
+
/**
|
|
9317
|
+
* Rewrite an editable agent draft for review without executing the parent action.
|
|
9318
|
+
*/
|
|
9319
|
+
static rewriteAgentDraft<T>(title_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9308
9320
|
/**
|
|
9309
9321
|
* List structured agent memories for a title.
|
|
9310
9322
|
*/
|
|
@@ -9349,6 +9361,77 @@ declare class Agents {
|
|
|
9349
9361
|
static agencyInbox<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9350
9362
|
}
|
|
9351
9363
|
|
|
9364
|
+
interface McpStartRunRequest {
|
|
9365
|
+
agent_id?: string | null;
|
|
9366
|
+
initial_message?: string | null;
|
|
9367
|
+
prompt?: string | null;
|
|
9368
|
+
run_type?: string;
|
|
9369
|
+
trigger_source?: string;
|
|
9370
|
+
background?: boolean;
|
|
9371
|
+
live_mode?: boolean;
|
|
9372
|
+
attachment_ids?: string[];
|
|
9373
|
+
[key: string]: any;
|
|
9374
|
+
}
|
|
9375
|
+
/**
|
|
9376
|
+
* Client for the Glitch MCP paid facade (/mcp/v1).
|
|
9377
|
+
*
|
|
9378
|
+
* Authenticate with a Glitch user JWT or a title-scoped MCP token. The facade
|
|
9379
|
+
* enforces subscription, title permissions, scope, and approval guardrails on
|
|
9380
|
+
* every call; this client only forwards requests.
|
|
9381
|
+
*/
|
|
9382
|
+
declare class Mcp {
|
|
9383
|
+
/** Health/auth probe. Returns authenticated=false (200) when no credential is set. */
|
|
9384
|
+
static authStatus<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9385
|
+
/** List titles visible to the current user token or title-scoped MCP token. */
|
|
9386
|
+
static listTitles<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9387
|
+
/** Fetch safe, subscription-gated workspace context for a title. */
|
|
9388
|
+
static titleContext<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9389
|
+
/** Check subscription, trial, plan, and credit state for a title. */
|
|
9390
|
+
static billing<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9391
|
+
/** Start a paid Glitch Agent run for a title. */
|
|
9392
|
+
static startRun<T>(title_id: string, data?: McpStartRunRequest, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9393
|
+
/** Fetch a durable run with status, actions, guidance, events, files, and report. */
|
|
9394
|
+
static viewRun<T>(title_id: string, run_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9395
|
+
/** List user-visible timeline events for a run. */
|
|
9396
|
+
static runEvents<T>(title_id: string, run_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9397
|
+
/** Fetch the human-friendly final or partial report for a run. */
|
|
9398
|
+
static finalReport<T>(title_id: string, run_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9399
|
+
/**
|
|
9400
|
+
* Server-Sent Events URL for a run's live event stream.
|
|
9401
|
+
*
|
|
9402
|
+
* Returns the absolute URL to open with an EventSource/fetch reader; the
|
|
9403
|
+
* endpoint emits `status`, `run_event`, and a terminal `settled`/`timeout` event.
|
|
9404
|
+
*/
|
|
9405
|
+
static runStreamUrl(title_id: string, run_id: string, params?: Record<string, any>): string;
|
|
9406
|
+
/** List downloadable files and hosted report artifacts for a run. */
|
|
9407
|
+
static artifacts<T>(title_id: string, run_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9408
|
+
/** List proposed/guidance/approval/executed actions for a title. */
|
|
9409
|
+
static listActions<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9410
|
+
/** Approve a reviewable action. Execution remains guarded server-side. */
|
|
9411
|
+
static approveAction<T>(title_id: string, action_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9412
|
+
/** Reject a proposed or approval-needed action. */
|
|
9413
|
+
static rejectAction<T>(title_id: string, action_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9414
|
+
/** Execute an approved action. Public/paid/creator-facing work stays guarded. */
|
|
9415
|
+
static executeAction<T>(title_id: string, action_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9416
|
+
/** List open or answered guidance requests for a title or run. */
|
|
9417
|
+
static listGuidance<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9418
|
+
/** Answer a guidance request and resume the server-side workflow when possible. */
|
|
9419
|
+
static answerGuidance<T>(title_id: string, guidance_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9420
|
+
/** Get instructions for uploading a file (points at uploadFile below). */
|
|
9421
|
+
static createUpload<T>(title_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9422
|
+
/**
|
|
9423
|
+
* Upload a file (image, video, or document) to a title or run as multipart/form-data.
|
|
9424
|
+
* The facade re-checks the title scope, subscription, and allowed mime types.
|
|
9425
|
+
*/
|
|
9426
|
+
static uploadFile<T>(title_id: string, file: File | Blob, data?: object, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
|
|
9427
|
+
/** List MCP title tokens (user JWT only). */
|
|
9428
|
+
static listTokens<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9429
|
+
/** Create a revocable title-scoped MCP token (user JWT only). */
|
|
9430
|
+
static createToken<T>(title_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9431
|
+
/** Revoke a title-scoped MCP token (user JWT only). */
|
|
9432
|
+
static revokeToken<T>(title_id: string, token_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9433
|
+
}
|
|
9434
|
+
|
|
9352
9435
|
/**
|
|
9353
9436
|
* Allowed outlet types in the PR directory.
|
|
9354
9437
|
*/
|
|
@@ -9747,6 +9830,13 @@ declare class Requests {
|
|
|
9747
9830
|
static setBaseUrl(url: string): void;
|
|
9748
9831
|
static setAuthToken(token: string): void;
|
|
9749
9832
|
static setCommunityID(community_id: string | undefined): void;
|
|
9833
|
+
/**
|
|
9834
|
+
* Build an absolute API URL using the currently configured base URL.
|
|
9835
|
+
*
|
|
9836
|
+
* This is useful for browser primitives such as EventSource that need a URL
|
|
9837
|
+
* string instead of an Axios request wrapper.
|
|
9838
|
+
*/
|
|
9839
|
+
static buildUrl(url: string, params?: Record<string, any>): string;
|
|
9750
9840
|
private static request;
|
|
9751
9841
|
static get<T>(url: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
9752
9842
|
static post<T>(url: string, data: any, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
@@ -10089,6 +10179,7 @@ declare class Glitch {
|
|
|
10089
10179
|
Multiplayer: typeof Multiplayer;
|
|
10090
10180
|
ServerOperations: typeof ServerOperations;
|
|
10091
10181
|
Agents: typeof Agents;
|
|
10182
|
+
Mcp: typeof Mcp;
|
|
10092
10183
|
PrDirectory: typeof PrDirectory;
|
|
10093
10184
|
};
|
|
10094
10185
|
static util: {
|
package/package.json
CHANGED
package/src/api/Agents.ts
CHANGED
|
@@ -196,6 +196,13 @@ class Agents {
|
|
|
196
196
|
return Requests.processRoute(AgentsRoute.routes.answerGuidance, data, { title_id, guidance_id }, params);
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Rewrite an editable agent draft for review without executing the parent action.
|
|
201
|
+
*/
|
|
202
|
+
public static rewriteAgentDraft<T>(title_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
203
|
+
return Requests.processRoute(AgentsRoute.routes.rewriteAgentDraft, data, { title_id }, params);
|
|
204
|
+
}
|
|
205
|
+
|
|
199
206
|
/**
|
|
200
207
|
* List structured agent memories for a title.
|
|
201
208
|
*/
|
package/src/api/Mcp.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import McpRoute from "../routes/McpRoute";
|
|
2
|
+
import Requests from "../util/Requests";
|
|
3
|
+
import Response from "../util/Response";
|
|
4
|
+
import { AxiosPromise, AxiosProgressEvent } from "axios";
|
|
5
|
+
|
|
6
|
+
export interface McpStartRunRequest {
|
|
7
|
+
agent_id?: string | null;
|
|
8
|
+
initial_message?: string | null;
|
|
9
|
+
prompt?: string | null;
|
|
10
|
+
run_type?: string;
|
|
11
|
+
trigger_source?: string;
|
|
12
|
+
background?: boolean;
|
|
13
|
+
live_mode?: boolean;
|
|
14
|
+
attachment_ids?: string[];
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Client for the Glitch MCP paid facade (/mcp/v1).
|
|
20
|
+
*
|
|
21
|
+
* Authenticate with a Glitch user JWT or a title-scoped MCP token. The facade
|
|
22
|
+
* enforces subscription, title permissions, scope, and approval guardrails on
|
|
23
|
+
* every call; this client only forwards requests.
|
|
24
|
+
*/
|
|
25
|
+
class Mcp {
|
|
26
|
+
/** Health/auth probe. Returns authenticated=false (200) when no credential is set. */
|
|
27
|
+
public static authStatus<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
28
|
+
return Requests.processRoute(McpRoute.routes.authStatus, {}, {}, params);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** List titles visible to the current user token or title-scoped MCP token. */
|
|
32
|
+
public static listTitles<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
33
|
+
return Requests.processRoute(McpRoute.routes.listTitles, {}, {}, params);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Fetch safe, subscription-gated workspace context for a title. */
|
|
37
|
+
public static titleContext<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
38
|
+
return Requests.processRoute(McpRoute.routes.titleContext, {}, { title_id }, params);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Check subscription, trial, plan, and credit state for a title. */
|
|
42
|
+
public static billing<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
43
|
+
return Requests.processRoute(McpRoute.routes.billing, {}, { title_id }, params);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Start a paid Glitch Agent run for a title. */
|
|
47
|
+
public static startRun<T>(title_id: string, data?: McpStartRunRequest, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
48
|
+
return Requests.processRoute(McpRoute.routes.startRun, data ?? {}, { title_id }, params);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Fetch a durable run with status, actions, guidance, events, files, and report. */
|
|
52
|
+
public static viewRun<T>(title_id: string, run_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
53
|
+
return Requests.processRoute(McpRoute.routes.viewRun, {}, { title_id, run_id }, params);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** List user-visible timeline events for a run. */
|
|
57
|
+
public static runEvents<T>(title_id: string, run_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
58
|
+
return Requests.processRoute(McpRoute.routes.runEvents, {}, { title_id, run_id }, params);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Fetch the human-friendly final or partial report for a run. */
|
|
62
|
+
public static finalReport<T>(title_id: string, run_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
63
|
+
return Requests.processRoute(McpRoute.routes.finalReport, {}, { title_id, run_id }, params);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Server-Sent Events URL for a run's live event stream.
|
|
68
|
+
*
|
|
69
|
+
* Returns the absolute URL to open with an EventSource/fetch reader; the
|
|
70
|
+
* endpoint emits `status`, `run_event`, and a terminal `settled`/`timeout` event.
|
|
71
|
+
*/
|
|
72
|
+
public static runStreamUrl(title_id: string, run_id: string, params?: Record<string, any>): string {
|
|
73
|
+
const url = McpRoute.routes.streamRun.url
|
|
74
|
+
.replace("{title_id}", encodeURIComponent(title_id))
|
|
75
|
+
.replace("{run_id}", encodeURIComponent(run_id));
|
|
76
|
+
return Requests.buildUrl(url, params);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** List downloadable files and hosted report artifacts for a run. */
|
|
80
|
+
public static artifacts<T>(title_id: string, run_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
81
|
+
return Requests.processRoute(McpRoute.routes.artifacts, {}, { title_id, run_id }, params);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** List proposed/guidance/approval/executed actions for a title. */
|
|
85
|
+
public static listActions<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
86
|
+
return Requests.processRoute(McpRoute.routes.listActions, {}, { title_id }, params);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Approve a reviewable action. Execution remains guarded server-side. */
|
|
90
|
+
public static approveAction<T>(title_id: string, action_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
91
|
+
return Requests.processRoute(McpRoute.routes.approveAction, data ?? {}, { title_id, action_id }, params);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Reject a proposed or approval-needed action. */
|
|
95
|
+
public static rejectAction<T>(title_id: string, action_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
96
|
+
return Requests.processRoute(McpRoute.routes.rejectAction, data ?? {}, { title_id, action_id }, params);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Execute an approved action. Public/paid/creator-facing work stays guarded. */
|
|
100
|
+
public static executeAction<T>(title_id: string, action_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
101
|
+
return Requests.processRoute(McpRoute.routes.executeAction, data ?? {}, { title_id, action_id }, params);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** List open or answered guidance requests for a title or run. */
|
|
105
|
+
public static listGuidance<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
106
|
+
return Requests.processRoute(McpRoute.routes.listGuidance, {}, { title_id }, params);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Answer a guidance request and resume the server-side workflow when possible. */
|
|
110
|
+
public static answerGuidance<T>(title_id: string, guidance_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
111
|
+
return Requests.processRoute(McpRoute.routes.answerGuidance, data ?? {}, { title_id, guidance_id }, params);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Get instructions for uploading a file (points at uploadFile below). */
|
|
115
|
+
public static createUpload<T>(title_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
116
|
+
return Requests.processRoute(McpRoute.routes.createUpload, data ?? {}, { title_id }, params);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Upload a file (image, video, or document) to a title or run as multipart/form-data.
|
|
121
|
+
* The facade re-checks the title scope, subscription, and allowed mime types.
|
|
122
|
+
*/
|
|
123
|
+
public static uploadFile<T>(
|
|
124
|
+
title_id: string,
|
|
125
|
+
file: File | Blob,
|
|
126
|
+
data?: object,
|
|
127
|
+
params?: Record<string, any>,
|
|
128
|
+
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void
|
|
129
|
+
): AxiosPromise<Response<T>> {
|
|
130
|
+
const url = McpRoute.routes.uploadFile.url.replace("{title_id}", title_id);
|
|
131
|
+
return Requests.uploadFile(url, "file", file, data, params, onUploadProgress);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** List MCP title tokens (user JWT only). */
|
|
135
|
+
public static listTokens<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
136
|
+
return Requests.processRoute(McpRoute.routes.listTokens, {}, { title_id }, params);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Create a revocable title-scoped MCP token (user JWT only). */
|
|
140
|
+
public static createToken<T>(title_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
141
|
+
return Requests.processRoute(McpRoute.routes.createToken, data ?? {}, { title_id }, params);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Revoke a title-scoped MCP token (user JWT only). */
|
|
145
|
+
public static revokeToken<T>(title_id: string, token_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
146
|
+
return Requests.processRoute(McpRoute.routes.revokeToken, {}, { title_id, token_id }, params);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export default Mcp;
|
package/src/api/Users.ts
CHANGED
|
@@ -256,6 +256,18 @@ class Users {
|
|
|
256
256
|
return Requests.processRoute(UserRoutes.routes.clearGoogleAuth, {});
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
/**
|
|
260
|
+
* Clear Gmail Workspace authentication information from the current user.
|
|
261
|
+
*
|
|
262
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/clearGmailAuth
|
|
263
|
+
*
|
|
264
|
+
* @returns promise
|
|
265
|
+
*/
|
|
266
|
+
public static clearGmailAuth<T>(): AxiosPromise<Response<T>> {
|
|
267
|
+
|
|
268
|
+
return Requests.processRoute(UserRoutes.routes.clearGmailAuth, {});
|
|
269
|
+
}
|
|
270
|
+
|
|
259
271
|
/**
|
|
260
272
|
* Clear Stripe authentication information from the current user.
|
|
261
273
|
*
|
|
@@ -699,4 +711,4 @@ class Users {
|
|
|
699
711
|
|
|
700
712
|
}
|
|
701
713
|
|
|
702
|
-
export default Users;
|
|
714
|
+
export default Users;
|
package/src/api/index.ts
CHANGED
|
@@ -46,6 +46,7 @@ import Crm from "./Crm";
|
|
|
46
46
|
import Multiplayer from "./Multiplayer";
|
|
47
47
|
import ServerOperations from "./ServerOperations";
|
|
48
48
|
import Agents from "./Agents";
|
|
49
|
+
import Mcp from "./Mcp";
|
|
49
50
|
import PrDirectory from "./PrDirectory";
|
|
50
51
|
|
|
51
52
|
export {Ads};
|
|
@@ -96,4 +97,5 @@ export {Crm};
|
|
|
96
97
|
export {Multiplayer};
|
|
97
98
|
export {ServerOperations};
|
|
98
99
|
export {Agents};
|
|
100
|
+
export {Mcp};
|
|
99
101
|
export {PrDirectory};
|
package/src/index.ts
CHANGED
|
@@ -50,6 +50,7 @@ import {Crm} from './api';
|
|
|
50
50
|
import {Multiplayer} from './api';
|
|
51
51
|
import {ServerOperations} from './api';
|
|
52
52
|
import {Agents} from './api';
|
|
53
|
+
import {Mcp} from './api';
|
|
53
54
|
import {PrDirectory} from './api';
|
|
54
55
|
|
|
55
56
|
import Requests from "./util/Requests";
|
|
@@ -130,6 +131,7 @@ class Glitch {
|
|
|
130
131
|
Multiplayer : Multiplayer,
|
|
131
132
|
ServerOperations : ServerOperations,
|
|
132
133
|
Agents : Agents,
|
|
134
|
+
Mcp : Mcp,
|
|
133
135
|
PrDirectory : PrDirectory,
|
|
134
136
|
}
|
|
135
137
|
|
package/src/models/user.ts
CHANGED
|
@@ -23,9 +23,18 @@ interface User {
|
|
|
23
23
|
twitch_handle?: string;
|
|
24
24
|
youtube_handle?: string;
|
|
25
25
|
paetron_handle?: string;
|
|
26
|
+
gmail_oauth_token?: string;
|
|
27
|
+
gmail_refresh_token?: string;
|
|
28
|
+
gmail_token_expiration?: number;
|
|
29
|
+
gmail_token_expires_at?: string;
|
|
30
|
+
gmail_id?: string;
|
|
31
|
+
gmail_name?: string;
|
|
32
|
+
gmail_email?: string;
|
|
33
|
+
gmail_avatar?: string;
|
|
34
|
+
gmail_scopes?: string[];
|
|
35
|
+
gmail_connected_at?: string;
|
|
26
36
|
created_at?: string;
|
|
27
37
|
updated_at?: string;
|
|
28
38
|
}
|
|
29
39
|
|
|
30
40
|
export default User;
|
|
31
|
-
|
|
@@ -25,6 +25,7 @@ class AgentsRoute {
|
|
|
25
25
|
executeAction: { url: "/agents/titles/{title_id}/actions/{action_id}/execute", method: HTTP_METHODS.POST },
|
|
26
26
|
listGuidance: { url: "/agents/titles/{title_id}/guidance", method: HTTP_METHODS.GET },
|
|
27
27
|
answerGuidance: { url: "/agents/titles/{title_id}/guidance/{guidance_id}/answer", method: HTTP_METHODS.POST },
|
|
28
|
+
rewriteAgentDraft: { url: "/agents/titles/{title_id}/drafts/rewrite", method: HTTP_METHODS.POST },
|
|
28
29
|
listMemories: { url: "/agents/titles/{title_id}/memories", method: HTTP_METHODS.GET },
|
|
29
30
|
results: { url: "/agents/titles/{title_id}/results", method: HTTP_METHODS.GET },
|
|
30
31
|
usage: { url: "/agents/titles/{title_id}/usage", method: HTTP_METHODS.GET },
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Route from "./interface";
|
|
2
|
+
import HTTP_METHODS from "../constants/HttpMethods";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Glitch MCP paid facade (/mcp/v1).
|
|
6
|
+
*
|
|
7
|
+
* Mirrors the routes served by McpAgentController. These endpoints authenticate
|
|
8
|
+
* with either a Glitch user JWT or a title-scoped MCP token and keep all planner,
|
|
9
|
+
* billing, and executor logic server-side. The public @glitch/mcp adapter calls
|
|
10
|
+
* the same endpoints; this SDK surface lets first-party TypeScript clients reuse them.
|
|
11
|
+
*/
|
|
12
|
+
class McpRoute {
|
|
13
|
+
public static routes: { [key: string]: Route } = {
|
|
14
|
+
authStatus: { url: "/mcp/v1/auth/status", method: HTTP_METHODS.GET },
|
|
15
|
+
listTitles: { url: "/mcp/v1/titles", method: HTTP_METHODS.GET },
|
|
16
|
+
titleContext: { url: "/mcp/v1/titles/{title_id}/context", method: HTTP_METHODS.GET },
|
|
17
|
+
billing: { url: "/mcp/v1/titles/{title_id}/billing", method: HTTP_METHODS.GET },
|
|
18
|
+
startRun: { url: "/mcp/v1/titles/{title_id}/runs", method: HTTP_METHODS.POST },
|
|
19
|
+
viewRun: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}", method: HTTP_METHODS.GET },
|
|
20
|
+
runEvents: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/events", method: HTTP_METHODS.GET },
|
|
21
|
+
streamRun: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/stream", method: HTTP_METHODS.GET },
|
|
22
|
+
finalReport: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/report", method: HTTP_METHODS.GET },
|
|
23
|
+
artifacts: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/artifacts", method: HTTP_METHODS.GET },
|
|
24
|
+
listActions: { url: "/mcp/v1/titles/{title_id}/actions", method: HTTP_METHODS.GET },
|
|
25
|
+
approveAction: { url: "/mcp/v1/titles/{title_id}/actions/{action_id}/approve", method: HTTP_METHODS.POST },
|
|
26
|
+
rejectAction: { url: "/mcp/v1/titles/{title_id}/actions/{action_id}/reject", method: HTTP_METHODS.POST },
|
|
27
|
+
executeAction: { url: "/mcp/v1/titles/{title_id}/actions/{action_id}/execute", method: HTTP_METHODS.POST },
|
|
28
|
+
listGuidance: { url: "/mcp/v1/titles/{title_id}/guidance", method: HTTP_METHODS.GET },
|
|
29
|
+
answerGuidance: { url: "/mcp/v1/titles/{title_id}/guidance/{guidance_id}/answer", method: HTTP_METHODS.POST },
|
|
30
|
+
createUpload: { url: "/mcp/v1/titles/{title_id}/uploads", method: HTTP_METHODS.POST },
|
|
31
|
+
uploadFile: { url: "/mcp/v1/titles/{title_id}/files", method: HTTP_METHODS.POST },
|
|
32
|
+
listTokens: { url: "/mcp/v1/titles/{title_id}/tokens", method: HTTP_METHODS.GET },
|
|
33
|
+
createToken: { url: "/mcp/v1/titles/{title_id}/tokens", method: HTTP_METHODS.POST },
|
|
34
|
+
revokeToken: { url: "/mcp/v1/titles/{title_id}/tokens/{token_id}", method: HTTP_METHODS.DELETE },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default McpRoute;
|
package/src/routes/UserRoutes.ts
CHANGED
|
@@ -18,6 +18,7 @@ class UserRoutes {
|
|
|
18
18
|
clearTwitchAuth: { url: '/users/clearTwitchAuth', method: HTTP_METHODS.DELETE },
|
|
19
19
|
clearFacebookAuth: { url: '/users/clearFacebookAuth', method: HTTP_METHODS.DELETE },
|
|
20
20
|
clearGoogleAuth: { url: '/users/clearGoogleAuth', method: HTTP_METHODS.DELETE },
|
|
21
|
+
clearGmailAuth: { url: '/users/clearGmailAuth', method: HTTP_METHODS.DELETE },
|
|
21
22
|
clearStripeAuth: { url: '/users/clearStripeAuth', method: HTTP_METHODS.DELETE },
|
|
22
23
|
clearTikTokAuth: { url: '/users/clearTikTokAuth', method: HTTP_METHODS.DELETE },
|
|
23
24
|
clearYoutubeAuth: { url: '/users/clearYoutubeAuth', method: HTTP_METHODS.DELETE },
|
|
@@ -75,4 +76,4 @@ class UserRoutes {
|
|
|
75
76
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
export default UserRoutes;
|
|
79
|
+
export default UserRoutes;
|
package/src/util/Requests.ts
CHANGED
|
@@ -28,6 +28,35 @@ class Requests {
|
|
|
28
28
|
Requests.community_id = community_id;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Build an absolute API URL using the currently configured base URL.
|
|
33
|
+
*
|
|
34
|
+
* This is useful for browser primitives such as EventSource that need a URL
|
|
35
|
+
* string instead of an Axios request wrapper.
|
|
36
|
+
*/
|
|
37
|
+
public static buildUrl(url: string, params?: Record<string, any>): string {
|
|
38
|
+
let path = url;
|
|
39
|
+
|
|
40
|
+
if (params && Object.keys(params).length > 0) {
|
|
41
|
+
const queryString = Object.entries(params)
|
|
42
|
+
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
|
43
|
+
.map(([key, value]) => {
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
return value.map((item) => `${key}[]=${encodeURIComponent(item)}`).join('&');
|
|
46
|
+
}
|
|
47
|
+
return `${key}=${encodeURIComponent(value)}`;
|
|
48
|
+
})
|
|
49
|
+
.filter(Boolean)
|
|
50
|
+
.join('&');
|
|
51
|
+
|
|
52
|
+
if (queryString) {
|
|
53
|
+
path = `${path}${path.includes('?') ? '&' : '?'}${queryString}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return Requests.baseUrl.replace(/\/+$/, '') + '/' + path.replace(/^\/+/, '');
|
|
58
|
+
}
|
|
59
|
+
|
|
31
60
|
private static request<T>(
|
|
32
61
|
method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE',
|
|
33
62
|
url: string,
|