@metorial-services/shuttle-client 1.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.
- package/README.md +21 -0
- package/dist/clients/typescript/src/controller.d.ts +4826 -0
- package/dist/clients/typescript/src/controller.d.ts.map +1 -0
- package/dist/clients/typescript/src/index.d.ts +3 -0
- package/dist/clients/typescript/src/index.d.ts.map +1 -0
- package/dist/clients/typescript/src/live.d.ts +17 -0
- package/dist/clients/typescript/src/live.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5100 -0
- package/dist/index.module.js +2 -0
- package/dist/index.module.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +45 -0
- package/src/controller.ts +5 -0
- package/src/index.ts +2 -0
- package/src/live.ts +47 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createClient as e}from"@lowerdeck/rpc-client";import{IsomorphicWs as n}from"@metorial/util-websocket";var o=function(n){return e(n)},t=function(e){try{return Promise.resolve({connect:function(o){var t=new n(e.endpoint+"/"+o.tenantId+"/connection/"+o.connectionId+"/live");return t.on("open",function(){null==o.onOpen||o.onOpen()}),t.on("message",function(e){var n=JSON.parse(e);null==o.onMessage||o.onMessage({type:n.type,data:n.data})}),t.on("close",function(){null==o.onClose||o.onClose()}),{sendMcpMessage:function(e){try{return Promise.resolve(t.send(JSON.stringify({type:"mcp.message",data:e}))).then(function(){})}catch(e){return Promise.reject(e)}},close:function(){try{return t.close(),Promise.resolve()}catch(e){return Promise.reject(e)}}}}})}catch(e){return Promise.reject(e)}};export{t as createLiveConnectionClient,o as createShuttleClient};
|
|
2
|
+
//# sourceMappingURL=index.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.module.js","sources":["../src/controller.ts","../src/live.ts"],"sourcesContent":["import { createClient } from '@lowerdeck/rpc-client';\nimport { ClientOpts } from '@lowerdeck/rpc-client/dist/shared/clientBuilder';\nimport type { ShuttleClient } from '../../../service/src/apis/controllers';\n\nexport let createShuttleClient = (o: ClientOpts) => createClient<ShuttleClient>(o);\n","import { IsomorphicWs } from '@metorial/util-websocket';\nimport type { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';\nimport type { ConnectionMessage } from '../../../service/src/mcp/utils/messenger';\n\nexport let createLiveConnectionClient = async (opts: { endpoint: string }) => ({\n connect: (d: {\n tenantId: string;\n connectionId: string;\n onOpen?: () => void;\n onMessage?: (msg: ConnectionMessage) => void;\n onClose?: () => void;\n }) => {\n let ws = new IsomorphicWs(\n `${opts.endpoint}/${d.tenantId}/connection/${d.connectionId}/live`\n );\n\n ws.on('open', () => {\n d.onOpen?.();\n });\n\n ws.on('message', (data: string) => {\n let msg: any = JSON.parse(data);\n d.onMessage?.({\n type: msg.type,\n data: msg.data\n });\n });\n\n ws.on('close', () => {\n d.onClose?.();\n });\n\n return {\n sendMcpMessage: async (msg: JSONRPCMessage) => {\n await ws.send(\n JSON.stringify({\n type: 'mcp.message',\n data: msg\n })\n );\n },\n close: async () => {\n ws.close();\n }\n };\n }\n});\n"],"names":["createShuttleClient","o","createClient","createLiveConnectionClient","opts","Promise","resolve","connect","d","ws","IsomorphicWs","endpoint","tenantId","connectionId","on","onOpen","data","msg","JSON","parse","onMessage","type","onClose","sendMcpMessage","send","stringify","then","e","reject","close"],"mappings":"6GAIW,IAAAA,EAAsB,SAACC,GAAa,OAAKC,EAA4BD,EAAE,ECAvEE,EAA0B,SAAUC,GAA0B,IAAA,OAAAC,QAAAC,QAAM,CAC7EC,QAAS,SAACC,GAOR,IAAIC,EAAK,IAAIC,EACRN,EAAKO,aAAYH,EAAEI,SAAQ,eAAeJ,EAAEK,aAAmB,SAmBpE,OAhBAJ,EAAGK,GAAG,OAAQ,WACJ,MAARN,EAAEO,QAAFP,EAAEO,QACJ,GAEAN,EAAGK,GAAG,UAAW,SAACE,GAChB,IAAIC,EAAWC,KAAKC,MAAMH,SAC1BR,EAAEY,WAAFZ,EAAEY,UAAY,CACZC,KAAMJ,EAAII,KACVL,KAAMC,EAAID,MAEd,GAEAP,EAAGK,GAAG,QAAS,WACJ,MAATN,EAAEc,SAAFd,EAAEc,SACJ,GAEO,CACLC,eAAc,SAASN,OAAuBZ,OAAAA,QAAAC,QACtCG,EAAGe,KACPN,KAAKO,UAAU,CACbJ,KAAM,cACNL,KAAMC,MAETS,KAAA,WAAA,EACH,CAAC,MAAAC,GAAAtB,OAAAA,QAAAuB,OAAAD,EAAA,CAAA,EACDE,MAAK,WAAA,IACQ,OAAXpB,EAAGoB,QAAQxB,QAAAC,SACb,CAAC,MAAAqB,GAAAtB,OAAAA,QAAAuB,OAAAD,KAEL,GACD,CAAA,MAAAA,GAAA,OAAAtB,QAAAuB,OAAAD,EAAC,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@lowerdeck/rpc-client"),require("@metorial/util-websocket")):"function"==typeof define&&define.amd?define(["exports","@lowerdeck/rpc-client","@metorial/util-websocket"],n):n((e||self).shuttleClient={},e.rpcClient,e.utilWebsocket)}(this,function(e,n,t){e.createLiveConnectionClient=function(e){try{return Promise.resolve({connect:function(n){var o=new t.IsomorphicWs(e.endpoint+"/"+n.tenantId+"/connection/"+n.connectionId+"/live");return o.on("open",function(){null==n.onOpen||n.onOpen()}),o.on("message",function(e){var t=JSON.parse(e);null==n.onMessage||n.onMessage({type:t.type,data:t.data})}),o.on("close",function(){null==n.onClose||n.onClose()}),{sendMcpMessage:function(e){try{return Promise.resolve(o.send(JSON.stringify({type:"mcp.message",data:e}))).then(function(){})}catch(e){return Promise.reject(e)}},close:function(){try{return o.close(),Promise.resolve()}catch(e){return Promise.reject(e)}}}}})}catch(e){return Promise.reject(e)}},e.createShuttleClient=function(e){return n.createClient(e)}});
|
|
2
|
+
//# sourceMappingURL=index.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/live.ts","../src/controller.ts"],"sourcesContent":["import { IsomorphicWs } from '@metorial/util-websocket';\nimport type { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';\nimport type { ConnectionMessage } from '../../../service/src/mcp/utils/messenger';\n\nexport let createLiveConnectionClient = async (opts: { endpoint: string }) => ({\n connect: (d: {\n tenantId: string;\n connectionId: string;\n onOpen?: () => void;\n onMessage?: (msg: ConnectionMessage) => void;\n onClose?: () => void;\n }) => {\n let ws = new IsomorphicWs(\n `${opts.endpoint}/${d.tenantId}/connection/${d.connectionId}/live`\n );\n\n ws.on('open', () => {\n d.onOpen?.();\n });\n\n ws.on('message', (data: string) => {\n let msg: any = JSON.parse(data);\n d.onMessage?.({\n type: msg.type,\n data: msg.data\n });\n });\n\n ws.on('close', () => {\n d.onClose?.();\n });\n\n return {\n sendMcpMessage: async (msg: JSONRPCMessage) => {\n await ws.send(\n JSON.stringify({\n type: 'mcp.message',\n data: msg\n })\n );\n },\n close: async () => {\n ws.close();\n }\n };\n }\n});\n","import { createClient } from '@lowerdeck/rpc-client';\nimport { ClientOpts } from '@lowerdeck/rpc-client/dist/shared/clientBuilder';\nimport type { ShuttleClient } from '../../../service/src/apis/controllers';\n\nexport let createShuttleClient = (o: ClientOpts) => createClient<ShuttleClient>(o);\n"],"names":["opts","Promise","resolve","connect","d","ws","IsomorphicWs","endpoint","tenantId","connectionId","on","onOpen","data","msg","JSON","parse","onMessage","type","onClose","sendMcpMessage","send","stringify","then","e","reject","close","o","createClient"],"mappings":"4ZAIqC,SAAUA,GAA0B,IAAA,OAAAC,QAAAC,QAAM,CAC7EC,QAAS,SAACC,GAOR,IAAIC,EAAK,IAAIC,eACRN,EAAKO,aAAYH,EAAEI,SAAQ,eAAeJ,EAAEK,aAAmB,SAmBpE,OAhBAJ,EAAGK,GAAG,OAAQ,WACJ,MAARN,EAAEO,QAAFP,EAAEO,QACJ,GAEAN,EAAGK,GAAG,UAAW,SAACE,GAChB,IAAIC,EAAWC,KAAKC,MAAMH,SAC1BR,EAAEY,WAAFZ,EAAEY,UAAY,CACZC,KAAMJ,EAAII,KACVL,KAAMC,EAAID,MAEd,GAEAP,EAAGK,GAAG,QAAS,WACJ,MAATN,EAAEc,SAAFd,EAAEc,SACJ,GAEO,CACLC,eAAc,SAASN,OAAuBZ,OAAAA,QAAAC,QACtCG,EAAGe,KACPN,KAAKO,UAAU,CACbJ,KAAM,cACNL,KAAMC,MAETS,KAAA,WAAA,EACH,CAAC,MAAAC,GAAAtB,OAAAA,QAAAuB,OAAAD,EAAA,CAAA,EACDE,MAAK,WAAA,IACQ,OAAXpB,EAAGoB,QAAQxB,QAAAC,SACb,CAAC,MAAAqB,GAAAtB,OAAAA,QAAAuB,OAAAD,KAEL,GACD,CAAA,MAAAA,GAAA,OAAAtB,QAAAuB,OAAAD,EAAC,CAAA,wBC1C+B,SAACG,GAAa,OAAKC,EAAAA,aAA4BD,EAAE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@metorial-services/shuttle-client",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"files": [
|
|
8
|
+
"src/**",
|
|
9
|
+
"dist/**",
|
|
10
|
+
"README.md",
|
|
11
|
+
"package.json"
|
|
12
|
+
],
|
|
13
|
+
"author": "Tobias Herber",
|
|
14
|
+
"license": "Apache 2",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"source": "src/index.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"require": "./dist/index.cjs",
|
|
20
|
+
"import": "./dist/index.module.js",
|
|
21
|
+
"default": "./dist/index.module.js"
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/index.cjs",
|
|
24
|
+
"module": "./dist/index.module.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"unpkg": "./dist/index.umd.js",
|
|
27
|
+
"scripts": {
|
|
28
|
+
"test": "vitest run --passWithNoTests",
|
|
29
|
+
"lint": "prettier src/**/*.ts --check",
|
|
30
|
+
"build": "rm -rf ./dist && microbundle && dts-bundle-generator --config dts-bundle-generator.config.json",
|
|
31
|
+
"prepublish": "bun run build"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@lowerdeck/rpc-client": "^1.0.2",
|
|
35
|
+
"@metorial/util-websocket": "^1.0.0",
|
|
36
|
+
"@types/bun": "^1.3.7"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^25.0.3",
|
|
40
|
+
"dts-bundle-generator": "^9.5.1",
|
|
41
|
+
"microbundle": "^0.15.1",
|
|
42
|
+
"typescript": "^5.8.3",
|
|
43
|
+
"vitest": "^3.1.2"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createClient } from '@lowerdeck/rpc-client';
|
|
2
|
+
import { ClientOpts } from '@lowerdeck/rpc-client/dist/shared/clientBuilder';
|
|
3
|
+
import type { ShuttleClient } from '../../../service/src/apis/controllers';
|
|
4
|
+
|
|
5
|
+
export let createShuttleClient = (o: ClientOpts) => createClient<ShuttleClient>(o);
|
package/src/index.ts
ADDED
package/src/live.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IsomorphicWs } from '@metorial/util-websocket';
|
|
2
|
+
import type { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { ConnectionMessage } from '../../../service/src/mcp/utils/messenger';
|
|
4
|
+
|
|
5
|
+
export let createLiveConnectionClient = async (opts: { endpoint: string }) => ({
|
|
6
|
+
connect: (d: {
|
|
7
|
+
tenantId: string;
|
|
8
|
+
connectionId: string;
|
|
9
|
+
onOpen?: () => void;
|
|
10
|
+
onMessage?: (msg: ConnectionMessage) => void;
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
}) => {
|
|
13
|
+
let ws = new IsomorphicWs(
|
|
14
|
+
`${opts.endpoint}/${d.tenantId}/connection/${d.connectionId}/live`
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
ws.on('open', () => {
|
|
18
|
+
d.onOpen?.();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
ws.on('message', (data: string) => {
|
|
22
|
+
let msg: any = JSON.parse(data);
|
|
23
|
+
d.onMessage?.({
|
|
24
|
+
type: msg.type,
|
|
25
|
+
data: msg.data
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
ws.on('close', () => {
|
|
30
|
+
d.onClose?.();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
sendMcpMessage: async (msg: JSONRPCMessage) => {
|
|
35
|
+
await ws.send(
|
|
36
|
+
JSON.stringify({
|
|
37
|
+
type: 'mcp.message',
|
|
38
|
+
data: msg
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
close: async () => {
|
|
43
|
+
ws.close();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
});
|