@webex/internal-plugin-llm 3.12.0-task-refactor.1 → 3.12.0-webex-services-ready.1
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 +83 -12
- package/dist/constants.js +9 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/llm.js +486 -51
- package/dist/llm.js.map +1 -1
- package/dist/llm.types.js +6 -0
- package/dist/llm.types.js.map +1 -1
- package/package.json +6 -6
- package/src/constants.ts +13 -0
- package/src/index.ts +3 -0
- package/src/llm.ts +502 -34
- package/src/llm.types.ts +66 -6
- package/test/unit/spec/llm.js +612 -52
package/README.md
CHANGED
|
@@ -23,22 +23,93 @@ npm install --save @webex/internal-plugin-llm
|
|
|
23
23
|
|
|
24
24
|
```js
|
|
25
25
|
import '@webex/internal-plugin-llm';
|
|
26
|
-
|
|
27
26
|
import WebexCore from '@webex/webex-core';
|
|
27
|
+
// Optional: import enum from package internals if needed in your app setup
|
|
28
|
+
// import {DataChannelTokenType} from '@webex/internal-plugin-llm/src/llm.types';
|
|
28
29
|
|
|
29
30
|
const webex = new WebexCore();
|
|
30
|
-
// locusUrl is got from meeting.locusInfo.url;
|
|
31
|
-
// datachannelUrl is got from meeting.locusInfo.info.datachannelUrl;
|
|
32
|
-
webex.internal.llm.registerAndConnect(locusUrl, datachannelUrl);
|
|
33
|
-
|
|
34
|
-
// Checks if LLM is connected
|
|
35
|
-
webex.internal.llm.isConnected();
|
|
36
|
-
|
|
37
|
-
// Disconnect LLM connection
|
|
38
|
-
webex.internal.llm.disconnectLLM();
|
|
39
31
|
|
|
40
|
-
//
|
|
41
|
-
|
|
32
|
+
// locusUrl and datachannelUrl are from meeting.locusInfo
|
|
33
|
+
const locusUrl = meeting.locusInfo.url;
|
|
34
|
+
const datachannelUrl = meeting.locusInfo.info.datachannelUrl;
|
|
35
|
+
|
|
36
|
+
// Optional JWT token for data channel auth
|
|
37
|
+
const datachannelToken = '<jwt-token>';
|
|
38
|
+
|
|
39
|
+
// Default session (no token)
|
|
40
|
+
await webex.internal.llm.registerAndConnect(locusUrl, datachannelUrl);
|
|
41
|
+
|
|
42
|
+
// Default session (with JWT token)
|
|
43
|
+
await webex.internal.llm.registerAndConnect(locusUrl, datachannelUrl, datachannelToken);
|
|
44
|
+
|
|
45
|
+
// Multiple named sessions
|
|
46
|
+
await webex.internal.llm.registerAndConnect(locusUrlA, datachannelUrlA, undefined, 'session-a');
|
|
47
|
+
await webex.internal.llm.registerAndConnect(
|
|
48
|
+
locusUrlB,
|
|
49
|
+
datachannelUrlB,
|
|
50
|
+
datachannelToken,
|
|
51
|
+
'session-b'
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
// Listen across multiple connections
|
|
55
|
+
const llm = webex.internal.llm;
|
|
56
|
+
const sessionA = 'session-a';
|
|
57
|
+
const sessionB = 'session-b';
|
|
58
|
+
|
|
59
|
+
// Default session events use the base event name.
|
|
60
|
+
llm.on('online', () => {
|
|
61
|
+
console.log('[default] connected');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
llm.on('event', (envelope) => {
|
|
65
|
+
console.log('[default] event', envelope.data?.eventType, envelope.sessionId);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Non-default sessions emit events with :<sessionId> suffix.
|
|
69
|
+
llm.on(`online:${sessionA}`, () => {
|
|
70
|
+
console.log(`[${sessionA}] connected`);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
llm.on(`event:${sessionA}`, (envelope) => {
|
|
74
|
+
console.log(`[${sessionA}] event`, envelope.data?.eventType, envelope.sessionId);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
llm.on(`event:${sessionB}`, (envelope) => {
|
|
78
|
+
console.log(`[${sessionB}] event`, envelope.data?.eventType, envelope.sessionId);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Optional: store/retrieve token by token type
|
|
82
|
+
webex.internal.llm.setDatachannelToken(datachannelToken, 'llm-default-session');
|
|
83
|
+
webex.internal.llm.getDatachannelToken('llm-default-session');
|
|
84
|
+
|
|
85
|
+
// Optional: inject token refresh handler
|
|
86
|
+
webex.internal.llm.setRefreshHandler(async () => {
|
|
87
|
+
// Return shape must match plugin expectation
|
|
88
|
+
return {
|
|
89
|
+
body: {
|
|
90
|
+
datachannelToken: '<refreshed-jwt-token>',
|
|
91
|
+
datachannelTokenType: 'llm-default-session',
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}, 'llm-default-session');
|
|
95
|
+
|
|
96
|
+
// Optional: manually trigger refresh (if needed by your flow)
|
|
97
|
+
await webex.internal.llm.refreshDataChannelToken();
|
|
98
|
+
|
|
99
|
+
// Per-session status and metadata
|
|
100
|
+
webex.internal.llm.isConnected('session-a');
|
|
101
|
+
webex.internal.llm.getBinding('session-a');
|
|
102
|
+
webex.internal.llm.getLocusUrl('session-a');
|
|
103
|
+
webex.internal.llm.getDatachannelUrl('session-a');
|
|
104
|
+
|
|
105
|
+
// All active sessions
|
|
106
|
+
webex.internal.llm.getAllConnections();
|
|
107
|
+
|
|
108
|
+
// Disconnect one session
|
|
109
|
+
await webex.internal.llm.disconnectLLM({code: 1000, reason: 'done'}, 'session-a', 'meeting-id');
|
|
110
|
+
|
|
111
|
+
// Disconnect all sessions
|
|
112
|
+
await webex.internal.llm.disconnectAllLLM({code: 1000, reason: 'shutdown'});
|
|
42
113
|
```
|
|
43
114
|
|
|
44
115
|
## Maintainers
|
package/dist/constants.js
CHANGED
|
@@ -4,7 +4,15 @@ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/defi
|
|
|
4
4
|
_Object$defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.LLM = void 0;
|
|
7
|
+
exports.SUBSCRIPTION_AWARE_SUBCHANNELS_PARAM = exports.LLM_PRACTICE_SESSION = exports.LLM_DEFAULT_SESSION = exports.LLM = exports.DATA_CHNANEL_TYPE = exports.DATA_CHANNEL_WITH_JWT_TOKEN = exports.AWARE_DATA_CHANNEL = void 0;
|
|
8
8
|
// eslint-disable-next-line import/prefer-default-export
|
|
9
9
|
var LLM = exports.LLM = 'llm';
|
|
10
|
+
var LLM_DEFAULT_SESSION = exports.LLM_DEFAULT_SESSION = 'llm-default-session';
|
|
11
|
+
var LLM_PRACTICE_SESSION = exports.LLM_PRACTICE_SESSION = 'llm-practice-session';
|
|
12
|
+
var DATA_CHANNEL_WITH_JWT_TOKEN = exports.DATA_CHANNEL_WITH_JWT_TOKEN = 'data-channel-with-jwt-token';
|
|
13
|
+
var SUBSCRIPTION_AWARE_SUBCHANNELS_PARAM = exports.SUBSCRIPTION_AWARE_SUBCHANNELS_PARAM = 'subscriptionAwareSubchannels';
|
|
14
|
+
var DATA_CHNANEL_TYPE = exports.DATA_CHNANEL_TYPE = {
|
|
15
|
+
TRANSCRIPTION: 'transcription'
|
|
16
|
+
};
|
|
17
|
+
var AWARE_DATA_CHANNEL = exports.AWARE_DATA_CHANNEL = [DATA_CHNANEL_TYPE.TRANSCRIPTION];
|
|
10
18
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LLM","exports"],"sources":["constants.ts"],"sourcesContent":["// eslint-disable-next-line import/prefer-default-export\nexport const LLM = 'llm';\n"],"mappings":";;;;;;;AAAA;AACO,IAAMA,GAAG,GAAAC,OAAA,CAAAD,GAAA,GAAG,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["LLM","exports","LLM_DEFAULT_SESSION","LLM_PRACTICE_SESSION","DATA_CHANNEL_WITH_JWT_TOKEN","SUBSCRIPTION_AWARE_SUBCHANNELS_PARAM","DATA_CHNANEL_TYPE","TRANSCRIPTION","AWARE_DATA_CHANNEL"],"sources":["constants.ts"],"sourcesContent":["// eslint-disable-next-line import/prefer-default-export\nexport const LLM = 'llm';\n\nexport const LLM_DEFAULT_SESSION = 'llm-default-session';\nexport const LLM_PRACTICE_SESSION = 'llm-practice-session';\n\nexport const DATA_CHANNEL_WITH_JWT_TOKEN = 'data-channel-with-jwt-token';\n\nexport const SUBSCRIPTION_AWARE_SUBCHANNELS_PARAM = 'subscriptionAwareSubchannels';\n\nexport const DATA_CHNANEL_TYPE = {\n TRANSCRIPTION: 'transcription',\n};\n\nexport const AWARE_DATA_CHANNEL = [DATA_CHNANEL_TYPE.TRANSCRIPTION];\n"],"mappings":";;;;;;;AAAA;AACO,IAAMA,GAAG,GAAAC,OAAA,CAAAD,GAAA,GAAG,KAAK;AAEjB,IAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,qBAAqB;AACjD,IAAMC,oBAAoB,GAAAF,OAAA,CAAAE,oBAAA,GAAG,sBAAsB;AAEnD,IAAMC,2BAA2B,GAAAH,OAAA,CAAAG,2BAAA,GAAG,6BAA6B;AAEjE,IAAMC,oCAAoC,GAAAJ,OAAA,CAAAI,oCAAA,GAAG,8BAA8B;AAE3E,IAAMC,iBAAiB,GAAAL,OAAA,CAAAK,iBAAA,GAAG;EAC/BC,aAAa,EAAE;AACjB,CAAC;AAEM,IAAMC,kBAAkB,GAAAP,OAAA,CAAAO,kBAAA,GAAG,CAACF,iBAAiB,CAACC,aAAa,CAAC","ignoreList":[]}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,24 @@ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/o
|
|
|
7
7
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
+
_Object$defineProperty(exports, "DataChannelTokenType", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _llm2.DataChannelTokenType;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
_Object$defineProperty(exports, "LLM_DEFAULT_SESSION", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function get() {
|
|
19
|
+
return _constants.LLM_DEFAULT_SESSION;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
_Object$defineProperty(exports, "LLM_PRACTICE_SESSION", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function get() {
|
|
25
|
+
return _constants.LLM_PRACTICE_SESSION;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
10
28
|
_Object$defineProperty(exports, "default", {
|
|
11
29
|
enumerable: true,
|
|
12
30
|
get: function get() {
|
|
@@ -15,6 +33,8 @@ _Object$defineProperty(exports, "default", {
|
|
|
15
33
|
});
|
|
16
34
|
var WebexCore = _interopRequireWildcard(require("@webex/webex-core"));
|
|
17
35
|
var _llm = _interopRequireWildcard(require("./llm"));
|
|
36
|
+
var _llm2 = require("./llm.types");
|
|
37
|
+
var _constants = require("./constants");
|
|
18
38
|
function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
19
39
|
WebexCore.registerInternalPlugin('llm', _llm.default, {
|
|
20
40
|
config: _llm.config
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebexCore","_interopRequireWildcard","require","_llm","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","_typeof","has","get","set","_t","hasOwnProperty","call","_Object$defineProperty","_Object$getOwnPropertyDescriptor","registerInternalPlugin","LLMChannel","config"],"sources":["index.ts"],"sourcesContent":["import * as WebexCore from '@webex/webex-core';\nimport LLMChannel, {config} from './llm';\n\nWebexCore.registerInternalPlugin('llm', LLMChannel, {\n config,\n});\n\nexport {default} from './llm';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["WebexCore","_interopRequireWildcard","require","_llm","_llm2","_constants","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","_typeof","has","get","set","_t","hasOwnProperty","call","_Object$defineProperty","_Object$getOwnPropertyDescriptor","registerInternalPlugin","LLMChannel","config"],"sources":["index.ts"],"sourcesContent":["import * as WebexCore from '@webex/webex-core';\nimport LLMChannel, {config} from './llm';\nimport {DataChannelTokenType} from './llm.types';\n\nWebexCore.registerInternalPlugin('llm', LLMChannel, {\n config,\n});\n\nexport {DataChannelTokenType};\nexport {LLM_DEFAULT_SESSION, LLM_PRACTICE_SESSION} from './constants';\nexport {default} from './llm';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAOA,IAAAG,UAAA,GAAAH,OAAA;AAAsE,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,QAAA,MAAAC,CAAA,OAAAD,QAAA,IAAAE,CAAA,OAAAF,QAAA,YAAAP,uBAAA,YAAAA,wBAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,gBAAAW,OAAA,CAAAX,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAM,GAAA,CAAAZ,CAAA,UAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,GAAAM,CAAA,CAAAQ,GAAA,CAAAd,CAAA,EAAAQ,CAAA,cAAAO,EAAA,IAAAf,CAAA,gBAAAe,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAe,EAAA,OAAAR,CAAA,IAAAD,CAAA,GAAAY,sBAAA,KAAAC,gCAAA,CAAAnB,CAAA,EAAAe,EAAA,OAAAR,CAAA,CAAAM,GAAA,IAAAN,CAAA,CAAAO,GAAA,IAAAR,CAAA,CAAAE,CAAA,EAAAO,EAAA,EAAAR,CAAA,IAAAC,CAAA,CAAAO,EAAA,IAAAf,CAAA,CAAAe,EAAA,WAAAP,CAAA,KAAAR,CAAA,EAAAC,CAAA;AALtEP,SAAS,CAAC0B,sBAAsB,CAAC,KAAK,EAAEC,YAAU,EAAE;EAClDC,MAAM,EAANA;AACF,CAAC,CAAC","ignoreList":[]}
|