@proxylayer/cli 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/README.md CHANGED
@@ -1,3 +1,71 @@
1
- # Temporary Holding Version
1
+ # @proxylayer/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Official zero-dependency CLI, local `stdio` MCP server, and TypeScript/JavaScript SDK for [ProxyLayer](https://proxy-layer.com).
4
+
5
+ ## Local MCP Server (Claude Desktop, Cursor, Windsurf, Cline)
6
+
7
+ Connect without any pre-existing API key:
8
+
9
+ ```json
10
+ {
11
+ "mcpServers": {
12
+ "proxylayer": {
13
+ "command": "npx",
14
+ "args": ["-y", "@proxylayer/cli", "mcp"]
15
+ }
16
+ }
17
+ }
18
+ ```
19
+
20
+ When an AI agent calls `auth_request_otp` and `auth_verify_otp`, the local `@proxylayer/cli` MCP bridge automatically saves your `pl_live_...` API key to `~/.config/proxylayer/config.json` (`0600`) so subsequent tool calls (`create_checkout`, `list_static_proxies`, `get_residential_proxies`) work immediately in the same session.
21
+
22
+ ## CLI Usage
23
+
24
+ ```bash
25
+ # Public catalog & pricing quote
26
+ npx @proxylayer/cli catalog
27
+ npx @proxylayer/cli quote --product isp --country US --qty 2 --days 30
28
+
29
+ # Email OTP sign-up / login (saves API key locally)
30
+ npx @proxylayer/cli login --email user@example.com
31
+ npx @proxylayer/cli login --email user@example.com --code 123456
32
+
33
+ # Create checkout (stripe hosted link, crypto invoice, or prepaid balance)
34
+ npx @proxylayer/cli buy --product residential --gb 10 --method stripe
35
+ npx @proxylayer/cli buy --product isp --country US --qty 1 --days 30 --method balance
36
+
37
+ # Poll checkout status & output ready-to-use proxy strings
38
+ npx @proxylayer/cli checkout <checkoutSessionId>
39
+ npx @proxylayer/cli proxies --product isp --raw
40
+ npx @proxylayer/cli residential --country us --session sticky --qty 5 --raw
41
+ ```
42
+
43
+ ## TypeScript / JavaScript SDK
44
+
45
+ ```bash
46
+ npm install @proxylayer/cli
47
+ ```
48
+
49
+ ```ts
50
+ import { ProxyLayer } from "@proxylayer/cli"
51
+
52
+ const client = new ProxyLayer({ apiKey: process.env.PROXYLAYER_API_KEY })
53
+
54
+ const quote = await client.quote({
55
+ productSlug: "isp",
56
+ durationDays: 30,
57
+ items: [{ countryCode: "US", quantity: 2 }],
58
+ })
59
+
60
+ const checkout = await client.createCheckout({
61
+ purchase: { productSlug: "residential", trafficGb: 10 },
62
+ paymentMethod: "stripe",
63
+ })
64
+ console.log("Pay here:", checkout.paymentUrl)
65
+
66
+ const { proxies } = await client.getResidentialProxies({
67
+ country: "us",
68
+ session: "sticky",
69
+ quantity: 5,
70
+ })
71
+ ```
package/dist/cli.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ export type CliDeps = {
3
+ fetch?: typeof globalThis.fetch;
4
+ stdout?: NodeJS.WritableStream;
5
+ stderr?: NodeJS.WritableStream;
6
+ stdin?: NodeJS.ReadableStream;
7
+ configPath?: string;
8
+ };
9
+ export declare function runCli(argv: string[], deps?: CliDeps): Promise<number>;
package/dist/cli.js ADDED
@@ -0,0 +1,420 @@
1
+ #!/usr/bin/env node
2
+ import { realpathSync } from "node:fs";
3
+ import readline from "node:readline/promises";
4
+ import { fileURLToPath } from "node:url";
5
+ import { ProxyLayer, ProxyLayerError, } from "./client.js";
6
+ import { clearConfig } from "./config.js";
7
+ import { runStdioMcpServer } from "./mcp.js";
8
+ const CLI_VERSION = "0.1.0";
9
+ const HELP_TEXT = `ProxyLayer CLI (${CLI_VERSION})
10
+
11
+ Usage:
12
+ proxylayer <command> [options]
13
+
14
+ Commands:
15
+ mcp Start local stdio MCP server (auto-saves API key on OTP verify)
16
+ login --email <email> Sign in or register via Email OTP and save API key locally
17
+ [--code <6-digits>] [--key-name <name>] [--access full|read]
18
+ whoami Show stored config path, email, baseUrl, and masked API key
19
+ logout Remove saved local credentials
20
+ catalog List products, durations, countries, and USD prices
21
+ quote --product <slug> Calculate USD price (--country US --qty 1 --days 30 | --gb 10)
22
+ balance Show prepaid USD wallet balance
23
+ buy --product <slug> Create checkout (--method stripe|crypto|balance)
24
+ checkout <session-id> Poll checkout payment and provisioning status
25
+ orders [--limit 20] List order and top-up history
26
+ proxies [--product isp] List static proxies (--raw prints host:port:user:pass per line)
27
+ residential [options] Generate residential proxy strings (--country us --qty 1 --raw)
28
+
29
+ Global options:
30
+ --json Print raw JSON response
31
+ --raw Print one proxy string per line (proxies, residential)
32
+ --api-key <pl_live_...> Override API key for this command
33
+ --base-url <url> Override API base URL (default: https://app.proxy-layer.com)
34
+ --config <path> Override config file path
35
+ -h, --help Show help
36
+ -v, --version Show CLI version
37
+ `;
38
+ function parseArgs(argv) {
39
+ const positionals = [];
40
+ const flags = new Map();
41
+ for (let i = 0; i < argv.length; i++) {
42
+ const token = argv[i];
43
+ if (token === "--") {
44
+ positionals.push(...argv.slice(i + 1));
45
+ break;
46
+ }
47
+ if (token === "-h" || token === "--help") {
48
+ flags.set("help", true);
49
+ continue;
50
+ }
51
+ if (token === "-v" || token === "--version") {
52
+ flags.set("version", true);
53
+ continue;
54
+ }
55
+ if (token.startsWith("--")) {
56
+ const eq = token.indexOf("=");
57
+ if (eq !== -1) {
58
+ flags.set(token.slice(2, eq), token.slice(eq + 1));
59
+ continue;
60
+ }
61
+ const key = token.slice(2);
62
+ if (key === "json" || key === "raw") {
63
+ flags.set(key, true);
64
+ continue;
65
+ }
66
+ const next = argv[i + 1];
67
+ if (next !== undefined && !next.startsWith("-")) {
68
+ flags.set(key, next);
69
+ i++;
70
+ }
71
+ else {
72
+ flags.set(key, true);
73
+ }
74
+ continue;
75
+ }
76
+ positionals.push(token);
77
+ }
78
+ return { positionals, flags };
79
+ }
80
+ function strFlag(flags, name) {
81
+ const value = flags.get(name);
82
+ return typeof value === "string" ? value.trim() : undefined;
83
+ }
84
+ function intFlag(flags, name, fallback) {
85
+ const raw = strFlag(flags, name);
86
+ if (raw === undefined)
87
+ return fallback;
88
+ const parsed = Number(raw);
89
+ if (!Number.isInteger(parsed))
90
+ throw new Error(`--${name} must be an integer (got "${raw}")`);
91
+ return parsed;
92
+ }
93
+ function boolFlag(flags, name) {
94
+ return flags.get(name) === true;
95
+ }
96
+ function maskKey(key) {
97
+ if (!key)
98
+ return null;
99
+ if (key.length <= 16)
100
+ return `${key.slice(0, 8)}...`;
101
+ return `${key.slice(0, 12)}...${key.slice(-4)}`;
102
+ }
103
+ function formatUsd(cents) {
104
+ return `$${(cents / 100).toFixed(2)}`;
105
+ }
106
+ function buildPurchase(flags, allowTopUp) {
107
+ const product = strFlag(flags, "product");
108
+ if (!product) {
109
+ throw new Error("--product is required (isp | datacenter | mobile | residential" + (allowTopUp ? " | balance-topup)" : ")"));
110
+ }
111
+ if (product === "residential") {
112
+ const trafficGb = intFlag(flags, "gb");
113
+ if (!trafficGb || trafficGb <= 0)
114
+ throw new Error("--gb <integer> is required for residential");
115
+ return { productSlug: "residential", trafficGb };
116
+ }
117
+ if (product === "balance-topup") {
118
+ if (!allowTopUp)
119
+ throw new Error("balance-topup cannot be quoted with quote; pass amount to buy");
120
+ const amountCents = intFlag(flags, "amount-cents");
121
+ if (!amountCents || amountCents <= 0)
122
+ throw new Error("--amount-cents <integer> is required for balance-topup");
123
+ return { productSlug: "balance-topup", amountCents };
124
+ }
125
+ if (product === "isp" || product === "datacenter" || product === "mobile") {
126
+ const durationDays = intFlag(flags, "days", 30);
127
+ const quantity = intFlag(flags, "qty", 1);
128
+ const countryCode = (strFlag(flags, "country") || "US").toUpperCase();
129
+ const targetIdsRaw = strFlag(flags, "target-proxy-ids");
130
+ const targetProxyIds = targetIdsRaw
131
+ ? targetIdsRaw.split(",").map((id) => id.trim()).filter(Boolean)
132
+ : undefined;
133
+ return {
134
+ productSlug: product,
135
+ durationDays,
136
+ items: [{ countryCode, quantity, ...(targetProxyIds?.length ? { targetProxyIds } : {}) }],
137
+ };
138
+ }
139
+ throw new Error(`Unsupported product "${product}"`);
140
+ }
141
+ export async function runCli(argv, deps) {
142
+ const stdout = deps?.stdout ?? process.stdout;
143
+ const stderr = deps?.stderr ?? process.stderr;
144
+ const stdin = deps?.stdin ?? process.stdin;
145
+ const out = (line) => stdout.write(`${line}\n`);
146
+ const errOut = (line) => stderr.write(`${line}\n`);
147
+ try {
148
+ const { positionals, flags } = parseArgs(argv);
149
+ if (boolFlag(flags, "version")) {
150
+ out(CLI_VERSION);
151
+ return 0;
152
+ }
153
+ const command = positionals[0];
154
+ if (!command || boolFlag(flags, "help") || command === "help") {
155
+ out(HELP_TEXT.trimEnd());
156
+ return 0;
157
+ }
158
+ const asJson = boolFlag(flags, "json");
159
+ const asRaw = boolFlag(flags, "raw");
160
+ const configPath = strFlag(flags, "config") ?? deps?.configPath;
161
+ const apiKey = strFlag(flags, "api-key");
162
+ const baseUrl = strFlag(flags, "base-url");
163
+ if (command === "mcp") {
164
+ await runStdioMcpServer({ apiKey, baseUrl, configPath, input: stdin, output: stdout, fetch: deps?.fetch });
165
+ return 0;
166
+ }
167
+ const client = new ProxyLayer({ apiKey, baseUrl, configPath, fetch: deps?.fetch });
168
+ if (command === "whoami") {
169
+ const resolved = client.getResolvedConfig();
170
+ const payload = {
171
+ authenticated: Boolean(resolved.apiKey),
172
+ email: resolved.email ?? null,
173
+ apiKeyMasked: maskKey(resolved.apiKey),
174
+ baseUrl: resolved.baseUrl,
175
+ configPath: resolved.configPath,
176
+ };
177
+ if (asJson) {
178
+ out(JSON.stringify(payload, null, 2));
179
+ }
180
+ else {
181
+ out(`Base URL: ${payload.baseUrl}`);
182
+ out(`Config: ${payload.configPath}`);
183
+ out(`Email: ${payload.email ?? "(none)"}`);
184
+ out(`API key: ${payload.apiKeyMasked ?? "(not signed in)"}`);
185
+ }
186
+ return resolved.apiKey ? 0 : 1;
187
+ }
188
+ if (command === "logout") {
189
+ const removed = clearConfig(configPath);
190
+ if (asJson)
191
+ out(JSON.stringify({ cleared: removed }, null, 2));
192
+ else
193
+ out(removed ? "Removed saved ProxyLayer credentials." : "No saved credentials found.");
194
+ return 0;
195
+ }
196
+ if (command === "login") {
197
+ const email = strFlag(flags, "email") ?? positionals[1];
198
+ if (!email)
199
+ throw new Error("--email <address> is required");
200
+ let code = strFlag(flags, "code");
201
+ const keyName = strFlag(flags, "key-name");
202
+ const access = strFlag(flags, "access");
203
+ if (access && access !== "read" && access !== "full") {
204
+ throw new Error("--access must be 'read' or 'full'");
205
+ }
206
+ if (!code) {
207
+ const requested = await client.requestOtp(email);
208
+ const isTty = Boolean(stdin.isTTY);
209
+ if (!isTty) {
210
+ if (asJson) {
211
+ out(JSON.stringify(requested, null, 2));
212
+ }
213
+ else {
214
+ out(`Sent 6-digit verification code to ${requested.email} (valid ${requested.expiresInSeconds}s).`);
215
+ out(`Complete login with:\n npx @proxylayer/cli login --email ${requested.email} --code <6-digits>`);
216
+ }
217
+ return 0;
218
+ }
219
+ errOut(`Verification code sent to ${requested.email}.`);
220
+ const rl = readline.createInterface({ input: stdin, output: stdout });
221
+ try {
222
+ code = (await rl.question("Enter 6-digit code: ")).trim();
223
+ }
224
+ finally {
225
+ rl.close();
226
+ }
227
+ }
228
+ const verified = await client.verifyOtp({ email, code, keyName, access, save: true });
229
+ const resolved = client.getResolvedConfig();
230
+ if (asJson) {
231
+ out(JSON.stringify({
232
+ saved: true,
233
+ configPath: resolved.configPath,
234
+ keyId: verified.keyId,
235
+ keyPrefix: verified.keyPrefix,
236
+ scopes: verified.scopes,
237
+ user: verified.user,
238
+ }, null, 2));
239
+ }
240
+ else {
241
+ out(`Signed in as ${verified.user.email} (${verified.keyPrefix}...)`);
242
+ out(`Saved API key to ${resolved.configPath}`);
243
+ }
244
+ return 0;
245
+ }
246
+ if (command === "catalog") {
247
+ const catalog = await client.getCatalog();
248
+ if (asJson) {
249
+ out(JSON.stringify(catalog, null, 2));
250
+ }
251
+ else {
252
+ for (const product of catalog.products) {
253
+ const durations = product.durationsDays.length ? `${product.durationsDays.join("/")}d` : "traffic";
254
+ out(`${product.slug.padEnd(12)} ${product.name} (${durations}, ${product.countries.length} countries)`);
255
+ }
256
+ }
257
+ return 0;
258
+ }
259
+ if (command === "quote") {
260
+ const quote = await client.quote(buildPurchase(flags, false));
261
+ if (asJson) {
262
+ out(JSON.stringify(quote, null, 2));
263
+ }
264
+ else {
265
+ out(`${quote.productName}: ${formatUsd(quote.amountCents)} (${quote.amountCents} cents USD)`);
266
+ }
267
+ return 0;
268
+ }
269
+ if (command === "balance") {
270
+ const summary = await client.getBalance();
271
+ if (asJson) {
272
+ out(JSON.stringify(summary, null, 2));
273
+ }
274
+ else {
275
+ out(`Balance: ${formatUsd(summary.balanceCents)} (${summary.balanceCents} cents USD)`);
276
+ }
277
+ return 0;
278
+ }
279
+ if (command === "buy") {
280
+ const paymentMethod = (strFlag(flags, "method") || "stripe");
281
+ if (paymentMethod !== "stripe" && paymentMethod !== "crypto" && paymentMethod !== "balance") {
282
+ throw new Error("--method must be 'stripe', 'crypto', or 'balance'");
283
+ }
284
+ const checkout = await client.createCheckout({
285
+ purchase: buildPurchase(flags, true),
286
+ paymentMethod,
287
+ cryptoCurrency: strFlag(flags, "crypto-currency"),
288
+ cryptoNetwork: strFlag(flags, "crypto-network"),
289
+ clientOperationId: strFlag(flags, "idempotency-key"),
290
+ });
291
+ if (asJson) {
292
+ out(JSON.stringify(checkout, null, 2));
293
+ }
294
+ else {
295
+ out(`Checkout ${checkout.checkoutSessionId} [${checkout.paymentMethod}] — ${checkout.status} (${formatUsd(checkout.amountCents)})`);
296
+ if (checkout.paymentUrl)
297
+ out(`Payment URL: ${checkout.paymentUrl}`);
298
+ if (checkout.crypto) {
299
+ out(`Pay ${checkout.crypto.payerAmount} ${checkout.crypto.payerCurrency} (${checkout.crypto.network}) -> ${checkout.crypto.address}`);
300
+ }
301
+ if (checkout.orderId)
302
+ out(`Order ID: ${checkout.orderId}`);
303
+ }
304
+ return 0;
305
+ }
306
+ if (command === "checkout") {
307
+ const sessionId = positionals[1] ?? strFlag(flags, "id");
308
+ if (!sessionId)
309
+ throw new Error("checkout <checkoutSessionId> is required");
310
+ const status = await client.getCheckoutStatus(sessionId);
311
+ if (asJson) {
312
+ out(JSON.stringify(status, null, 2));
313
+ }
314
+ else {
315
+ out(`Checkout ${status.checkoutSessionId}: status=${status.status}, provisioningPending=${status.provisioningPending}${status.orderId ? `, orderId=${status.orderId}` : ""}${status.fulfillmentStatus ? ` (${status.fulfillmentStatus})` : ""}`);
316
+ if (status.failureMessage)
317
+ out(`Message: ${status.failureMessage}`);
318
+ }
319
+ return 0;
320
+ }
321
+ if (command === "orders") {
322
+ const orders = await client.listOrders({
323
+ limit: intFlag(flags, "limit"),
324
+ cursor: strFlag(flags, "cursor"),
325
+ });
326
+ if (asJson) {
327
+ out(JSON.stringify(orders, null, 2));
328
+ }
329
+ else {
330
+ for (const order of orders.items) {
331
+ out(`${order.id} ${order.occurredAt} ${order.paymentStatus}/${order.fulfillmentStatus} ${formatUsd(order.totalAmount)}`);
332
+ }
333
+ }
334
+ return 0;
335
+ }
336
+ if (command === "proxies") {
337
+ const product = (strFlag(flags, "product") || "isp");
338
+ if (product !== "isp" && product !== "datacenter" && product !== "mobile") {
339
+ throw new Error("--product must be 'isp', 'datacenter', or 'mobile'");
340
+ }
341
+ const res = await client.listStaticProxies({
342
+ product,
343
+ checkoutSessionId: strFlag(flags, "checkout-session-id"),
344
+ limit: intFlag(flags, "limit"),
345
+ cursor: strFlag(flags, "cursor"),
346
+ });
347
+ if (asJson) {
348
+ out(JSON.stringify(res, null, 2));
349
+ }
350
+ else if (asRaw) {
351
+ for (const row of res.data)
352
+ out(row.proxy);
353
+ }
354
+ else {
355
+ for (const row of res.data) {
356
+ out(`${row.proxy} [${row.countryCode}, ${row.daysLeft}d left]`);
357
+ }
358
+ if (res.data.length === 0 && res.pendingCheckout) {
359
+ out(`Checkout ${res.pendingCheckout.checkoutSessionId} is awaiting payment/provisioning (${res.pendingCheckout.quantity}).`);
360
+ }
361
+ }
362
+ return 0;
363
+ }
364
+ if (command === "residential") {
365
+ const session = strFlag(flags, "session");
366
+ if (session && session !== "sticky" && session !== "rotating") {
367
+ throw new Error("--session must be 'sticky' or 'rotating'");
368
+ }
369
+ const res = await client.getResidentialProxies({
370
+ country: strFlag(flags, "country"),
371
+ city: strFlag(flags, "city"),
372
+ region: strFlag(flags, "region"),
373
+ asn: strFlag(flags, "asn"),
374
+ session,
375
+ ttl: intFlag(flags, "ttl"),
376
+ quantity: intFlag(flags, "qty"),
377
+ format: strFlag(flags, "format"),
378
+ });
379
+ if (asJson) {
380
+ out(JSON.stringify(res, null, 2));
381
+ }
382
+ else if (asRaw) {
383
+ for (const proxy of res.proxies)
384
+ out(proxy);
385
+ }
386
+ else {
387
+ if (res.trafficBalance.balanceFormatted) {
388
+ out(`Traffic remaining: ${res.trafficBalance.balanceFormatted}`);
389
+ }
390
+ for (const proxy of res.proxies)
391
+ out(proxy);
392
+ }
393
+ return 0;
394
+ }
395
+ throw new Error(`Unknown command "${command}". Run with --help to see usage.`);
396
+ }
397
+ catch (error) {
398
+ if (error instanceof ProxyLayerError) {
399
+ errOut(`Error (${error.code}, HTTP ${error.status}): ${error.message}`);
400
+ }
401
+ else {
402
+ errOut(`Error: ${error instanceof Error ? error.message : String(error)}`);
403
+ }
404
+ return 1;
405
+ }
406
+ }
407
+ const isEntrypoint = Boolean(process.argv[1] &&
408
+ (() => {
409
+ try {
410
+ return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
411
+ }
412
+ catch {
413
+ return false;
414
+ }
415
+ })());
416
+ if (isEntrypoint) {
417
+ runCli(process.argv.slice(2)).then((code) => {
418
+ process.exitCode = code;
419
+ });
420
+ }
@@ -0,0 +1,262 @@
1
+ export type FixedProductSlug = "isp" | "datacenter" | "mobile";
2
+ export type ProductSlug = FixedProductSlug | "residential";
3
+ export type PaymentMethod = "stripe" | "crypto" | "balance";
4
+ export type ProxyStringFormat = "http://login:password@ip:port" | "https://login:password@ip:port" | "socks5://login:password@ip:port" | "ip:port:login:password";
5
+ export type FixedPurchaseItem = {
6
+ countryCode: string;
7
+ quantity: number;
8
+ targetProxyIds?: string[];
9
+ };
10
+ export type QuotePurchaseInput = {
11
+ productSlug: FixedProductSlug;
12
+ durationDays: number;
13
+ items: FixedPurchaseItem[];
14
+ } | {
15
+ productSlug: "residential";
16
+ trafficGb: number;
17
+ };
18
+ export type CheckoutPurchaseInput = QuotePurchaseInput | {
19
+ productSlug: "balance-topup";
20
+ amountCents: number;
21
+ };
22
+ export type CatalogResponse = {
23
+ currency: "USD";
24
+ products: Array<{
25
+ slug: ProductSlug;
26
+ type: string;
27
+ name: string;
28
+ billingMode: "FIXED" | "TRAFFIC";
29
+ durationsDays: number[];
30
+ countries: Array<{
31
+ code: string;
32
+ name: string;
33
+ }>;
34
+ prices: Array<{
35
+ ruleType: "BASE" | "COUNTRY" | "TRAFFIC_TIER" | "QUANTITY_TIER";
36
+ durationDays: number | null;
37
+ countryCode: string | null;
38
+ minQuantity: number | null;
39
+ maxQuantity: number | null;
40
+ minTrafficGb: number | null;
41
+ maxTrafficGb: number | null;
42
+ unitAmountCents: number;
43
+ packageAmountCents: number | null;
44
+ currency: "USD";
45
+ }>;
46
+ }>;
47
+ limits: {
48
+ maxProxyQuantity: number;
49
+ maxResidentialTrafficGb: number;
50
+ };
51
+ };
52
+ export type QuoteResponse = {
53
+ productSlug: ProductSlug;
54
+ productType: string;
55
+ productName: string;
56
+ currency: "USD";
57
+ amountCents: number;
58
+ durationDays: number | null;
59
+ quantity: number;
60
+ items: Array<{
61
+ countryCode: string | null;
62
+ quantity: number;
63
+ targetProxyIds: string[];
64
+ trafficGb: number | null;
65
+ unitAmountCents: number;
66
+ totalAmountCents: number;
67
+ }>;
68
+ };
69
+ export type OtpRequestResponse = {
70
+ sent: true;
71
+ email: string;
72
+ expiresInSeconds: number;
73
+ };
74
+ export type OtpVerifyResponse = {
75
+ apiKey: string;
76
+ keyId: string;
77
+ keyPrefix: string;
78
+ scopes: string[];
79
+ user: {
80
+ id: string;
81
+ email: string;
82
+ };
83
+ };
84
+ export type BalanceResponse = {
85
+ balanceCents: number;
86
+ balanceMajor: number;
87
+ };
88
+ export type CheckoutResponse = {
89
+ checkoutSessionId: string;
90
+ paymentMethod: PaymentMethod;
91
+ status: "pending" | "completed";
92
+ currency: "USD";
93
+ amountCents: number;
94
+ paymentUrl?: string | null;
95
+ expiresAt?: string | null;
96
+ orderId?: string | null;
97
+ balanceCents?: number | null;
98
+ crypto?: {
99
+ address: string;
100
+ payerAmount: string;
101
+ payerCurrency: string;
102
+ network: string;
103
+ expiresAt: number | null;
104
+ };
105
+ };
106
+ export type CheckoutStatusResponse = {
107
+ checkoutSessionId: string;
108
+ status: "pending" | "completed" | "failed" | "expired" | "cancelled" | "refunded";
109
+ provisioningPending: boolean;
110
+ orderId: string | null;
111
+ fulfillmentStatus: "PENDING" | "FULFILLED" | "FAILED" | "NEEDS_CHECK" | null;
112
+ failureMessage: string | null;
113
+ balanceCents: number | null;
114
+ detail?: "WAITING_CONFIRMATIONS" | "UNDERPAID";
115
+ paymentProvider?: string | null;
116
+ };
117
+ export type OrdersResponse = {
118
+ items: Array<{
119
+ historyKind?: "order" | "balance_top_up";
120
+ occurredAt: string;
121
+ id: string;
122
+ paymentStatus: "PENDING" | "PAID" | "PARTIALLY_REFUNDED" | "REFUNDED" | "CANCELLED";
123
+ fulfillmentStatus: "PENDING" | "FULFILLED" | "FAILED" | "NEEDS_CHECK";
124
+ currency: "USD";
125
+ totalAmount: number;
126
+ subtotalAmount: number;
127
+ discountAmount: number;
128
+ taxAmount: number;
129
+ paymentMethod: {
130
+ provider: string;
131
+ method: "balance" | "card" | "paypal" | "crypto" | "stripe" | "unknown";
132
+ cardBrand?: string | null;
133
+ cardLast4?: string | null;
134
+ } | null;
135
+ items: Array<{
136
+ id: string;
137
+ kind: "balance_top_up" | null;
138
+ durationDays: number | null;
139
+ quantity: number;
140
+ trafficGb: number | null;
141
+ unitAmount: number;
142
+ totalAmount: number;
143
+ countryCode: string | null;
144
+ fulfillmentStatus?: "PENDING" | "FULFILLED" | "FAILED" | "NEEDS_CHECK";
145
+ failureReason?: string | null;
146
+ fulfilledAt?: string | null;
147
+ product: {
148
+ name: string;
149
+ type: string;
150
+ };
151
+ }>;
152
+ }>;
153
+ nextCursor: string | null;
154
+ };
155
+ export type StaticProxiesResponse = {
156
+ data: Array<{
157
+ id: string;
158
+ product: FixedProductSlug;
159
+ countryCode: string;
160
+ country: string;
161
+ host: string;
162
+ port: number;
163
+ username: string;
164
+ password: string;
165
+ protocol: string;
166
+ proxy: string;
167
+ purchasedAt: string;
168
+ expiresAt: string | null;
169
+ daysLeft: number;
170
+ note: string;
171
+ tags: string[];
172
+ }>;
173
+ pagination: {
174
+ nextCursor: string | null;
175
+ };
176
+ pendingCheckout?: {
177
+ checkoutSessionId: string;
178
+ quantity: number;
179
+ checkingPayment?: boolean;
180
+ };
181
+ provisioningOrders?: Array<{
182
+ orderId: string;
183
+ quantity: number;
184
+ fulfillmentStatus: "PENDING" | "FULFILLED" | "FAILED" | "NEEDS_CHECK";
185
+ }>;
186
+ };
187
+ export type ResidentialProxiesResponse = {
188
+ trafficBalance: {
189
+ status: "UNPROVISIONED" | "FRESH" | "ERROR";
190
+ lastSyncedAt: string | null;
191
+ errorMessage: string | null;
192
+ balanceGb: number | null;
193
+ balanceFormatted: string | null;
194
+ totalTrafficGb: number | null;
195
+ totalTrafficFormatted: string | null;
196
+ usedTrafficGb: number | null;
197
+ usedTrafficFormatted: string | null;
198
+ };
199
+ format: ProxyStringFormat;
200
+ proxies: string[];
201
+ };
202
+ export type ProxyLayerOptions = {
203
+ apiKey?: string;
204
+ baseUrl?: string;
205
+ configPath?: string;
206
+ fetch?: typeof globalThis.fetch;
207
+ };
208
+ export declare class ProxyLayerError extends Error {
209
+ readonly status: number;
210
+ readonly code: string;
211
+ readonly issues?: unknown[];
212
+ constructor(message: string, status: number, code: string, issues?: unknown[]);
213
+ }
214
+ export declare class ProxyLayer {
215
+ private apiKeyOverride?;
216
+ private readonly baseUrlOverride?;
217
+ private readonly configPath?;
218
+ private readonly fetchFn;
219
+ constructor(options?: ProxyLayerOptions);
220
+ get baseUrl(): string;
221
+ getResolvedConfig(): import("./config.js").ResolvedConfig;
222
+ private request;
223
+ getCatalog(): Promise<CatalogResponse>;
224
+ quote(purchase: QuotePurchaseInput): Promise<QuoteResponse>;
225
+ requestOtp(email: string): Promise<OtpRequestResponse>;
226
+ verifyOtp(input: {
227
+ email: string;
228
+ code: string;
229
+ keyName?: string;
230
+ access?: "read" | "full";
231
+ save?: boolean;
232
+ }): Promise<OtpVerifyResponse>;
233
+ getBalance(): Promise<BalanceResponse>;
234
+ createCheckout(input: {
235
+ purchase: CheckoutPurchaseInput;
236
+ paymentMethod?: PaymentMethod;
237
+ cryptoCurrency?: string;
238
+ cryptoNetwork?: string;
239
+ clientOperationId?: string;
240
+ }): Promise<CheckoutResponse>;
241
+ getCheckoutStatus(checkoutSessionId: string): Promise<CheckoutStatusResponse>;
242
+ listOrders(params?: {
243
+ limit?: number;
244
+ cursor?: string;
245
+ }): Promise<OrdersResponse>;
246
+ listStaticProxies(params: {
247
+ product: FixedProductSlug;
248
+ checkoutSessionId?: string;
249
+ limit?: number;
250
+ cursor?: string;
251
+ }): Promise<StaticProxiesResponse>;
252
+ getResidentialProxies(params?: {
253
+ country?: string;
254
+ city?: string;
255
+ region?: string;
256
+ asn?: string;
257
+ session?: "sticky" | "rotating";
258
+ ttl?: number;
259
+ quantity?: number;
260
+ format?: ProxyStringFormat;
261
+ }): Promise<ResidentialProxiesResponse>;
262
+ }
package/dist/client.js ADDED
@@ -0,0 +1,170 @@
1
+ import { DEFAULT_BASE_URL, resolveConfig, saveConfig } from "./config.js";
2
+ export class ProxyLayerError extends Error {
3
+ status;
4
+ code;
5
+ issues;
6
+ constructor(message, status, code, issues) {
7
+ super(message);
8
+ this.name = "ProxyLayerError";
9
+ this.status = status;
10
+ this.code = code;
11
+ this.issues = issues;
12
+ }
13
+ }
14
+ export class ProxyLayer {
15
+ apiKeyOverride;
16
+ baseUrlOverride;
17
+ configPath;
18
+ fetchFn;
19
+ constructor(options) {
20
+ this.apiKeyOverride = options?.apiKey?.trim() || undefined;
21
+ this.baseUrlOverride = options?.baseUrl?.trim() || undefined;
22
+ this.configPath = options?.configPath;
23
+ this.fetchFn = options?.fetch ?? globalThis.fetch;
24
+ }
25
+ get baseUrl() {
26
+ return resolveConfig({
27
+ apiKey: this.apiKeyOverride,
28
+ baseUrl: this.baseUrlOverride,
29
+ configPath: this.configPath,
30
+ }).baseUrl || DEFAULT_BASE_URL;
31
+ }
32
+ getResolvedConfig() {
33
+ return resolveConfig({
34
+ apiKey: this.apiKeyOverride,
35
+ baseUrl: this.baseUrlOverride,
36
+ configPath: this.configPath,
37
+ });
38
+ }
39
+ async request(method, pathname, options) {
40
+ const config = this.getResolvedConfig();
41
+ const authMode = options?.auth ?? "required";
42
+ if (authMode === "required" && !config.apiKey) {
43
+ throw new ProxyLayerError("Missing ProxyLayer API key. Run `npx @proxylayer/cli login` or set PROXYLAYER_API_KEY.", 401, "UNAUTHORIZED");
44
+ }
45
+ const url = new URL(pathname, `${config.baseUrl}/`);
46
+ if (options?.query) {
47
+ for (const [key, value] of Object.entries(options.query)) {
48
+ if (value !== undefined)
49
+ url.searchParams.set(key, String(value));
50
+ }
51
+ }
52
+ const headers = {
53
+ Accept: "application/json",
54
+ ...options?.headers,
55
+ };
56
+ if (authMode !== "none" && config.apiKey) {
57
+ headers.Authorization = `Bearer ${config.apiKey}`;
58
+ }
59
+ if (options?.body !== undefined) {
60
+ headers["Content-Type"] = "application/json";
61
+ }
62
+ const response = await this.fetchFn(url.toString(), {
63
+ method,
64
+ headers,
65
+ body: options?.body !== undefined ? JSON.stringify(options.body) : undefined,
66
+ });
67
+ const text = await response.text();
68
+ let parsed = null;
69
+ if (text) {
70
+ try {
71
+ parsed = JSON.parse(text);
72
+ }
73
+ catch {
74
+ parsed = null;
75
+ }
76
+ }
77
+ if (!response.ok) {
78
+ const errorObj = (parsed && typeof parsed === "object" ? parsed.error : undefined);
79
+ const message = typeof errorObj?.message === "string"
80
+ ? errorObj.message
81
+ : `ProxyLayer API request failed (${response.status})`;
82
+ const code = typeof errorObj?.code === "string" ? errorObj.code : "API_ERROR";
83
+ const issues = Array.isArray(errorObj?.issues) ? errorObj.issues : undefined;
84
+ throw new ProxyLayerError(message, response.status, code, issues);
85
+ }
86
+ return parsed;
87
+ }
88
+ getCatalog() {
89
+ return this.request("GET", "/api/v1/catalog", { auth: "none" });
90
+ }
91
+ quote(purchase) {
92
+ return this.request("POST", "/api/v1/quotes", {
93
+ auth: "optional",
94
+ body: { purchase },
95
+ });
96
+ }
97
+ requestOtp(email) {
98
+ return this.request("POST", "/api/v1/auth/otp/request", {
99
+ auth: "none",
100
+ body: { email },
101
+ });
102
+ }
103
+ async verifyOtp(input) {
104
+ const result = await this.request("POST", "/api/v1/auth/otp/verify", {
105
+ auth: "none",
106
+ body: {
107
+ email: input.email,
108
+ code: input.code,
109
+ ...(input.keyName ? { keyName: input.keyName } : {}),
110
+ ...(input.access ? { access: input.access } : {}),
111
+ },
112
+ });
113
+ this.apiKeyOverride = result.apiKey;
114
+ if (input.save) {
115
+ saveConfig({
116
+ apiKey: result.apiKey,
117
+ email: result.user.email,
118
+ baseUrl: this.baseUrlOverride,
119
+ }, this.configPath);
120
+ }
121
+ return result;
122
+ }
123
+ getBalance() {
124
+ return this.request("GET", "/api/v1/balance");
125
+ }
126
+ createCheckout(input) {
127
+ return this.request("POST", "/api/v1/checkouts", {
128
+ body: {
129
+ purchase: input.purchase,
130
+ ...(input.paymentMethod ? { paymentMethod: input.paymentMethod } : {}),
131
+ ...(input.cryptoCurrency ? { cryptoCurrency: input.cryptoCurrency } : {}),
132
+ ...(input.cryptoNetwork ? { cryptoNetwork: input.cryptoNetwork } : {}),
133
+ ...(input.clientOperationId ? { clientOperationId: input.clientOperationId } : {}),
134
+ },
135
+ headers: input.clientOperationId ? { "Idempotency-Key": input.clientOperationId } : undefined,
136
+ });
137
+ }
138
+ getCheckoutStatus(checkoutSessionId) {
139
+ return this.request("GET", `/api/v1/checkouts/${encodeURIComponent(checkoutSessionId)}`);
140
+ }
141
+ listOrders(params) {
142
+ return this.request("GET", "/api/v1/orders", {
143
+ query: { limit: params?.limit, cursor: params?.cursor },
144
+ });
145
+ }
146
+ listStaticProxies(params) {
147
+ return this.request("GET", "/api/v1/proxies", {
148
+ query: {
149
+ product: params.product,
150
+ checkoutSessionId: params.checkoutSessionId,
151
+ limit: params.limit,
152
+ cursor: params.cursor,
153
+ },
154
+ });
155
+ }
156
+ getResidentialProxies(params) {
157
+ return this.request("GET", "/api/v1/residential/proxies", {
158
+ query: {
159
+ country: params?.country,
160
+ city: params?.city,
161
+ region: params?.region,
162
+ asn: params?.asn,
163
+ session: params?.session,
164
+ ttl: params?.ttl,
165
+ quantity: params?.quantity,
166
+ format: params?.format,
167
+ },
168
+ });
169
+ }
170
+ }
@@ -0,0 +1,21 @@
1
+ export declare const DEFAULT_BASE_URL = "https://app.proxy-layer.com";
2
+ export type StoredConfig = {
3
+ apiKey?: string;
4
+ email?: string;
5
+ baseUrl?: string;
6
+ };
7
+ export type ResolvedConfig = {
8
+ apiKey?: string;
9
+ email?: string;
10
+ baseUrl: string;
11
+ configPath: string;
12
+ };
13
+ export declare function getConfigPath(override?: string): string;
14
+ export declare function readConfig(configPath?: string): StoredConfig;
15
+ export declare function saveConfig(patch: StoredConfig, configPath?: string): string;
16
+ export declare function clearConfig(configPath?: string): boolean;
17
+ export declare function resolveConfig(overrides?: {
18
+ apiKey?: string;
19
+ baseUrl?: string;
20
+ configPath?: string;
21
+ }): ResolvedConfig;
package/dist/config.js ADDED
@@ -0,0 +1,69 @@
1
+ import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ export const DEFAULT_BASE_URL = "https://app.proxy-layer.com";
5
+ export function getConfigPath(override) {
6
+ const custom = override?.trim() || process.env.PROXYLAYER_CONFIG_PATH?.trim();
7
+ if (custom)
8
+ return path.resolve(custom);
9
+ const baseDir = process.env.XDG_CONFIG_HOME?.trim() || path.join(os.homedir(), ".config");
10
+ return path.join(baseDir, "proxylayer", "config.json");
11
+ }
12
+ export function readConfig(configPath) {
13
+ const filePath = getConfigPath(configPath);
14
+ if (!existsSync(filePath))
15
+ return {};
16
+ try {
17
+ const raw = JSON.parse(readFileSync(filePath, "utf8"));
18
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
19
+ return {};
20
+ const record = raw;
21
+ return {
22
+ ...(typeof record.apiKey === "string" && record.apiKey.trim() ? { apiKey: record.apiKey.trim() } : {}),
23
+ ...(typeof record.email === "string" && record.email.trim() ? { email: record.email.trim() } : {}),
24
+ ...(typeof record.baseUrl === "string" && record.baseUrl.trim() ? { baseUrl: record.baseUrl.trim() } : {}),
25
+ };
26
+ }
27
+ catch {
28
+ return {};
29
+ }
30
+ }
31
+ export function saveConfig(patch, configPath) {
32
+ const filePath = getConfigPath(configPath);
33
+ const next = { ...readConfig(filePath) };
34
+ for (const key of ["apiKey", "email", "baseUrl"]) {
35
+ if (patch[key] !== undefined) {
36
+ const value = patch[key]?.trim();
37
+ if (value)
38
+ next[key] = value;
39
+ else
40
+ delete next[key];
41
+ }
42
+ }
43
+ mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 });
44
+ writeFileSync(filePath, `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600 });
45
+ chmodSync(filePath, 0o600);
46
+ return filePath;
47
+ }
48
+ export function clearConfig(configPath) {
49
+ const filePath = getConfigPath(configPath);
50
+ if (!existsSync(filePath))
51
+ return false;
52
+ rmSync(filePath, { force: true });
53
+ return true;
54
+ }
55
+ export function resolveConfig(overrides) {
56
+ const configPath = getConfigPath(overrides?.configPath);
57
+ const stored = readConfig(configPath);
58
+ const apiKey = overrides?.apiKey?.trim() || process.env.PROXYLAYER_API_KEY?.trim() || stored.apiKey;
59
+ const rawBaseUrl = overrides?.baseUrl?.trim() ||
60
+ process.env.PROXYLAYER_BASE_URL?.trim() ||
61
+ stored.baseUrl ||
62
+ DEFAULT_BASE_URL;
63
+ return {
64
+ apiKey,
65
+ email: stored.email,
66
+ baseUrl: rawBaseUrl.replace(/\/+$/, ""),
67
+ configPath,
68
+ };
69
+ }
@@ -0,0 +1,3 @@
1
+ export { ProxyLayer, ProxyLayerError, type BalanceResponse, type CatalogResponse, type CheckoutPurchaseInput, type CheckoutResponse, type CheckoutStatusResponse, type FixedProductSlug, type FixedPurchaseItem, type OrdersResponse, type OtpRequestResponse, type OtpVerifyResponse, type PaymentMethod, type ProductSlug, type ProxyLayerOptions, type ProxyStringFormat, type QuotePurchaseInput, type QuoteResponse, type ResidentialProxiesResponse, type StaticProxiesResponse, } from "./client.js";
2
+ export { clearConfig, DEFAULT_BASE_URL, getConfigPath, readConfig, resolveConfig, saveConfig, type ResolvedConfig, type StoredConfig, } from "./config.js";
3
+ export { runStdioMcpServer, type StdioMcpOptions } from "./mcp.js";
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { ProxyLayer, ProxyLayerError, } from "./client.js";
2
+ export { clearConfig, DEFAULT_BASE_URL, getConfigPath, readConfig, resolveConfig, saveConfig, } from "./config.js";
3
+ export { runStdioMcpServer } from "./mcp.js";
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export type StdioMcpOptions = {
2
+ apiKey?: string;
3
+ baseUrl?: string;
4
+ configPath?: string;
5
+ input?: NodeJS.ReadableStream;
6
+ output?: NodeJS.WritableStream;
7
+ fetch?: typeof globalThis.fetch;
8
+ };
9
+ export declare function runStdioMcpServer(options?: StdioMcpOptions): Promise<void>;
package/dist/mcp.js ADDED
@@ -0,0 +1,127 @@
1
+ import readline from "node:readline";
2
+ import { resolveConfig, saveConfig } from "./config.js";
3
+ const PUBLIC_TOOLS = new Set(["get_catalog", "auth_request_otp", "auth_verify_otp"]);
4
+ function writeJsonLine(output, payload) {
5
+ output.write(`${JSON.stringify(payload)}\n`);
6
+ }
7
+ function extractVerifiedCredentials(result) {
8
+ if (!result || result.isError)
9
+ return null;
10
+ const structured = result.structuredContent;
11
+ let candidate = structured && typeof structured === "object" ? structured : null;
12
+ if (!candidate && Array.isArray(result.content)) {
13
+ const firstText = result.content.find((item) => Boolean(item && typeof item === "object" && item.type === "text"))?.text;
14
+ if (firstText) {
15
+ try {
16
+ const parsed = JSON.parse(firstText);
17
+ if (parsed && typeof parsed === "object")
18
+ candidate = parsed;
19
+ }
20
+ catch {
21
+ candidate = null;
22
+ }
23
+ }
24
+ }
25
+ if (!candidate || typeof candidate.apiKey !== "string" || !candidate.apiKey.startsWith("pl_live_")) {
26
+ return null;
27
+ }
28
+ const user = candidate.user;
29
+ const email = user && typeof user === "object" && typeof user.email === "string"
30
+ ? user.email
31
+ : undefined;
32
+ return { apiKey: candidate.apiKey, email };
33
+ }
34
+ export async function runStdioMcpServer(options) {
35
+ const input = options?.input ?? process.stdin;
36
+ const output = options?.output ?? process.stdout;
37
+ const fetchFn = options?.fetch ?? globalThis.fetch;
38
+ const initialConfig = resolveConfig({
39
+ apiKey: options?.apiKey,
40
+ baseUrl: options?.baseUrl,
41
+ configPath: options?.configPath,
42
+ });
43
+ const endpointUrl = `${initialConfig.baseUrl}/api/mcp`;
44
+ let sessionApiKey = initialConfig.apiKey;
45
+ const handleLine = async (line) => {
46
+ const trimmed = line.trim();
47
+ if (!trimmed)
48
+ return;
49
+ let requestMessage;
50
+ try {
51
+ requestMessage = JSON.parse(trimmed);
52
+ }
53
+ catch {
54
+ writeJsonLine(output, {
55
+ jsonrpc: "2.0",
56
+ id: null,
57
+ error: { code: -32700, message: "Parse error: invalid JSON" },
58
+ });
59
+ return;
60
+ }
61
+ const hasId = requestMessage.id !== undefined;
62
+ const method = typeof requestMessage.method === "string" ? requestMessage.method : "";
63
+ const toolName = method === "tools/call" && requestMessage.params && typeof requestMessage.params.name === "string"
64
+ ? requestMessage.params.name
65
+ : "";
66
+ const sendAuth = Boolean(sessionApiKey) && !PUBLIC_TOOLS.has(toolName);
67
+ try {
68
+ const response = await fetchFn(endpointUrl, {
69
+ method: "POST",
70
+ headers: {
71
+ "Content-Type": "application/json",
72
+ ...(sendAuth && sessionApiKey ? { Authorization: `Bearer ${sessionApiKey}` } : {}),
73
+ },
74
+ body: trimmed,
75
+ });
76
+ if (response.status === 202 || !hasId)
77
+ return;
78
+ const raw = await response.text();
79
+ if (!raw)
80
+ return;
81
+ let rpcResponse;
82
+ try {
83
+ rpcResponse = JSON.parse(raw);
84
+ }
85
+ catch {
86
+ writeJsonLine(output, {
87
+ jsonrpc: "2.0",
88
+ id: requestMessage.id ?? null,
89
+ error: { code: -32603, message: `Invalid response from ${endpointUrl} (${response.status})` },
90
+ });
91
+ return;
92
+ }
93
+ if (method === "initialize" && rpcResponse.result && typeof rpcResponse.result === "object") {
94
+ const existing = typeof rpcResponse.result.instructions === "string" ? rpcResponse.result.instructions : "";
95
+ rpcResponse.result.instructions = `${existing} Local stdio bridge: auth_verify_otp automatically saves the returned pl_live_... key locally for immediate use in this session.`.trim();
96
+ }
97
+ if (toolName === "auth_verify_otp") {
98
+ const verified = extractVerifiedCredentials(rpcResponse.result);
99
+ if (verified) {
100
+ sessionApiKey = verified.apiKey;
101
+ saveConfig({
102
+ apiKey: verified.apiKey,
103
+ email: verified.email,
104
+ baseUrl: options?.baseUrl?.trim() || undefined,
105
+ }, options?.configPath);
106
+ }
107
+ }
108
+ writeJsonLine(output, rpcResponse);
109
+ }
110
+ catch (error) {
111
+ if (!hasId)
112
+ return;
113
+ writeJsonLine(output, {
114
+ jsonrpc: "2.0",
115
+ id: requestMessage.id ?? null,
116
+ error: {
117
+ code: -32603,
118
+ message: error instanceof Error ? error.message : "Failed to reach ProxyLayer MCP endpoint",
119
+ },
120
+ });
121
+ }
122
+ };
123
+ const rl = readline.createInterface({ input, crlfDelay: Infinity });
124
+ for await (const line of rl) {
125
+ await handleLine(line);
126
+ }
127
+ }
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@proxylayer/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Zero-dependency ProxyLayer CLI, local stdio MCP server, and TypeScript/JavaScript SDK.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=20.0.0"
9
+ },
10
+ "bin": {
11
+ "proxylayer": "./dist/cli.js"
12
+ },
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md"
24
+ ],
25
+ "keywords": [
26
+ "proxy",
27
+ "proxies",
28
+ "mcp",
29
+ "model-context-protocol",
30
+ "cli",
31
+ "sdk",
32
+ "proxylayer"
33
+ ],
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.json && node -e \"import('node:fs').then((fs) => fs.chmodSync('dist/cli.js', 0o755))\"",
36
+ "test": "npm run build && node --test ./test/proxylayer.test.mjs"
37
+ },
38
+ "devDependencies": {
39
+ "typescript": "^5.9.3"
40
+ }
41
+ }