@relayrail/server 0.1.6 → 0.1.7
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/cli.js +47 -4
- package/dist/index.d.ts +10 -2
- package/dist/index.js +47 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1576,16 +1576,22 @@ function createProxyRouter(config) {
|
|
|
1576
1576
|
var VERSION = "0.1.0";
|
|
1577
1577
|
var RelayRailServer = class {
|
|
1578
1578
|
server;
|
|
1579
|
-
supabase;
|
|
1579
|
+
supabase = null;
|
|
1580
1580
|
config;
|
|
1581
1581
|
context = null;
|
|
1582
1582
|
router = null;
|
|
1583
1583
|
constructor(config) {
|
|
1584
1584
|
this.config = config;
|
|
1585
|
-
|
|
1585
|
+
const hasSupabaseCredentials = config.supabaseServiceRoleKey && config.supabaseServiceRoleKey.length > 0;
|
|
1586
|
+
if (hasSupabaseCredentials) {
|
|
1587
|
+
this.supabase = createServiceClient(config.supabaseUrl, config.supabaseServiceRoleKey);
|
|
1588
|
+
}
|
|
1586
1589
|
const hasEmail = !!config.resendApiKey;
|
|
1587
1590
|
const hasSms = !!(config.telnyxApiKey && config.telnyxPhoneNumber);
|
|
1588
1591
|
if (hasEmail || hasSms) {
|
|
1592
|
+
if (!this.supabase) {
|
|
1593
|
+
throw new Error("Supabase credentials required when using local email/SMS configuration");
|
|
1594
|
+
}
|
|
1589
1595
|
this.router = createRouter(
|
|
1590
1596
|
{
|
|
1591
1597
|
baseUrl: config.baseUrl,
|
|
@@ -1605,7 +1611,6 @@ var RelayRailServer = class {
|
|
|
1605
1611
|
this.supabase
|
|
1606
1612
|
);
|
|
1607
1613
|
} else if (config.apiKey) {
|
|
1608
|
-
console.log("[RelayRail] Using proxy router for message delivery");
|
|
1609
1614
|
this.router = createProxyRouter({
|
|
1610
1615
|
apiUrl: config.baseUrl,
|
|
1611
1616
|
apiKey: config.apiKey
|
|
@@ -1617,6 +1622,26 @@ var RelayRailServer = class {
|
|
|
1617
1622
|
});
|
|
1618
1623
|
this.registerTools();
|
|
1619
1624
|
}
|
|
1625
|
+
/**
|
|
1626
|
+
* Check if we're in proxy mode (no direct Supabase access)
|
|
1627
|
+
*/
|
|
1628
|
+
isProxyMode() {
|
|
1629
|
+
return !this.supabase && !!this.config.apiKey;
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* Make a proxy API call
|
|
1633
|
+
*/
|
|
1634
|
+
async proxyApiCall(endpoint, body) {
|
|
1635
|
+
const response = await fetch(`${this.config.baseUrl}/api/mcp/${endpoint}`, {
|
|
1636
|
+
method: "POST",
|
|
1637
|
+
headers: {
|
|
1638
|
+
"Content-Type": "application/json",
|
|
1639
|
+
"Authorization": `Bearer ${this.config.apiKey}`
|
|
1640
|
+
},
|
|
1641
|
+
body: JSON.stringify(body)
|
|
1642
|
+
});
|
|
1643
|
+
return response.json();
|
|
1644
|
+
}
|
|
1620
1645
|
/**
|
|
1621
1646
|
* Register all MCP tools
|
|
1622
1647
|
*/
|
|
@@ -1638,6 +1663,12 @@ var RelayRailServer = class {
|
|
|
1638
1663
|
};
|
|
1639
1664
|
}
|
|
1640
1665
|
try {
|
|
1666
|
+
if (this.isProxyMode()) {
|
|
1667
|
+
const result2 = await this.proxyApiCall("request-approval", params);
|
|
1668
|
+
return {
|
|
1669
|
+
content: [{ type: "text", text: JSON.stringify(result2) }]
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1641
1672
|
const result = await requestApproval(
|
|
1642
1673
|
params,
|
|
1643
1674
|
{
|
|
@@ -1681,6 +1712,12 @@ var RelayRailServer = class {
|
|
|
1681
1712
|
};
|
|
1682
1713
|
}
|
|
1683
1714
|
try {
|
|
1715
|
+
if (this.isProxyMode()) {
|
|
1716
|
+
const result2 = await this.proxyApiCall("send-notification", params);
|
|
1717
|
+
return {
|
|
1718
|
+
content: [{ type: "text", text: JSON.stringify(result2) }]
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1684
1721
|
const result = await sendNotification(
|
|
1685
1722
|
params,
|
|
1686
1723
|
{
|
|
@@ -1722,6 +1759,12 @@ var RelayRailServer = class {
|
|
|
1722
1759
|
};
|
|
1723
1760
|
}
|
|
1724
1761
|
try {
|
|
1762
|
+
if (this.isProxyMode()) {
|
|
1763
|
+
const result2 = await this.proxyApiCall("await-response", params);
|
|
1764
|
+
return {
|
|
1765
|
+
content: [{ type: "text", text: JSON.stringify(result2) }]
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1725
1768
|
const result = await awaitResponse(
|
|
1726
1769
|
params,
|
|
1727
1770
|
{
|
|
@@ -1888,7 +1931,7 @@ var RelayRailServer = class {
|
|
|
1888
1931
|
return this.server;
|
|
1889
1932
|
}
|
|
1890
1933
|
/**
|
|
1891
|
-
* Get the Supabase client
|
|
1934
|
+
* Get the Supabase client (may be null in proxy mode)
|
|
1892
1935
|
*/
|
|
1893
1936
|
getSupabase() {
|
|
1894
1937
|
return this.supabase;
|
package/dist/index.d.ts
CHANGED
|
@@ -239,6 +239,14 @@ declare class RelayRailServer {
|
|
|
239
239
|
private context;
|
|
240
240
|
private router;
|
|
241
241
|
constructor(config: ServerConfig);
|
|
242
|
+
/**
|
|
243
|
+
* Check if we're in proxy mode (no direct Supabase access)
|
|
244
|
+
*/
|
|
245
|
+
private isProxyMode;
|
|
246
|
+
/**
|
|
247
|
+
* Make a proxy API call
|
|
248
|
+
*/
|
|
249
|
+
private proxyApiCall;
|
|
242
250
|
/**
|
|
243
251
|
* Register all MCP tools
|
|
244
252
|
*/
|
|
@@ -260,9 +268,9 @@ declare class RelayRailServer {
|
|
|
260
268
|
*/
|
|
261
269
|
getMcpServer(): McpServer;
|
|
262
270
|
/**
|
|
263
|
-
* Get the Supabase client
|
|
271
|
+
* Get the Supabase client (may be null in proxy mode)
|
|
264
272
|
*/
|
|
265
|
-
getSupabase(): TypedSupabaseClient;
|
|
273
|
+
getSupabase(): TypedSupabaseClient | null;
|
|
266
274
|
/**
|
|
267
275
|
* Get the server configuration
|
|
268
276
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1574,16 +1574,22 @@ function createProxyRouter(config) {
|
|
|
1574
1574
|
var VERSION = "0.1.0";
|
|
1575
1575
|
var RelayRailServer = class {
|
|
1576
1576
|
server;
|
|
1577
|
-
supabase;
|
|
1577
|
+
supabase = null;
|
|
1578
1578
|
config;
|
|
1579
1579
|
context = null;
|
|
1580
1580
|
router = null;
|
|
1581
1581
|
constructor(config) {
|
|
1582
1582
|
this.config = config;
|
|
1583
|
-
|
|
1583
|
+
const hasSupabaseCredentials = config.supabaseServiceRoleKey && config.supabaseServiceRoleKey.length > 0;
|
|
1584
|
+
if (hasSupabaseCredentials) {
|
|
1585
|
+
this.supabase = createServiceClient(config.supabaseUrl, config.supabaseServiceRoleKey);
|
|
1586
|
+
}
|
|
1584
1587
|
const hasEmail = !!config.resendApiKey;
|
|
1585
1588
|
const hasSms = !!(config.telnyxApiKey && config.telnyxPhoneNumber);
|
|
1586
1589
|
if (hasEmail || hasSms) {
|
|
1590
|
+
if (!this.supabase) {
|
|
1591
|
+
throw new Error("Supabase credentials required when using local email/SMS configuration");
|
|
1592
|
+
}
|
|
1587
1593
|
this.router = createRouter(
|
|
1588
1594
|
{
|
|
1589
1595
|
baseUrl: config.baseUrl,
|
|
@@ -1603,7 +1609,6 @@ var RelayRailServer = class {
|
|
|
1603
1609
|
this.supabase
|
|
1604
1610
|
);
|
|
1605
1611
|
} else if (config.apiKey) {
|
|
1606
|
-
console.log("[RelayRail] Using proxy router for message delivery");
|
|
1607
1612
|
this.router = createProxyRouter({
|
|
1608
1613
|
apiUrl: config.baseUrl,
|
|
1609
1614
|
apiKey: config.apiKey
|
|
@@ -1615,6 +1620,26 @@ var RelayRailServer = class {
|
|
|
1615
1620
|
});
|
|
1616
1621
|
this.registerTools();
|
|
1617
1622
|
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Check if we're in proxy mode (no direct Supabase access)
|
|
1625
|
+
*/
|
|
1626
|
+
isProxyMode() {
|
|
1627
|
+
return !this.supabase && !!this.config.apiKey;
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Make a proxy API call
|
|
1631
|
+
*/
|
|
1632
|
+
async proxyApiCall(endpoint, body) {
|
|
1633
|
+
const response = await fetch(`${this.config.baseUrl}/api/mcp/${endpoint}`, {
|
|
1634
|
+
method: "POST",
|
|
1635
|
+
headers: {
|
|
1636
|
+
"Content-Type": "application/json",
|
|
1637
|
+
"Authorization": `Bearer ${this.config.apiKey}`
|
|
1638
|
+
},
|
|
1639
|
+
body: JSON.stringify(body)
|
|
1640
|
+
});
|
|
1641
|
+
return response.json();
|
|
1642
|
+
}
|
|
1618
1643
|
/**
|
|
1619
1644
|
* Register all MCP tools
|
|
1620
1645
|
*/
|
|
@@ -1636,6 +1661,12 @@ var RelayRailServer = class {
|
|
|
1636
1661
|
};
|
|
1637
1662
|
}
|
|
1638
1663
|
try {
|
|
1664
|
+
if (this.isProxyMode()) {
|
|
1665
|
+
const result2 = await this.proxyApiCall("request-approval", params);
|
|
1666
|
+
return {
|
|
1667
|
+
content: [{ type: "text", text: JSON.stringify(result2) }]
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1639
1670
|
const result = await requestApproval(
|
|
1640
1671
|
params,
|
|
1641
1672
|
{
|
|
@@ -1679,6 +1710,12 @@ var RelayRailServer = class {
|
|
|
1679
1710
|
};
|
|
1680
1711
|
}
|
|
1681
1712
|
try {
|
|
1713
|
+
if (this.isProxyMode()) {
|
|
1714
|
+
const result2 = await this.proxyApiCall("send-notification", params);
|
|
1715
|
+
return {
|
|
1716
|
+
content: [{ type: "text", text: JSON.stringify(result2) }]
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1682
1719
|
const result = await sendNotification(
|
|
1683
1720
|
params,
|
|
1684
1721
|
{
|
|
@@ -1720,6 +1757,12 @@ var RelayRailServer = class {
|
|
|
1720
1757
|
};
|
|
1721
1758
|
}
|
|
1722
1759
|
try {
|
|
1760
|
+
if (this.isProxyMode()) {
|
|
1761
|
+
const result2 = await this.proxyApiCall("await-response", params);
|
|
1762
|
+
return {
|
|
1763
|
+
content: [{ type: "text", text: JSON.stringify(result2) }]
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1723
1766
|
const result = await awaitResponse(
|
|
1724
1767
|
params,
|
|
1725
1768
|
{
|
|
@@ -1886,7 +1929,7 @@ var RelayRailServer = class {
|
|
|
1886
1929
|
return this.server;
|
|
1887
1930
|
}
|
|
1888
1931
|
/**
|
|
1889
|
-
* Get the Supabase client
|
|
1932
|
+
* Get the Supabase client (may be null in proxy mode)
|
|
1890
1933
|
*/
|
|
1891
1934
|
getSupabase() {
|
|
1892
1935
|
return this.supabase;
|