@mcpaid/sdk 2.0.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.
Files changed (111) hide show
  1. package/LICENSE +176 -0
  2. package/NPM_RESTRUCTURE.md +86 -0
  3. package/OPERATOR-LICENSE.md +18 -0
  4. package/README.md +380 -0
  5. package/SELF-HOSTING.md +108 -0
  6. package/dist/circuit-breaker/circuit-breaker.d.ts +26 -0
  7. package/dist/circuit-breaker/circuit-breaker.d.ts.map +1 -0
  8. package/dist/circuit-breaker/circuit-breaker.js +128 -0
  9. package/dist/circuit-breaker/circuit-breaker.js.map +1 -0
  10. package/dist/cli.d.ts +21 -0
  11. package/dist/cli.d.ts.map +1 -0
  12. package/dist/cli.js +1560 -0
  13. package/dist/cli.js.map +1 -0
  14. package/dist/contracts/ToolPayRouter.d.ts +288 -0
  15. package/dist/contracts/ToolPayRouter.d.ts.map +1 -0
  16. package/dist/contracts/ToolPayRouter.js +370 -0
  17. package/dist/contracts/ToolPayRouter.js.map +1 -0
  18. package/dist/contracts/router-registry.d.ts +19 -0
  19. package/dist/contracts/router-registry.d.ts.map +1 -0
  20. package/dist/contracts/router-registry.js +28 -0
  21. package/dist/contracts/router-registry.js.map +1 -0
  22. package/dist/fee/fee-calculator.d.ts +35 -0
  23. package/dist/fee/fee-calculator.d.ts.map +1 -0
  24. package/dist/fee/fee-calculator.js +57 -0
  25. package/dist/fee/fee-calculator.js.map +1 -0
  26. package/dist/fee/fee-ledger.d.ts +66 -0
  27. package/dist/fee/fee-ledger.d.ts.map +1 -0
  28. package/dist/fee/fee-ledger.js +181 -0
  29. package/dist/fee/fee-ledger.js.map +1 -0
  30. package/dist/gateway/config-loader.d.ts +38 -0
  31. package/dist/gateway/config-loader.d.ts.map +1 -0
  32. package/dist/gateway/config-loader.js +125 -0
  33. package/dist/gateway/config-loader.js.map +1 -0
  34. package/dist/gateway/server-registry.d.ts +25 -0
  35. package/dist/gateway/server-registry.d.ts.map +1 -0
  36. package/dist/gateway/server-registry.js +59 -0
  37. package/dist/gateway/server-registry.js.map +1 -0
  38. package/dist/gateway/toolpay-gateway.d.ts +57 -0
  39. package/dist/gateway/toolpay-gateway.d.ts.map +1 -0
  40. package/dist/gateway/toolpay-gateway.js +320 -0
  41. package/dist/gateway/toolpay-gateway.js.map +1 -0
  42. package/dist/index.d.ts +36 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +37 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/sdk/client-agent.d.ts +47 -0
  47. package/dist/sdk/client-agent.d.ts.map +1 -0
  48. package/dist/sdk/client-agent.js +158 -0
  49. package/dist/sdk/client-agent.js.map +1 -0
  50. package/dist/sdk/server-sdk.d.ts +51 -0
  51. package/dist/sdk/server-sdk.d.ts.map +1 -0
  52. package/dist/sdk/server-sdk.js +170 -0
  53. package/dist/sdk/server-sdk.js.map +1 -0
  54. package/dist/settlement/base-contract-client.d.ts +156 -0
  55. package/dist/settlement/base-contract-client.d.ts.map +1 -0
  56. package/dist/settlement/base-contract-client.js +156 -0
  57. package/dist/settlement/base-contract-client.js.map +1 -0
  58. package/dist/settlement/nonce-store.d.ts +54 -0
  59. package/dist/settlement/nonce-store.d.ts.map +1 -0
  60. package/dist/settlement/nonce-store.js +125 -0
  61. package/dist/settlement/nonce-store.js.map +1 -0
  62. package/dist/settlement/onchain-verifier.d.ts +41 -0
  63. package/dist/settlement/onchain-verifier.d.ts.map +1 -0
  64. package/dist/settlement/onchain-verifier.js +114 -0
  65. package/dist/settlement/onchain-verifier.js.map +1 -0
  66. package/dist/settlement/payment-orchestrator.d.ts +59 -0
  67. package/dist/settlement/payment-orchestrator.d.ts.map +1 -0
  68. package/dist/settlement/payment-orchestrator.js +282 -0
  69. package/dist/settlement/payment-orchestrator.js.map +1 -0
  70. package/dist/settlement/permit-verifier.d.ts +60 -0
  71. package/dist/settlement/permit-verifier.d.ts.map +1 -0
  72. package/dist/settlement/permit-verifier.js +80 -0
  73. package/dist/settlement/permit-verifier.js.map +1 -0
  74. package/dist/settlement/session-wallet.d.ts +60 -0
  75. package/dist/settlement/session-wallet.d.ts.map +1 -0
  76. package/dist/settlement/session-wallet.js +105 -0
  77. package/dist/settlement/session-wallet.js.map +1 -0
  78. package/dist/transports/sse-transport.d.ts +27 -0
  79. package/dist/transports/sse-transport.d.ts.map +1 -0
  80. package/dist/transports/sse-transport.js +65 -0
  81. package/dist/transports/sse-transport.js.map +1 -0
  82. package/dist/transports/stdio-bridge.d.ts +29 -0
  83. package/dist/transports/stdio-bridge.d.ts.map +1 -0
  84. package/dist/transports/stdio-bridge.js +133 -0
  85. package/dist/transports/stdio-bridge.js.map +1 -0
  86. package/dist/types/circuit-breaker.d.ts +22 -0
  87. package/dist/types/circuit-breaker.d.ts.map +1 -0
  88. package/dist/types/circuit-breaker.js +5 -0
  89. package/dist/types/circuit-breaker.js.map +1 -0
  90. package/dist/types/ledger.d.ts +57 -0
  91. package/dist/types/ledger.d.ts.map +1 -0
  92. package/dist/types/ledger.js +5 -0
  93. package/dist/types/ledger.js.map +1 -0
  94. package/dist/types/mcp.d.ts +67 -0
  95. package/dist/types/mcp.d.ts.map +1 -0
  96. package/dist/types/mcp.js +5 -0
  97. package/dist/types/mcp.js.map +1 -0
  98. package/dist/types/pricing.d.ts +68 -0
  99. package/dist/types/pricing.d.ts.map +1 -0
  100. package/dist/types/pricing.js +5 -0
  101. package/dist/types/pricing.js.map +1 -0
  102. package/dist/types/x402.d.ts +76 -0
  103. package/dist/types/x402.d.ts.map +1 -0
  104. package/dist/types/x402.js +5 -0
  105. package/dist/types/x402.js.map +1 -0
  106. package/dist/utils/units.d.ts +45 -0
  107. package/dist/utils/units.d.ts.map +1 -0
  108. package/dist/utils/units.js +141 -0
  109. package/dist/utils/units.js.map +1 -0
  110. package/package.json +72 -0
  111. package/src/contracts/ToolPayRouter.json +371 -0
@@ -0,0 +1,108 @@
1
+ # MCPaid Self-Hosting Guide (Operators Only)
2
+
3
+ > This guide is for operators who want to run their **own isolated gateway** instead of using the hosted MCPaid network at `https://mcpaid.dev`.
4
+ >
5
+ > **Trade-off:** a self-hosted gateway is a separate network. You lose hosted discovery (`mcpaid.dev/mcp/:id`), dashboard logins, and the managed 60-second relayer, and you take on all Cloudflare ops, relayer key custody, and settlement yourself. Most developers should just use `mcpaid publish` / `mcpaid dev` (see `README.md`).
6
+ >
7
+ > License: Apache-2.0 — forking/operating your own instance is permitted. You may set your own `platformFeeBps` / treasury, including zero fees on your own network. That does not affect the hosted `mcpaid.dev` network.
8
+
9
+ > **Production self-hosts:** operating the edge gateway with real users/USDC requires either settling through the official routers (`src/contracts/router-registry.ts`) or a commercial operator agreement — see `OPERATOR-LICENSE.md`. Non-production (local dev, `base-sepolia`, CI) needs no agreement. Changing `ROUTER_CONTRACT_ADDRESS` to divert the cut in production breaches the operator license (technically possible, legally a breach + delisting).
10
+
11
+ This content was previously (incorrectly) published on the user-facing npm README. It lives here now so `README.md` stays user-focused.
12
+
13
+ ---
14
+
15
+ ## 1. Local Development & Building (from source checkout, not from npm tarball)
16
+
17
+ The npm tarball ships `dist/` only — self-hosting requires a git checkout:
18
+
19
+ ```bash
20
+ # Install dependencies
21
+ npm install
22
+
23
+ # Compile smart contracts with solc
24
+ npm run compile:contracts
25
+
26
+ # Compile TypeScript
27
+ npm run build
28
+
29
+ # Run test suite (146 tests across 23 suites)
30
+ npm test
31
+
32
+ # Run local Cloudflare Workers development server
33
+ npx wrangler dev
34
+
35
+ # Deploy to your own Cloudflare Workers account (Edge)
36
+ npx wrangler deploy
37
+ ```
38
+
39
+ ## 2. Cloudflare D1 Database Setup (your own account)
40
+
41
+ ```bash
42
+ # 1. Create D1 database on Cloudflare
43
+ npx wrangler d1 create toolpay-prod-db
44
+
45
+ # 2. Apply database migrations
46
+ npx wrangler d1 execute toolpay-prod-db --local --file=./migrations/0001_initial_schema.sql
47
+ npx wrangler d1 execute toolpay-prod-db --remote --file=./migrations/0001_initial_schema.sql
48
+ npx wrangler d1 execute toolpay-prod-db --remote --file=./migrations/0002_user_accounts.sql
49
+ npx wrangler d1 execute toolpay-prod-db --remote --file=./migrations/0003_withdrawals.sql
50
+ ```
51
+
52
+ Create KV namespace for challenge nonces and wire `TOOLPAY_DB` / `TOOLPAY_NONCES` bindings in your own `wrangler.jsonc`. Never reuse MCPaid's production IDs.
53
+
54
+ ## 3. Base L2 Smart Contract Deployment (your own treasury)
55
+
56
+ ```bash
57
+ # Compile contracts (generates ABI & bytecode)
58
+ npx tsx scripts/compile-contract.ts
59
+
60
+ # 1. Deploy ToolPayRouter to Base Sepolia (testnet, Chain ID 84532)
61
+ DEPLOYER_PRIVATE_KEY="0x..." BASE_NETWORK="base-sepolia" npx tsx scripts/deploy-contract.ts
62
+
63
+ # 2. Deploy ToolPayRouter to Base Mainnet (production, Chain ID 8453)
64
+ DEPLOYER_PRIVATE_KEY="0x..." BASE_NETWORK="base-mainnet" npx tsx scripts/deploy-contract.ts
65
+ ```
66
+
67
+ Never commit real private keys (`.env` is gitignored for a reason). Prefer `wrangler secret` / your CI secret manager.
68
+
69
+ ### Production Activation Checklist (your own worker)
70
+
71
+ 1. Deploy contract above targeting `base-mainnet`. Copy the contract address.
72
+ 2. Set worker secrets & vars:
73
+
74
+ ```bash
75
+ npx wrangler secret put ROUTER_CONTRACT_ADDRESS
76
+ # paste your Base Mainnet contract address
77
+ npx wrangler secret put RELAYER_PRIVATE_KEY
78
+ npx wrangler secret put TOOLPAY_ADMIN_KEY
79
+ ```
80
+
81
+ ```toml
82
+ # wrangler vars (example)
83
+ BASE_NETWORK = "base"
84
+ BASE_RPC_URL = "https://mainnet.base.org"
85
+ ```
86
+
87
+ 3. Deploy edge worker:
88
+
89
+ ```bash
90
+ npx wrangler deploy
91
+ ```
92
+
93
+ 4. Verify: unauthenticated `POST /v1/auth/test-email` must 401, signup/login must not leak OTP codes, and `ROUTER_CONTRACT_ADDRESS` must be set (unset = router verification bypass — fail-open).
94
+
95
+ ## 4. Lightweight Alternative (no Cloudflare): local/embedded gateway
96
+
97
+ If you don't need the global edge at all, run the gateway in-process instead of deploying Workers:
98
+
99
+ ```bash
100
+ npx @mcpaid/sdk start
101
+ ```
102
+
103
+ ```typescript
104
+ import { McpaidServer } from '@mcpaid/sdk';
105
+ const mcpaid = new McpaidServer({ serverId: 'custom-mcp', payoutWallet: '0x...', network: 'base' });
106
+ ```
107
+
108
+ See `DOCS.md` Option 4. Same fork semantics: your fees, your ops.
@@ -0,0 +1,26 @@
1
+ /**
2
+ * ToolPay Circuit Breaker & Agent Loop Prevention Engine
3
+ * Protects agents and developers from runaway execution loops, rapid spam, and excessive wallet drain.
4
+ */
5
+ import { CircuitBreakerCheckParams, CircuitBreakerCheckResult } from '../types/circuit-breaker.js';
6
+ import { ToolCircuitBreakerConfig } from '../types/pricing.js';
7
+ export declare const DEFAULT_MAX_CALLS_PER_MINUTE = 30;
8
+ export declare const DEFAULT_MAX_CONSECUTIVE_DUPLICATES = 3;
9
+ export declare const MAX_TRACKED_SESSIONS = 10000;
10
+ export declare class CircuitBreaker {
11
+ private sessions;
12
+ /**
13
+ * Evaluates if a paid tool call is allowed according to velocity limits,
14
+ * budget caps, and runaway duplicate loop heuristics.
15
+ */
16
+ check(params: CircuitBreakerCheckParams, config?: ToolCircuitBreakerConfig): CircuitBreakerCheckResult;
17
+ /**
18
+ * Commits the execution and updates the session counters.
19
+ */
20
+ commit(params: CircuitBreakerCheckParams): void;
21
+ /**
22
+ * Resets session state for an agent (useful for testing or session renewals).
23
+ */
24
+ resetSession(serverId: string, agentWallet: string): void;
25
+ }
26
+ //# sourceMappingURL=circuit-breaker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circuit-breaker.d.ts","sourceRoot":"","sources":["../../src/circuit-breaker/circuit-breaker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAkB/D,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,kCAAkC,IAAI,CAAC;AACpD,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAE3C,qBAAa,cAAc;IAEzB,OAAO,CAAC,QAAQ,CAA6C;IAE7D;;;OAGG;IACI,KAAK,CACV,MAAM,EAAE,yBAAyB,EACjC,MAAM,CAAC,EAAE,wBAAwB,GAChC,yBAAyB;IAwF5B;;OAEG;IACI,MAAM,CAAC,MAAM,EAAE,yBAAyB,GAAG,IAAI;IAsBtD;;OAEG;IACI,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;CAIjE"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * ToolPay Circuit Breaker & Agent Loop Prevention Engine
3
+ * Protects agents and developers from runaway execution loops, rapid spam, and excessive wallet drain.
4
+ */
5
+ import { usdToMicro, canonicalJsonStringify } from '../utils/units.js';
6
+ import { createHash } from 'node:crypto';
7
+ export const DEFAULT_MAX_CALLS_PER_MINUTE = 30;
8
+ export const DEFAULT_MAX_CONSECUTIVE_DUPLICATES = 3;
9
+ export const MAX_TRACKED_SESSIONS = 10_000;
10
+ export class CircuitBreaker {
11
+ // Key: `${serverId}:${agentWallet.toLowerCase()}`
12
+ sessions = new Map();
13
+ /**
14
+ * Evaluates if a paid tool call is allowed according to velocity limits,
15
+ * budget caps, and runaway duplicate loop heuristics.
16
+ */
17
+ check(params, config) {
18
+ const now = params.timestamp || Date.now();
19
+ const sessionKey = `${params.serverId}:${params.agentWallet.toLowerCase()}`;
20
+ // Bounded map protection against unbounded memory growth
21
+ if (this.sessions.size >= MAX_TRACKED_SESSIONS) {
22
+ const oneHourAgo = now - 3600_000;
23
+ for (const [k, s] of this.sessions.entries()) {
24
+ if (s.lastSeen < oneHourAgo) {
25
+ this.sessions.delete(k);
26
+ }
27
+ }
28
+ }
29
+ let state = this.sessions.get(sessionKey);
30
+ if (!state) {
31
+ state = {
32
+ calls: [],
33
+ totalSpendMicro: 0n,
34
+ consecutiveDuplicateCount: 0,
35
+ lastSeen: now,
36
+ };
37
+ this.sessions.set(sessionKey, state);
38
+ }
39
+ state.lastSeen = now;
40
+ // 1. Prune records older than 60 seconds for sliding-window velocity check
41
+ const oneMinuteAgo = now - 60_000;
42
+ state.calls = state.calls.filter((c) => c.timestamp > oneMinuteAgo);
43
+ // 2. Velocity Check (calls per minute)
44
+ const maxCallsPerMinute = config?.maxCallsPerMinute ?? DEFAULT_MAX_CALLS_PER_MINUTE;
45
+ if (state.calls.length >= maxCallsPerMinute) {
46
+ const oldestInWindow = state.calls[0].timestamp;
47
+ const retryAfterSeconds = Math.max(1, Math.ceil((oldestInWindow + 60_000 - now) / 1000));
48
+ return {
49
+ allowed: false,
50
+ statusCode: 429,
51
+ reason: `Velocity limit exceeded: max ${maxCallsPerMinute} calls per minute.`,
52
+ retryAfterSeconds,
53
+ callsInWindow: state.calls.length,
54
+ maxCallsPerMinute,
55
+ };
56
+ }
57
+ // 3. Session Budget Hard Cap Check
58
+ if (config?.maxSessionSpendUsd) {
59
+ const maxBudgetMicro = usdToMicro(config.maxSessionSpendUsd);
60
+ if (state.totalSpendMicro + params.costMicro > maxBudgetMicro) {
61
+ return {
62
+ allowed: false,
63
+ statusCode: 402,
64
+ reason: `Session budget hard cap exceeded: maximum allowed is $${config.maxSessionSpendUsd}. Current spend: $${(Number(state.totalSpendMicro) / 1_000_000).toFixed(6)}.`,
65
+ currentSpendMicro: state.totalSpendMicro,
66
+ maxSessionSpendMicro: maxBudgetMicro,
67
+ };
68
+ }
69
+ }
70
+ // 4. Runaway Duplicate Argument Loop Detection
71
+ if (config?.preventDuplicateLoops && params.callArguments) {
72
+ const argString = canonicalJsonStringify(params.callArguments);
73
+ const currentArgHash = createHash('sha256').update(argString).digest('hex');
74
+ if (state.lastArgHash === currentArgHash) {
75
+ state.consecutiveDuplicateCount += 1;
76
+ if (state.consecutiveDuplicateCount >= DEFAULT_MAX_CONSECUTIVE_DUPLICATES) {
77
+ return {
78
+ allowed: false,
79
+ statusCode: 429,
80
+ reason: `Runaway execution loop detected: identical arguments passed ${state.consecutiveDuplicateCount} consecutive times in rapid succession.`,
81
+ retryAfterSeconds: 5,
82
+ };
83
+ }
84
+ }
85
+ else {
86
+ state.lastArgHash = currentArgHash;
87
+ state.consecutiveDuplicateCount = 1;
88
+ }
89
+ }
90
+ return {
91
+ allowed: true,
92
+ currentSpendMicro: state.totalSpendMicro,
93
+ callsInWindow: state.calls.length,
94
+ maxCallsPerMinute,
95
+ };
96
+ }
97
+ /**
98
+ * Commits the execution and updates the session counters.
99
+ */
100
+ commit(params) {
101
+ const now = params.timestamp || Date.now();
102
+ const sessionKey = `${params.serverId}:${params.agentWallet.toLowerCase()}`;
103
+ let state = this.sessions.get(sessionKey);
104
+ if (!state) {
105
+ state = {
106
+ calls: [],
107
+ totalSpendMicro: 0n,
108
+ consecutiveDuplicateCount: 0,
109
+ lastSeen: now,
110
+ };
111
+ this.sessions.set(sessionKey, state);
112
+ }
113
+ state.lastSeen = now;
114
+ state.calls.push({
115
+ timestamp: now,
116
+ costMicro: params.costMicro,
117
+ });
118
+ state.totalSpendMicro += params.costMicro;
119
+ }
120
+ /**
121
+ * Resets session state for an agent (useful for testing or session renewals).
122
+ */
123
+ resetSession(serverId, agentWallet) {
124
+ const sessionKey = `${serverId}:${agentWallet.toLowerCase()}`;
125
+ this.sessions.delete(sessionKey);
126
+ }
127
+ }
128
+ //# sourceMappingURL=circuit-breaker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circuit-breaker.js","sourceRoot":"","sources":["../../src/circuit-breaker/circuit-breaker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAgBzC,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,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G,CAAC,UAAU,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG;gBACN,KAAK,EAAE,EAAE;gBACT,eAAe,EAAE,EAAE;gBACnB,yBAAyB,EAAE,CAAC;gBAC5B,QAAQ,EAAE,GAAG;aACd,CAAC;YACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC;QAErB,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;YACf,SAAS,EAAE,GAAG;YACd,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B,CAAC,CAAC;QACH,KAAK,CAAC,eAAe,IAAI,MAAM,CAAC,SAAS,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,QAAgB,EAAE,WAAmB;QACvD,MAAM,UAAU,GAAG,GAAG,QAAQ,IAAI,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC;QAC9D,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;CACF"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * ToolPay CLI
4
+ * Command-line interface for MCP developers to configure, validate, and launch ToolPay gateways.
5
+ */
6
+ export interface CliCredentials {
7
+ email: string;
8
+ token: string;
9
+ gatewayUrl: string;
10
+ payoutWallet?: string;
11
+ }
12
+ export declare function getCredentialsPath(): string;
13
+ export declare function loadCredentials(): CliCredentials | null;
14
+ export declare function saveCredentials(creds: CliCredentials): void;
15
+ export declare function clearCredentials(): void;
16
+ export declare function getFlagValue(flags: string[], name: string, alias?: string): string | undefined;
17
+ export declare function hasFlag(flags: string[], name: string, alias?: string): boolean;
18
+ export declare function promptQuestion(query: string): Promise<string>;
19
+ export declare function isLocalOrPrivateHost(urlStr: string): boolean;
20
+ export declare function runCli(): Promise<void>;
21
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAqDH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAM3C;AAED,wBAAgB,eAAe,IAAI,cAAc,GAAG,IAAI,CASvD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAG3D;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAOvC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW9F;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAE9E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAW7D;AA8gBD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAmB5D;AA+6BD,wBAAsB,MAAM,kBAkE3B"}