@airborne-dev/mcp 0.0.0-stage → 0.1.0
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/SKILL.md +50 -0
- package/dist/api.d.ts +37 -0
- package/dist/api.js +265 -0
- package/dist/archive.d.ts +59 -0
- package/dist/archive.js +862 -0
- package/dist/auth.d.ts +17 -0
- package/dist/auth.js +400 -0
- package/dist/helpers.d.ts +75 -0
- package/dist/helpers.js +31 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +737 -0
- package/package.json +34 -4
- package/README.md +0 -3
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface StoredCredentials {
|
|
2
|
+
apiBase: string;
|
|
3
|
+
accessToken: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
updatedAt: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function normalizeBase(url: string): string;
|
|
8
|
+
export declare function isLocalHttpAllowed(rawUrl: string): boolean;
|
|
9
|
+
export declare function getApiBase(): string;
|
|
10
|
+
export declare function loadCredentials(targetApiBase?: string): StoredCredentials | null;
|
|
11
|
+
export declare function saveCredentials(creds: StoredCredentials): void;
|
|
12
|
+
export declare function getAccessToken(): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Starts a short-lived localhost OAuth callback server (`http://127.0.0.1:<ephemeral_port>/callback`)
|
|
15
|
+
* to authenticate the local MCP with the Airborne Control Plane.
|
|
16
|
+
*/
|
|
17
|
+
export declare function runLocalhostOAuthLogin(apiBase?: string, timeoutMs?: number): Promise<StoredCredentials>;
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import http from "node:http";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
const DEFAULT_API_BASE = "https://airborne.dev";
|
|
8
|
+
function getCredentialsPaths() {
|
|
9
|
+
const dir = path.join(os.homedir(), ".airborne");
|
|
10
|
+
return { dir, file: path.join(dir, "credentials.json") };
|
|
11
|
+
}
|
|
12
|
+
export function normalizeBase(url) {
|
|
13
|
+
const trimmed = url.trim().replace(/\/+$/, "");
|
|
14
|
+
try {
|
|
15
|
+
const parsed = new URL(trimmed);
|
|
16
|
+
const pathname = parsed.pathname.replace(/\/+$/, "");
|
|
17
|
+
return `${parsed.origin}${pathname}`;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return trimmed;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function isLocalHttpAllowed(rawUrl) {
|
|
24
|
+
try {
|
|
25
|
+
const parsed = new URL(rawUrl);
|
|
26
|
+
if (parsed.protocol === "https:")
|
|
27
|
+
return true;
|
|
28
|
+
return (parsed.protocol === "http:" &&
|
|
29
|
+
(parsed.hostname === "localhost" ||
|
|
30
|
+
parsed.hostname === "127.0.0.1" ||
|
|
31
|
+
parsed.hostname === "::1" ||
|
|
32
|
+
parsed.hostname === "[::1]"));
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function readRawCredentialsFile() {
|
|
39
|
+
const { file } = getCredentialsPaths();
|
|
40
|
+
try {
|
|
41
|
+
const stat = fs.lstatSync(file);
|
|
42
|
+
if (!stat.isFile() || stat.isSymbolicLink()) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const raw = fs.readFileSync(file, "utf8");
|
|
46
|
+
const parsed = JSON.parse(raw);
|
|
47
|
+
return parsed && typeof parsed === "object" ? parsed : null;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function extractProfiles(raw) {
|
|
54
|
+
const profiles = Object.create(null);
|
|
55
|
+
if (!raw)
|
|
56
|
+
return { defaultApiBase: null, profiles };
|
|
57
|
+
if (raw.profiles && typeof raw.profiles === "object") {
|
|
58
|
+
for (const [key, entry] of Object.entries(raw.profiles)) {
|
|
59
|
+
if (entry &&
|
|
60
|
+
typeof entry === "object" &&
|
|
61
|
+
typeof entry.accessToken === "string" &&
|
|
62
|
+
entry.accessToken.trim()) {
|
|
63
|
+
const base = normalizeBase(typeof entry.apiBase === "string" && entry.apiBase.trim()
|
|
64
|
+
? entry.apiBase
|
|
65
|
+
: key);
|
|
66
|
+
profiles[base] = {
|
|
67
|
+
apiBase: base,
|
|
68
|
+
accessToken: entry.accessToken.trim(),
|
|
69
|
+
email: typeof entry.email === "string" ? entry.email : undefined,
|
|
70
|
+
updatedAt: typeof entry.updatedAt === "string"
|
|
71
|
+
? entry.updatedAt
|
|
72
|
+
: new Date().toISOString(),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Legacy flat credentials.json migration
|
|
78
|
+
if (typeof raw.accessToken === "string" && raw.accessToken.trim()) {
|
|
79
|
+
const base = typeof raw.apiBase === "string" && raw.apiBase.trim()
|
|
80
|
+
? normalizeBase(raw.apiBase)
|
|
81
|
+
: DEFAULT_API_BASE;
|
|
82
|
+
if (!profiles[base]) {
|
|
83
|
+
profiles[base] = {
|
|
84
|
+
apiBase: base,
|
|
85
|
+
accessToken: raw.accessToken.trim(),
|
|
86
|
+
email: typeof raw.email === "string" ? raw.email : undefined,
|
|
87
|
+
updatedAt: typeof raw.updatedAt === "string"
|
|
88
|
+
? raw.updatedAt
|
|
89
|
+
: new Date().toISOString(),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const defaultApiBase = typeof raw.defaultApiBase === "string" && raw.defaultApiBase.trim()
|
|
94
|
+
? normalizeBase(raw.defaultApiBase)
|
|
95
|
+
: typeof raw.apiBase === "string" && raw.apiBase.trim()
|
|
96
|
+
? normalizeBase(raw.apiBase)
|
|
97
|
+
: Object.keys(profiles)[0] ?? null;
|
|
98
|
+
return { defaultApiBase, profiles };
|
|
99
|
+
}
|
|
100
|
+
export function getApiBase() {
|
|
101
|
+
const fromEnv = process.env.AIRBORNE_API_BASE?.trim();
|
|
102
|
+
if (fromEnv) {
|
|
103
|
+
const normalized = normalizeBase(fromEnv);
|
|
104
|
+
if (!isLocalHttpAllowed(normalized)) {
|
|
105
|
+
throw new Error(`Refusing to use insecure non-HTTPS AIRBORNE_API_BASE "${normalized}". Use https:// (or http://localhost for local dev).`);
|
|
106
|
+
}
|
|
107
|
+
return normalized;
|
|
108
|
+
}
|
|
109
|
+
// Never inherit a previously stored apiBase when AIRBORNE_API_TOKEN is explicitly provided
|
|
110
|
+
// (prevents leaking CI/prod env tokens to a stale local/staging URL).
|
|
111
|
+
if (process.env.AIRBORNE_API_TOKEN?.trim()) {
|
|
112
|
+
return DEFAULT_API_BASE;
|
|
113
|
+
}
|
|
114
|
+
const stored = loadCredentials();
|
|
115
|
+
if (stored?.apiBase && isLocalHttpAllowed(stored.apiBase)) {
|
|
116
|
+
return normalizeBase(stored.apiBase);
|
|
117
|
+
}
|
|
118
|
+
return DEFAULT_API_BASE;
|
|
119
|
+
}
|
|
120
|
+
export function loadCredentials(targetApiBase) {
|
|
121
|
+
const { defaultApiBase, profiles } = extractProfiles(readRawCredentialsFile());
|
|
122
|
+
if (targetApiBase) {
|
|
123
|
+
const key = normalizeBase(targetApiBase);
|
|
124
|
+
return profiles[key] ?? null;
|
|
125
|
+
}
|
|
126
|
+
if (defaultApiBase && profiles[defaultApiBase]) {
|
|
127
|
+
return profiles[defaultApiBase];
|
|
128
|
+
}
|
|
129
|
+
const first = Object.values(profiles)[0];
|
|
130
|
+
return first ?? null;
|
|
131
|
+
}
|
|
132
|
+
export function saveCredentials(creds) {
|
|
133
|
+
const { dir, file } = getCredentialsPaths();
|
|
134
|
+
try {
|
|
135
|
+
const dirStat = fs.lstatSync(dir);
|
|
136
|
+
if (dirStat.isSymbolicLink() || !dirStat.isDirectory()) {
|
|
137
|
+
throw new Error(`Refusing to write credentials: ${dir} is not a regular directory.`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
if (err.code === "ENOENT") {
|
|
142
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
throw err;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
fs.chmodSync(dir, 0o700);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// Windows chmod is a no-op
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
const fileStat = fs.lstatSync(file);
|
|
156
|
+
if (fileStat.isSymbolicLink() || !fileStat.isFile()) {
|
|
157
|
+
throw new Error(`Refusing to overwrite non-regular credentials file: ${file}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
if (err.code !== "ENOENT") {
|
|
162
|
+
throw err;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const normalizedBase = normalizeBase(creds.apiBase);
|
|
166
|
+
const { profiles } = extractProfiles(readRawCredentialsFile());
|
|
167
|
+
profiles[normalizedBase] = {
|
|
168
|
+
...creds,
|
|
169
|
+
apiBase: normalizedBase,
|
|
170
|
+
};
|
|
171
|
+
const payload = {
|
|
172
|
+
defaultApiBase: normalizedBase,
|
|
173
|
+
profiles,
|
|
174
|
+
};
|
|
175
|
+
const tmpFile = `${file}.${crypto.randomBytes(16).toString("hex")}.tmp`;
|
|
176
|
+
try {
|
|
177
|
+
fs.writeFileSync(tmpFile, JSON.stringify(payload, null, 2) + "\n", {
|
|
178
|
+
encoding: "utf8",
|
|
179
|
+
mode: 0o600,
|
|
180
|
+
});
|
|
181
|
+
// Harden permissions BEFORE atomic rename so the file is never world-readable
|
|
182
|
+
try {
|
|
183
|
+
fs.chmodSync(tmpFile, 0o600);
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// Windows chmod is a no-op
|
|
187
|
+
}
|
|
188
|
+
fs.renameSync(tmpFile, file);
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
try {
|
|
192
|
+
fs.rmSync(tmpFile, { force: true });
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
// Best-effort cleanup so plaintext token isn't leaked on disk
|
|
196
|
+
}
|
|
197
|
+
throw err;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
export function getAccessToken() {
|
|
201
|
+
const envToken = process.env.AIRBORNE_API_TOKEN?.trim();
|
|
202
|
+
if (envToken) {
|
|
203
|
+
return envToken;
|
|
204
|
+
}
|
|
205
|
+
const activeBase = getApiBase();
|
|
206
|
+
const stored = loadCredentials(activeBase);
|
|
207
|
+
if (!stored)
|
|
208
|
+
return null;
|
|
209
|
+
// Never send stored credentials to a different API base URL (prevents prod token leak)
|
|
210
|
+
if (normalizeBase(stored.apiBase) !== activeBase) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
return stored.accessToken;
|
|
214
|
+
}
|
|
215
|
+
function safeEqual(a, b) {
|
|
216
|
+
const bufA = Buffer.from(a);
|
|
217
|
+
const bufB = Buffer.from(b);
|
|
218
|
+
if (bufA.length !== bufB.length)
|
|
219
|
+
return false;
|
|
220
|
+
return crypto.timingSafeEqual(bufA, bufB);
|
|
221
|
+
}
|
|
222
|
+
function openBrowser(rawUrl) {
|
|
223
|
+
let parsed;
|
|
224
|
+
try {
|
|
225
|
+
parsed = new URL(rawUrl);
|
|
226
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const url = parsed.toString();
|
|
234
|
+
const platform = process.platform;
|
|
235
|
+
let cmd;
|
|
236
|
+
let args;
|
|
237
|
+
if (platform === "darwin") {
|
|
238
|
+
cmd = "open";
|
|
239
|
+
args = [url];
|
|
240
|
+
}
|
|
241
|
+
else if (platform === "win32") {
|
|
242
|
+
cmd = "rundll32.exe";
|
|
243
|
+
args = ["url.dll,FileProtocolHandler", url];
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
cmd = "xdg-open";
|
|
247
|
+
args = [url];
|
|
248
|
+
}
|
|
249
|
+
try {
|
|
250
|
+
const child = spawn(cmd, args, { detached: true, stdio: "ignore" });
|
|
251
|
+
child.on("error", () => { });
|
|
252
|
+
child.unref();
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
// Best-effort browser open; URL is also printed to stderr
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Starts a short-lived localhost OAuth callback server (`http://127.0.0.1:<ephemeral_port>/callback`)
|
|
260
|
+
* to authenticate the local MCP with the Airborne Control Plane.
|
|
261
|
+
*/
|
|
262
|
+
export async function runLocalhostOAuthLogin(apiBase = getApiBase(), timeoutMs = 120_000) {
|
|
263
|
+
const cleanBase = normalizeBase(apiBase);
|
|
264
|
+
const state = crypto.randomBytes(16).toString("hex");
|
|
265
|
+
return new Promise((resolve, reject) => {
|
|
266
|
+
let settled = false;
|
|
267
|
+
let handlingCallback = false;
|
|
268
|
+
let boundPort = 0;
|
|
269
|
+
const shutdownServer = () => {
|
|
270
|
+
try {
|
|
271
|
+
server.closeAllConnections?.();
|
|
272
|
+
server.close();
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
// ignore
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
const finishError = (err) => {
|
|
279
|
+
if (settled)
|
|
280
|
+
return;
|
|
281
|
+
settled = true;
|
|
282
|
+
clearTimeout(timer);
|
|
283
|
+
shutdownServer();
|
|
284
|
+
reject(err);
|
|
285
|
+
};
|
|
286
|
+
const server = http.createServer((req, res) => {
|
|
287
|
+
try {
|
|
288
|
+
res.setHeader("Cache-Control", "no-store");
|
|
289
|
+
res.setHeader("Referrer-Policy", "no-referrer");
|
|
290
|
+
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
291
|
+
res.setHeader("Content-Security-Policy", "default-src 'none'; style-src 'unsafe-inline'");
|
|
292
|
+
res.setHeader("Connection", "close");
|
|
293
|
+
const hostHeader = (req.headers.host ?? "").toLowerCase();
|
|
294
|
+
if (boundPort === 0 ||
|
|
295
|
+
(hostHeader !== `127.0.0.1:${boundPort}` &&
|
|
296
|
+
hostHeader !== `localhost:${boundPort}`)) {
|
|
297
|
+
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
298
|
+
res.end("Forbidden Host");
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (req.method !== "GET") {
|
|
302
|
+
res.writeHead(405, { Allow: "GET" });
|
|
303
|
+
res.end("Method Not Allowed");
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (!req.url) {
|
|
307
|
+
res.writeHead(400);
|
|
308
|
+
res.end("Missing request URL");
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
let parsedUrl;
|
|
312
|
+
try {
|
|
313
|
+
parsedUrl = new URL(req.url, "http://127.0.0.1");
|
|
314
|
+
}
|
|
315
|
+
catch {
|
|
316
|
+
res.writeHead(400);
|
|
317
|
+
res.end("Malformed request URL");
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (parsedUrl.pathname === "/done") {
|
|
321
|
+
const successHtml = "<html><body style='font-family:system-ui,sans-serif;padding:48px;background:#fafafa;color:#18181b'><h2>Airborne Connected</h2><p>Your local MCP is now signed in. You can close this tab and return to your IDE.</p></body></html>";
|
|
322
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
323
|
+
res.end(successHtml);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (parsedUrl.pathname !== "/callback") {
|
|
327
|
+
res.writeHead(404);
|
|
328
|
+
res.end("Not found");
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
const token = parsedUrl.searchParams.get("token");
|
|
332
|
+
const returnedState = parsedUrl.searchParams.get("state") ?? "";
|
|
333
|
+
const email = parsedUrl.searchParams.get("email") ?? undefined;
|
|
334
|
+
if (!token || !safeEqual(returnedState, state)) {
|
|
335
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
336
|
+
res.end("<html><body style='font-family:sans-serif;padding:40px'><h2>Authentication failed</h2><p>Invalid state or missing token. Please retry from your IDE.</p></body></html>");
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
// Synchronous guard prevents concurrent duplicate callback writes while still allowing
|
|
340
|
+
// finishError() to reject the Promise if saveCredentials() throws.
|
|
341
|
+
if (settled || handlingCallback) {
|
|
342
|
+
res.writeHead(303, { Location: "/done" });
|
|
343
|
+
res.end();
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
handlingCallback = true;
|
|
347
|
+
const creds = {
|
|
348
|
+
apiBase: cleanBase,
|
|
349
|
+
accessToken: token,
|
|
350
|
+
email,
|
|
351
|
+
updatedAt: new Date().toISOString(),
|
|
352
|
+
};
|
|
353
|
+
saveCredentials(creds);
|
|
354
|
+
settled = true;
|
|
355
|
+
clearTimeout(timer);
|
|
356
|
+
// Redirect 303 to /done to strip `?token=...&state=...` from the browser URL bar/history.
|
|
357
|
+
// Resolve immediately after queuing the response so a dropped browser socket cannot hang login.
|
|
358
|
+
res.writeHead(303, { Location: "/done" });
|
|
359
|
+
res.end();
|
|
360
|
+
const closeTimer = setTimeout(shutdownServer, 1500);
|
|
361
|
+
closeTimer.unref?.();
|
|
362
|
+
resolve(creds);
|
|
363
|
+
}
|
|
364
|
+
catch (err) {
|
|
365
|
+
handlingCallback = false;
|
|
366
|
+
try {
|
|
367
|
+
res.writeHead(500);
|
|
368
|
+
res.end("Internal authentication error");
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
// ignore
|
|
372
|
+
}
|
|
373
|
+
finishError(err instanceof Error ? err : new Error("Local OAuth callback failed."));
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
server.requestTimeout = 10_000;
|
|
377
|
+
server.headersTimeout = 5_000;
|
|
378
|
+
server.keepAliveTimeout = 1_000;
|
|
379
|
+
server.maxConnections = 16;
|
|
380
|
+
server.on("error", (err) => {
|
|
381
|
+
finishError(new Error(`Could not start localhost login callback server (${err.message}). Set AIRBORNE_API_TOKEN to authenticate directly.`));
|
|
382
|
+
});
|
|
383
|
+
const timer = setTimeout(() => {
|
|
384
|
+
finishError(new Error(`Timed out waiting for browser login. Open ${cleanBase} to sign in, or set AIRBORNE_API_TOKEN.`));
|
|
385
|
+
}, timeoutMs);
|
|
386
|
+
server.listen(0, "127.0.0.1", () => {
|
|
387
|
+
const addr = server.address();
|
|
388
|
+
if (!addr || typeof addr === "string") {
|
|
389
|
+
finishError(new Error("Failed to bind ephemeral localhost callback port."));
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
boundPort = addr.port;
|
|
393
|
+
const callbackUrl = `http://127.0.0.1:${addr.port}/callback`;
|
|
394
|
+
const authUrl = `${cleanBase}/auth/cli?callback=${encodeURIComponent(callbackUrl)}&state=${encodeURIComponent(state)}`;
|
|
395
|
+
// Print to stderr (never stdout, which carries MCP JSON-RPC) for headless/SSH/WSL users
|
|
396
|
+
console.error(`[airborne] Sign in via browser: ${authUrl}`);
|
|
397
|
+
openBrowser(authUrl);
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-contained helpers and wire-contract types for `@airborne-dev/mcp` so
|
|
3
|
+
* `npx -y @airborne-dev/mcp` works standalone with zero unpublished workspace dependencies.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ALWAYS_FREE_DEFAULTS: {
|
|
6
|
+
readonly region: "us-central1";
|
|
7
|
+
readonly maxInstances: 3;
|
|
8
|
+
};
|
|
9
|
+
export declare const RESERVED_CLOUD_RUN_ENV_KEYS: Set<string>;
|
|
10
|
+
export declare function isValidGcpRegion(region: string): boolean;
|
|
11
|
+
export declare function sanitizeAppName(raw: string, maxLen?: number): string;
|
|
12
|
+
export interface AppRecord {
|
|
13
|
+
id: string;
|
|
14
|
+
connectionId: string;
|
|
15
|
+
name: string;
|
|
16
|
+
region: string;
|
|
17
|
+
liveUrl: string | null;
|
|
18
|
+
publicUrl?: string | null;
|
|
19
|
+
customDomain?: string | null;
|
|
20
|
+
maxInstances: number;
|
|
21
|
+
isPaused: boolean;
|
|
22
|
+
addons?: Record<string, unknown>;
|
|
23
|
+
lastDeployStatus: string;
|
|
24
|
+
lastDeployedAt: string | null;
|
|
25
|
+
github?: {
|
|
26
|
+
repoFullName: string;
|
|
27
|
+
branch: string;
|
|
28
|
+
autoDeploy: boolean;
|
|
29
|
+
prPreviews?: boolean;
|
|
30
|
+
} | null;
|
|
31
|
+
}
|
|
32
|
+
export interface DiagnoseReport {
|
|
33
|
+
appName: string;
|
|
34
|
+
healthy: boolean;
|
|
35
|
+
summary: string;
|
|
36
|
+
issues: Array<{
|
|
37
|
+
code: string;
|
|
38
|
+
title: string;
|
|
39
|
+
plainEnglishExplanation: string;
|
|
40
|
+
recommendedFix: string;
|
|
41
|
+
sampleLog?: string;
|
|
42
|
+
}>;
|
|
43
|
+
rawErrorCount: number;
|
|
44
|
+
}
|
|
45
|
+
export interface ConnectionSummary {
|
|
46
|
+
id: string;
|
|
47
|
+
provider?: string;
|
|
48
|
+
gcpProjectId: string;
|
|
49
|
+
deployerSa?: string;
|
|
50
|
+
runtimeSa?: string;
|
|
51
|
+
region: string;
|
|
52
|
+
spendCapUsd: number;
|
|
53
|
+
billingCurrency?: string;
|
|
54
|
+
status: string;
|
|
55
|
+
}
|
|
56
|
+
export interface StatusResponse {
|
|
57
|
+
authenticated?: boolean;
|
|
58
|
+
authRequired?: boolean;
|
|
59
|
+
accessRevoked?: boolean;
|
|
60
|
+
requestedProjectNotFound?: boolean;
|
|
61
|
+
connected: boolean;
|
|
62
|
+
demoMode: boolean;
|
|
63
|
+
license?: Record<string, unknown> | null;
|
|
64
|
+
planLimits?: Record<string, unknown> | null;
|
|
65
|
+
user: {
|
|
66
|
+
id: string;
|
|
67
|
+
email: string;
|
|
68
|
+
displayName?: string | null;
|
|
69
|
+
name?: string | null;
|
|
70
|
+
plan: string;
|
|
71
|
+
} | null;
|
|
72
|
+
connection: ConnectionSummary | null;
|
|
73
|
+
connections?: ConnectionSummary[];
|
|
74
|
+
apps: AppRecord[];
|
|
75
|
+
}
|
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-contained helpers and wire-contract types for `@airborne-dev/mcp` so
|
|
3
|
+
* `npx -y @airborne-dev/mcp` works standalone with zero unpublished workspace dependencies.
|
|
4
|
+
*/
|
|
5
|
+
export const ALWAYS_FREE_DEFAULTS = {
|
|
6
|
+
region: "us-central1",
|
|
7
|
+
maxInstances: 3,
|
|
8
|
+
};
|
|
9
|
+
export const RESERVED_CLOUD_RUN_ENV_KEYS = new Set([
|
|
10
|
+
"PORT",
|
|
11
|
+
"K_SERVICE",
|
|
12
|
+
"K_REVISION",
|
|
13
|
+
"K_CONFIGURATION",
|
|
14
|
+
"GOOGLE_APPLICATION_CREDENTIALS",
|
|
15
|
+
"AIRBORNE_SECRETS_JSON",
|
|
16
|
+
]);
|
|
17
|
+
export function isValidGcpRegion(region) {
|
|
18
|
+
return region.length <= 40 && /^[a-z]+-[a-z]+\d+$/.test(region);
|
|
19
|
+
}
|
|
20
|
+
export function sanitizeAppName(raw, maxLen = 49) {
|
|
21
|
+
const cleaned = raw
|
|
22
|
+
.toLowerCase()
|
|
23
|
+
.replace(/[^a-z0-9-]+/g, "-")
|
|
24
|
+
.replace(/^-+/, "")
|
|
25
|
+
.slice(0, maxLen)
|
|
26
|
+
.replace(/-+$/, "");
|
|
27
|
+
if (!cleaned || !/^[a-z]/.test(cleaned)) {
|
|
28
|
+
throw new Error(`Invalid app name "${raw}". App names must start with a letter and use only letters, numbers, and hyphens.`);
|
|
29
|
+
}
|
|
30
|
+
return cleaned;
|
|
31
|
+
}
|
package/dist/index.d.ts
ADDED