@webex/internal-plugin-llm 3.12.0-webex-services-ready.4 → 3.13.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/.repo-context.json +416 -0
- package/.sdd/manifest.json +355 -0
- package/AGENTS.md +198 -0
- package/README.md +45 -65
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/dist/llm-plugin.js +199 -0
- package/dist/llm-plugin.js.map +1 -0
- package/dist/llm.js +193 -411
- package/dist/llm.js.map +1 -1
- package/dist/llm.types.js +8 -0
- package/dist/llm.types.js.map +1 -1
- package/docs/adr/0001-retain-product-readme.md +94 -0
- package/docs/adr/index.md +22 -0
- package/docs/architecture.md +279 -0
- package/docs/getting-started.md +104 -0
- package/docs/index.md +47 -0
- package/docs/specs/README.md +73 -0
- package/package.json +6 -6
- package/schemas/repo-context.schema.json +796 -0
- package/src/docs/README.md +522 -0
- package/src/index.ts +7 -2
- package/src/llm-plugin.ts +115 -0
- package/src/llm.ts +156 -443
- package/src/llm.types.ts +68 -50
- package/test/unit/spec/llm-plugin.js +391 -0
- package/test/unit/spec/llm.js +440 -567
package/dist/llm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_internalPluginMercury","_interopRequireDefault","require","_constants","_llm","_createForOfIteratorHelper","r","e","t","_Symbol","_Symbol$iterator","_Array$isArray","_unsupportedIterableToArray","length","_n","F","s","n","done","value","f","TypeError","o","a","u","call","next","return","_arrayLikeToArray","toString","slice","constructor","name","_Array$from","test","Array","_callSuper","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","_Reflect$construct","apply","Boolean","prototype","valueOf","config","exports","llm","pingInterval","process","env","MERCURY_PING_INTERVAL","pongTimeout","MERCURY_PONG_TIMEOUT","backoffTimeMax","MERCURY_BACKOFF_TIME_MAX","backoffTimeReset","MERCURY_BACKOFF_TIME_RESET","forceCloseDelay","MERCURY_FORCE_CLOSE_DELAY","LLMChannel","_ref","_this","_classCallCheck2","_len","arguments","args","_key","concat","_defineProperty3","LLM","LLM_DEFAULT_SESSION","_map","DataChannelTokenType","Default","undefined","PracticeSession","_ref2","_asyncToGenerator2","_regenerator","mark","_callee","llmSocketUrl","datachannelToken","sessionId","isDataChannelTokenEnabled","_args","wrap","_context","prev","sent","abrupt","request","method","url","body","deviceUrl","webex","internal","device","headers","then","res","sessionData","connections","get","webSocketUrl","binding","set","catch","error","logger","stop","_x","_x2","locusUrl","datachannelUrl","registerStart","performance","now","register","_callee2","clientLLMDatachannelResponseTime","connectUrl","connectStart","clientLLMWebSocketConnectTime","_t","_context2","Math","round","Error","timing","buildUrlWithAwareSubchannels","AWARE_DATA_CHANNEL","connect","socket","getSocket","connected","ownerMeetingId","currentOwner","getOwnerMeetingId","isOwner","tokenKey","resolvedTokenKey","_this$resolveSessionO","resolveSessionOwnership","info","datachannelTokens","_this$resolveSessionO2","_this$resolveSessionO3","options","resolvedSessionId","resolvedOwnerMeetingId","warn","_this$resolveSessionO4","_promise","resolve","disconnect","setOwnerMeetingId","delete","disconnectAll","clear","_inherits2","_createClass2","key","setRefreshHandler","handler","_this$resolveSessionO5","refreshHandler","_refreshDataChannelToken","_callee3","_this$connections$get","_args3","_t2","_context3","message","refreshDataChannelToken","getLocusUrlByDatachannelUrl","requestUrl","_iterator","_step","_step$value","_slicedToArray2","connection","matchesDatachannelRequestUrl","err","getSessionIdByDatachannelUrl","_iterator2","_step2","_step2$value","feature","getFeature","DATA_CHANNEL_WITH_JWT_TOKEN","registrationUrl","startsWith","URL","registration","pathname","Mercury","baseUrl","subchannels","urlObj","searchParams","SUBSCRIPTION_AWARE_SUBCHANNELS_PARAM","join"],"sources":["llm.ts"],"sourcesContent":["/* eslint-disable consistent-return */\n\nimport Mercury from '@webex/internal-plugin-mercury';\n\n// eslint-disable-next-line no-unused-vars\nimport {\n LLM,\n DATA_CHANNEL_WITH_JWT_TOKEN,\n AWARE_DATA_CHANNEL,\n SUBSCRIPTION_AWARE_SUBCHANNELS_PARAM,\n LLM_DEFAULT_SESSION,\n} from './constants';\nimport {ILLMChannel, DataChannelTokenType, RegisterAndConnectTiming} from './llm.types';\n\nexport const config = {\n llm: {\n /**\n * Milliseconds between pings sent up the socket\n * @type {number}\n */\n pingInterval: process.env.MERCURY_PING_INTERVAL || 15000,\n /**\n * Milliseconds to wait for a pong before declaring the connection dead\n * @type {number}\n */\n pongTimeout: process.env.MERCURY_PONG_TIMEOUT || 14000,\n /**\n * Maximum milliseconds between connection attempts\n * @type {Number}\n */\n backoffTimeMax: process.env.MERCURY_BACKOFF_TIME_MAX || 32000,\n /**\n * Initial milliseconds between connection attempts\n * @type {Number}\n */\n backoffTimeReset: process.env.MERCURY_BACKOFF_TIME_RESET || 1000,\n /**\n * Milliseconds to wait for a close frame before declaring the socket dead and\n * discarding it\n * @type {[type]}\n */\n forceCloseDelay: process.env.MERCURY_FORCE_CLOSE_DELAY || 2000,\n },\n};\n\n/**\n * LLMChannel to provide socket connections\n */\nexport default class LLMChannel extends (Mercury as any) implements ILLMChannel {\n namespace = LLM;\n defaultSessionId = LLM_DEFAULT_SESSION;\n /**\n * Map to store connection-specific data for multiple LLM connections\n * Key: sessionId\n * @private\n * @type {Map<string, {webSocketUrl?: string; binding?: string; locusUrl?: string; datachannelUrl?: string}>}\n */\n private connections: Map<\n string,\n {\n webSocketUrl?: string;\n binding?: string;\n locusUrl?: string;\n datachannelUrl?: string;\n ownerMeetingId?: string;\n refreshHandler?: () => Promise<{\n body: {datachannelToken: string; datachannelTokenType: DataChannelTokenType};\n }>;\n }\n > = new Map();\n\n // Session-keyed token cache is intentionally decoupled from connection state.\n // Disconnecting a socket session must not implicitly wipe token cache.\n private datachannelTokens: Record<string, string | undefined> = {\n [DataChannelTokenType.Default]: undefined,\n [DataChannelTokenType.PracticeSession]: undefined,\n };\n\n /**\n * Register to the websocket\n * @param {string} llmSocketUrl\n * @param {string} datachannelToken\n * @param {string} sessionId - Connection identifier\n * @returns {Promise<void>}\n */\n private register = async (\n llmSocketUrl: string,\n datachannelToken?: string,\n sessionId: string = LLM_DEFAULT_SESSION\n ): Promise<void> => {\n const isDataChannelTokenEnabled = await this.isDataChannelTokenEnabled();\n\n return this.request({\n method: 'POST',\n url: llmSocketUrl,\n body: {deviceUrl: this.webex.internal.device.url},\n headers:\n isDataChannelTokenEnabled && datachannelToken\n ? {'Data-Channel-Auth-Token': datachannelToken}\n : {},\n })\n .then((res: {body: {webSocketUrl: string; binding: string}}) => {\n // Get or create connection data\n const sessionData = this.connections.get(sessionId) || {};\n sessionData.webSocketUrl = res.body.webSocketUrl;\n sessionData.binding = res.body.binding;\n this.connections.set(sessionId, sessionData);\n })\n .catch((error: any) => {\n this.logger.error(`Error connecting to websocket for ${sessionId}: ${error}`);\n throw error;\n });\n };\n\n /**\n * Register and connect to the websocket\n * @param {string} locusUrl\n * @param {string} datachannelUrl\n * @param {string} datachannelToken\n * @param {string} sessionId - Connection identifier\n * @returns {Promise<void>}\n */\n public registerAndConnect = (\n locusUrl: string,\n datachannelUrl: string,\n datachannelToken?: string,\n sessionId: string = LLM_DEFAULT_SESSION\n ): Promise<RegisterAndConnectTiming | undefined> => {\n const registerStart = performance.now();\n\n // Pre-populate locusUrl and datachannelUrl before register() fires the\n // HTTP POST, so that any token refresh triggered during registration can\n // be routed via connections without falling back to a locusInfo URL scan.\n if (locusUrl && datachannelUrl) {\n const sessionData = this.connections.get(sessionId) || {};\n sessionData.locusUrl = locusUrl;\n sessionData.datachannelUrl = datachannelUrl;\n this.connections.set(sessionId, sessionData);\n }\n\n return this.register(datachannelUrl, datachannelToken, sessionId).then(async () => {\n if (!locusUrl || !datachannelUrl) return undefined;\n\n const clientLLMDatachannelResponseTime = Math.round(performance.now() - registerStart);\n\n // locusUrl and datachannelUrl were pre-populated before register(); here\n // we only need to read the existing session data to get webSocketUrl/binding\n // that register() filled in.\n const sessionData = this.connections.get(sessionId) || {};\n\n if (!sessionData.webSocketUrl) {\n // register() succeeded but the response carried no websocket URL. Attach the measured\n // datachannel time so callers don't misreport a registration that completed as time 0.\n const error: any = new Error(`LLM registration for ${sessionId} returned no websocket URL`);\n error.timing = {clientLLMDatachannelResponseTime};\n throw error;\n }\n\n const isDataChannelTokenEnabled = await this.isDataChannelTokenEnabled();\n\n const connectUrl = isDataChannelTokenEnabled\n ? LLMChannel.buildUrlWithAwareSubchannels(sessionData.webSocketUrl, AWARE_DATA_CHANNEL)\n : sessionData.webSocketUrl;\n\n const connectStart = performance.now();\n\n try {\n await this.connect(connectUrl, sessionId);\n } catch (error) {\n // register() succeeded; only connect() failed. Attach the measured datachannel time so\n // callers don't misreport a websocket failure as a registration that never completed.\n // @ts-ignore\n error.timing = {clientLLMDatachannelResponseTime};\n throw error;\n }\n\n const clientLLMWebSocketConnectTime = Math.round(performance.now() - connectStart);\n\n return {clientLLMDatachannelResponseTime, clientLLMWebSocketConnectTime};\n });\n };\n\n /**\n * Tells if LLM socket is connected\n * @param {string} sessionId - Connection identifier\n * @returns {boolean} connected\n */\n public isConnected = (sessionId = LLM_DEFAULT_SESSION): boolean => {\n const socket = this.getSocket(sessionId);\n\n return socket ? socket.connected : false;\n };\n\n /**\n * Tells if LLM socket is binding\n * @param {string} sessionId - Connection identifier\n * @returns {string} binding\n */\n public getBinding = (sessionId = LLM_DEFAULT_SESSION): string => {\n const sessionData = this.connections.get(sessionId);\n\n return sessionData?.binding;\n };\n\n /**\n * Get Locus URL for the connection\n * @param {string} sessionId - Connection identifier\n * @returns {string} locus Url\n */\n public getLocusUrl = (sessionId = LLM_DEFAULT_SESSION): string => {\n const sessionData = this.connections.get(sessionId);\n\n return sessionData?.locusUrl;\n };\n\n /**\n * Get data channel URL for the connection\n * @param {string} sessionId - Connection identifier\n * @returns {string} data channel Url\n */\n public getDatachannelUrl = (sessionId = LLM_DEFAULT_SESSION): string => {\n const sessionData = this.connections.get(sessionId);\n\n return sessionData?.datachannelUrl;\n };\n\n /**\n * Get WebSocket URL for the connection\n * @param {string} sessionId - Connection identifier\n * @returns {string | undefined} WebSocket URL\n */\n public getWebSocketUrl = (sessionId = LLM_DEFAULT_SESSION): string | undefined => {\n const sessionData = this.connections.get(sessionId);\n\n return sessionData?.webSocketUrl;\n };\n\n /**\n * Set the owner meeting ID for a given LLM session. Used by the meetings\n * plugin to tag which Meeting instance currently owns the (default) LLM\n * connection so that other Meeting instances can avoid disconnecting or\n * re-initializing a connection they do not own.\n *\n * Does NOT create a connections entry if one does not already exist — this\n * method is a no-op when there is no active session data. Callers should\n * invoke it after a successful `registerAndConnect` or during an explicit\n * ownership handoff.\n *\n * @param {string | undefined} ownerMeetingId - Meeting ID (or undefined to clear)\n * @param {string} sessionId - Connection identifier (defaults to default session)\n * @returns {void}\n */\n public setOwnerMeetingId = (\n ownerMeetingId: string | undefined,\n sessionId: string = LLM_DEFAULT_SESSION\n ): void => {\n const sessionData = this.connections.get(sessionId);\n\n if (!sessionData) {\n return;\n }\n\n sessionData.ownerMeetingId = ownerMeetingId;\n this.connections.set(sessionId, sessionData);\n };\n\n /**\n * Get the owner meeting ID currently associated with an LLM session.\n * Returns undefined when no owner has been assigned (e.g. before the\n * first successful `registerAndConnect`, or after `disconnectLLM`).\n *\n * @param {string} sessionId - Connection identifier (defaults to default session)\n * @returns {string | undefined} ownerMeetingId\n */\n public getOwnerMeetingId = (sessionId: string = LLM_DEFAULT_SESSION): string | undefined => {\n const sessionData = this.connections.get(sessionId);\n\n return sessionData?.ownerMeetingId;\n };\n\n /**\n * Resolve ownership information for an LLM session.\n *\n * Rules:\n * - no current owner => caller may proceed\n * - caller has no identity to assert => treat as owner\n * - otherwise caller must match current owner\n *\n * @param {string | undefined} ownerMeetingId - Candidate owner to evaluate\n * @param {string} sessionId - Connection identifier (defaults to default session)\n * @returns {{currentOwner: (string|undefined), isOwner: boolean}}\n */\n public resolveSessionOwnership = (\n ownerMeetingId?: string,\n sessionId: string = LLM_DEFAULT_SESSION\n ): {\n currentOwner: string | undefined;\n isOwner: boolean;\n } => {\n const currentOwner = this.getOwnerMeetingId(sessionId);\n const isOwner = !currentOwner || !ownerMeetingId || currentOwner === ownerMeetingId;\n\n return {\n currentOwner,\n isOwner,\n };\n };\n\n /**\n * Get data channel token for the connection\n * @param {DataChannelTokenType|string} tokenKey\n * @param {string | undefined} ownerMeetingId - Meeting id asserting read ownership\n * @returns {string | undefined} data channel token\n */\n public getDatachannelToken = (\n tokenKey?: DataChannelTokenType | string,\n ownerMeetingId?: string\n ): string | undefined => {\n const resolvedTokenKey = tokenKey ?? DataChannelTokenType.Default;\n\n const {currentOwner, isOwner} = this.resolveSessionOwnership(ownerMeetingId, resolvedTokenKey);\n\n if (!isOwner) {\n this.logger.info(\n `llm#getDatachannelToken --> skip read for session ${resolvedTokenKey}; owned by ${currentOwner}, candidate ${ownerMeetingId}`\n );\n\n return undefined;\n }\n\n return this.datachannelTokens[resolvedTokenKey];\n };\n\n /**\n * Set data channel token for the connection\n * @param {string} datachannelToken - data channel token\n * @param {DataChannelTokenType|string} [tokenKey]\n * @param {string | undefined} ownerMeetingId - Meeting id asserting write ownership\n * @returns {void}\n */\n public setDatachannelToken = (\n datachannelToken: string,\n tokenKey?: DataChannelTokenType | string,\n ownerMeetingId?: string\n ): void => {\n const resolvedTokenKey = tokenKey ?? DataChannelTokenType.Default;\n\n const {currentOwner, isOwner} = this.resolveSessionOwnership(ownerMeetingId, resolvedTokenKey);\n\n if (!isOwner) {\n this.logger.info(\n `llm#setDatachannelToken --> skip write for session ${resolvedTokenKey}; owned by ${currentOwner}, candidate ${ownerMeetingId}`\n );\n\n return;\n }\n\n this.datachannelTokens[resolvedTokenKey] = datachannelToken;\n };\n\n /**\n * Clears a single session's data channel token.\n * @param {DataChannelTokenType|string} tokenKey\n * @param {string} ownerMeetingId - Meeting id asserting delete ownership\n * @returns {void}\n */\n public clearDatachannelToken = (\n tokenKey: DataChannelTokenType | string,\n ownerMeetingId: string\n ): void => {\n const resolvedTokenKey = tokenKey;\n\n const {currentOwner, isOwner} = this.resolveSessionOwnership(ownerMeetingId, resolvedTokenKey);\n\n if (!isOwner) {\n this.logger.info(\n `llm#clearDatachannelToken --> skip clear for session ${resolvedTokenKey}; owned by ${currentOwner}, candidate ${ownerMeetingId}`\n );\n\n return;\n }\n\n this.datachannelTokens[resolvedTokenKey] = undefined;\n delete this.datachannelTokens[resolvedTokenKey];\n };\n\n /**\n * Set the handler used to refresh the DataChannel token\n *\n * @param {function} handler - Function that returns a refreshed token\n * @param {string} [sessionId] - Connection identifier\n * @param {string | undefined} ownerMeetingId - Meeting id asserting refresh-handler ownership\n * @returns {void}\n */\n public setRefreshHandler(\n handler: () => Promise<{\n body: {datachannelToken: string; datachannelTokenType: DataChannelTokenType};\n }>,\n sessionId?: string,\n ownerMeetingId?: string\n ) {\n const resolvedSessionId = sessionId ?? LLM_DEFAULT_SESSION;\n\n const {currentOwner, isOwner} = this.resolveSessionOwnership(ownerMeetingId, resolvedSessionId);\n\n if (!isOwner) {\n this.logger.info(\n `llm#setRefreshHandler --> skip write for session ${resolvedSessionId}; owned by ${currentOwner}, candidate ${ownerMeetingId}`\n );\n\n return;\n }\n\n const sessionData = this.connections.get(resolvedSessionId);\n\n if (sessionData) {\n sessionData.refreshHandler = handler;\n if (ownerMeetingId) {\n sessionData.ownerMeetingId = ownerMeetingId;\n }\n\n return;\n }\n\n // Intentionally allow a pre-connection session shape here.\n // Some flows inject refreshHandler before register/connect so token refresh\n // is already wired when the socket lifecycle starts. register()/\n // registerAndConnect() will later fill webSocketUrl/binding/locusUrl/\n // datachannelUrl into this same session entry.\n this.connections.set(resolvedSessionId, {\n refreshHandler: handler,\n ownerMeetingId,\n });\n }\n\n /**\n * Refresh the data channel token using the injected handler.\n * Logs a descriptive error if the handler is missing or fails.\n * @param {string} sessionId - Connection identifier (defaults to default session)\n * @returns {Promise<string>} The refreshed token.\n */\n public async refreshDataChannelToken(sessionId: string = LLM_DEFAULT_SESSION) {\n const refreshHandler = this.connections.get(sessionId)?.refreshHandler;\n\n if (!refreshHandler) {\n this.logger.warn(\n `llm#refreshDataChannelToken --> LLM refreshHandler is not set for session ${sessionId}, skipping token refresh`\n );\n\n return null;\n }\n\n try {\n const res = await refreshHandler();\n\n return res;\n } catch (error: any) {\n this.logger.warn(\n `llm#refreshDataChannelToken --> DataChannel token refresh failed (likely locus changed or participant left): ${\n error?.message || error\n }`\n );\n\n return null;\n }\n }\n\n /**\n * Disconnects websocket connection\n * @param {{code: number, reason: string}} options - The disconnect option object with code and reason\n * @param {string} sessionId - Connection identifier\n * @param {string} ownerMeetingId - Meeting id asserting disconnect ownership\n * @returns {Promise<boolean>} True when disconnect was performed, false when skipped\n */\n public disconnectLLM = (\n options: {code: number; reason: string},\n sessionId?: string,\n ownerMeetingId?: string\n ): Promise<boolean> => {\n const resolvedSessionId = sessionId ?? LLM_DEFAULT_SESSION;\n\n // Backward-compat path: historically callers could omit ownerMeetingId\n // (and sometimes sessionId). Reuse current owner when available so legacy\n // calls remain best-effort without throwing at teardown time.\n const resolvedOwnerMeetingId = ownerMeetingId || this.getOwnerMeetingId(resolvedSessionId);\n\n if (!ownerMeetingId) {\n this.logger.warn(\n `llm#disconnectLLM --> ownerMeetingId is omitted for session ${resolvedSessionId}; using legacy compatibility path`\n );\n }\n\n const {currentOwner, isOwner} = this.resolveSessionOwnership(\n resolvedOwnerMeetingId,\n resolvedSessionId\n );\n\n if (!isOwner) {\n this.logger.info(\n `llm#disconnectLLM --> skip disconnect for session ${resolvedSessionId}; owned by ${currentOwner}, candidate ${resolvedOwnerMeetingId}`\n );\n\n return Promise.resolve(false);\n }\n\n return this.disconnect(options, resolvedSessionId).then(() => {\n // Clear owner tag before cleanup to ensure it's not lingering\n // if another meeting claimed it during disconnect\n this.setOwnerMeetingId(undefined, resolvedSessionId);\n\n // Clean up sessions data\n this.connections.delete(resolvedSessionId);\n\n return true;\n });\n };\n\n /**\n * Disconnects all LLM websocket connections\n * @param {{code: number, reason: string}} options - The disconnect option object with code and reason\n * @returns {Promise<void>}\n */\n public disconnectAllLLM = (options?: {code: number; reason: string}): Promise<void> =>\n this.disconnectAll(options).then(() => {\n // Clean up all connection data\n this.connections.clear();\n });\n\n /**\n * Get all active LLM connections\n * @returns {Map} Map of sessionId to session data\n */\n public getAllConnections = (): Map<\n string,\n {\n webSocketUrl?: string;\n binding?: string;\n locusUrl?: string;\n datachannelUrl?: string;\n ownerMeetingId?: string;\n }\n > => new Map(this.connections);\n\n /**\n * Look up the locusUrl associated with a datachannel request URL.\n * Iterates all active LLM sessions and returns the locusUrl of the\n * session whose stored datachannelUrl is a prefix of the given request URL.\n *\n * @param {string} requestUrl - The in-flight request URL to match\n * @returns {string | undefined} The matching locusUrl, or undefined if not found\n */\n public getLocusUrlByDatachannelUrl(requestUrl: string): string | undefined {\n for (const [, connection] of this.connections) {\n if (\n connection.datachannelUrl &&\n LLMChannel.matchesDatachannelRequestUrl(requestUrl, connection.datachannelUrl)\n ) {\n return connection.locusUrl;\n }\n }\n\n return undefined;\n }\n\n /**\n * Look up the sessionId associated with a datachannel request URL.\n * Iterates all active LLM sessions and returns the sessionId whose\n * stored datachannelUrl is a prefix of the given request URL.\n *\n * @param {string} requestUrl - The in-flight request URL to match\n * @returns {string | undefined} The matching sessionId, or undefined if not found\n */\n public getSessionIdByDatachannelUrl(requestUrl: string): string | undefined {\n for (const [sessionId, connection] of this.connections) {\n if (\n connection.datachannelUrl &&\n LLMChannel.matchesDatachannelRequestUrl(requestUrl, connection.datachannelUrl)\n ) {\n return sessionId;\n }\n }\n\n return undefined;\n }\n\n /**\n * Matches a request URL to a stored datachannel registration URL.\n * Host can differ (e.g. rewritten by hostmap interceptor), so we first\n * try full URL prefix and then fall back to pathname prefix.\n * @param {string} requestUrl\n * @param {string} registrationUrl\n * @returns {boolean}\n */\n public static matchesDatachannelRequestUrl(requestUrl: string, registrationUrl: string): boolean {\n if (!requestUrl || !registrationUrl) {\n return false;\n }\n\n if (requestUrl.startsWith(registrationUrl)) {\n return true;\n }\n\n try {\n const request = new URL(requestUrl);\n const registration = new URL(registrationUrl);\n\n return request.pathname.startsWith(registration.pathname);\n } catch (error) {\n return false;\n }\n }\n\n /**\n * Returns true if data channel token is enabled, false otherwise\n * @returns {Promise<boolean>} resolves with true if data channel token is enabled\n */\n public isDataChannelTokenEnabled(): Promise<boolean> {\n // @ts-ignore\n return this.webex.internal.feature.getFeature('developer', DATA_CHANNEL_WITH_JWT_TOKEN);\n }\n\n /**\n * Builds a WebSocket URL with the `subscriptionAwareSubchannels` query parameter.\n *\n * @param {string} baseUrl - The original WebSocket URL.\n * @param {string[]} subchannels - List of subchannels to declare as subscription-aware.\n * @returns {string} The final URL with updated query parameters.\n */\n\n public static buildUrlWithAwareSubchannels = (baseUrl: string, subchannels: string[]) => {\n const urlObj = new URL(baseUrl);\n urlObj.searchParams.set(SUBSCRIPTION_AWARE_SUBCHANNELS_PARAM, subchannels.join(','));\n\n return urlObj.toString();\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAD,OAAA;AAOA,IAAAE,IAAA,GAAAF,OAAA;AAAwF,SAAAG,2BAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,yBAAAC,OAAA,IAAAH,CAAA,CAAAI,gBAAA,KAAAJ,CAAA,qBAAAE,CAAA,QAAAG,cAAA,CAAAL,CAAA,MAAAE,CAAA,GAAAI,2BAAA,CAAAN,CAAA,MAAAC,CAAA,IAAAD,CAAA,uBAAAA,CAAA,CAAAO,MAAA,IAAAL,CAAA,KAAAF,CAAA,GAAAE,CAAA,OAAAM,EAAA,MAAAC,CAAA,YAAAA,EAAA,eAAAC,CAAA,EAAAD,CAAA,EAAAE,CAAA,WAAAA,EAAA,WAAAH,EAAA,IAAAR,CAAA,CAAAO,MAAA,KAAAK,IAAA,WAAAA,IAAA,MAAAC,KAAA,EAAAb,CAAA,CAAAQ,EAAA,UAAAP,CAAA,WAAAA,EAAAD,CAAA,UAAAA,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B,CAAC;IACzF;;IAEA;AACF;AACA;AACA;AACA;AACA;AACA;EANE;IAAA5B,GAAA;IAAAlJ,KAAA,EA5BA,SAAcsK,4BAA4BA,CAACN,UAAkB,EAAEe,eAAuB,EAAW;MAC/F,IAAI,CAACf,UAAU,IAAI,CAACe,eAAe,EAAE;QACnC,OAAO,KAAK;MACd;MAEA,IAAIf,UAAU,CAACgB,UAAU,CAACD,eAAe,CAAC,EAAE;QAC1C,OAAO,IAAI;MACb;MAEA,IAAI;QACF,IAAMrG,OAAO,GAAG,IAAIuG,GAAG,CAACjB,UAAU,CAAC;QACnC,IAAMkB,YAAY,GAAG,IAAID,GAAG,CAACF,eAAe,CAAC;QAE7C,OAAOrG,OAAO,CAACyG,QAAQ,CAACH,UAAU,CAACE,YAAY,CAACC,QAAQ,CAAC;MAC3D,CAAC,CAAC,OAAOvF,KAAK,EAAE;QACd,OAAO,KAAK;MACd;IACF;EAAC;AAAA,EAljBsCwF,8BAAO;AAAA,IAAAjI,gBAAA,CAAAhC,OAAA,EAA3BuB,UAAU,kCAqkBgB,UAAC2I,OAAe,EAAEC,WAAqB,EAAK;EACvF,IAAMC,MAAM,GAAG,IAAIN,GAAG,CAACI,OAAO,CAAC;EAC/BE,MAAM,CAACC,YAAY,CAAC9F,GAAG,CAAC+F,+CAAoC,EAAEH,WAAW,CAACI,IAAI,CAAC,GAAG,CAAC,CAAC;EAEpF,OAAOH,MAAM,CAAC7K,QAAQ,CAAC,CAAC;AAC1B,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_internalPluginMercury","_interopRequireDefault","require","_constants","_callSuper","t","o","e","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","_Reflect$construct","constructor","apply","Boolean","prototype","valueOf","call","_superPropGet","r","p","_get2","config","exports","llm","pingInterval","process","env","MERCURY_PING_INTERVAL","pongTimeout","MERCURY_PONG_TIMEOUT","backoffTimeMax","MERCURY_BACKOFF_TIME_MAX","backoffTimeReset","MERCURY_BACKOFF_TIME_RESET","forceCloseDelay","MERCURY_FORCE_CLOSE_DELAY","LLMChannel","_ref","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","concat","_defineProperty2","LLM","_ref2","_asyncToGenerator2","_regenerator","mark","_callee","llmSocketUrl","datachannelToken","isDataChannelTokenEnabled","wrap","_context","prev","next","sent","abrupt","request","method","url","body","deviceUrl","webex","internal","device","headers","then","res","catch","error","logger","stop","_x","_x2","locusUrl","datachannelUrl","connectingPromise","isConnected","_promise","resolve","registerStart","performance","now","connectionPromise","register","_ref4","_callee2","_ref3","webSocketUrl","binding","clientLLMDatachannelResponseTime","connectUrl","connectStart","clientLLMWebSocketConnectTime","_t","_context2","Math","round","buildUrlWithAwareSubchannels","AWARE_DATA_CHANNEL","connect","timing","_x3","finally","undefined","connected","token","handler","refreshHandler","_inherits2","_createClass2","key","value","isConnecting","_refreshDataChannelToken","_callee3","_t2","_context3","warn","message","refreshDataChannelToken","_disconnect","_callee4","options","_context4","disconnect","_x4","feature","getFeature","DATA_CHANNEL_WITH_JWT_TOKEN","matchesDatachannelRequestUrl","requestUrl","registrationUrl","startsWith","URL","registration","pathname","Mercury","baseUrl","subchannels","urlObj","searchParams","set","SUBSCRIPTION_AWARE_SUBCHANNELS_PARAM","join","toString"],"sources":["llm.ts"],"sourcesContent":["/* eslint-disable consistent-return */\nimport Mercury from '@webex/internal-plugin-mercury';\n\nimport {\n LLM,\n DATA_CHANNEL_WITH_JWT_TOKEN,\n AWARE_DATA_CHANNEL,\n SUBSCRIPTION_AWARE_SUBCHANNELS_PARAM,\n} from './constants';\nimport {ILLMChannel, DataChannelTokenType, RegisterAndConnectTiming} from './llm.types';\n\nexport const config = {\n llm: {\n /**\n * Milliseconds between pings sent up the socket\n * @type {number}\n */\n pingInterval: process.env.MERCURY_PING_INTERVAL || 15000,\n /**\n * Milliseconds to wait for a pong before declaring the connection dead\n * @type {number}\n */\n pongTimeout: process.env.MERCURY_PONG_TIMEOUT || 14000,\n /**\n * Maximum milliseconds between connection attempts\n * @type {Number}\n */\n backoffTimeMax: process.env.MERCURY_BACKOFF_TIME_MAX || 32000,\n /**\n * Initial milliseconds between connection attempts\n * @type {Number}\n */\n backoffTimeReset: process.env.MERCURY_BACKOFF_TIME_RESET || 1000,\n /**\n * Milliseconds to wait for a close frame before declaring the socket dead and\n * discarding it\n * @type {[type]}\n */\n forceCloseDelay: process.env.MERCURY_FORCE_CLOSE_DELAY || 2000,\n },\n};\n\n/**\n * LLMChannel — a single WebSocket connection to the LLM data channel.\n *\n * Created via `webex.internal.llm.createChannel()`. The caller owns the\n * channel and is responsible for its lifecycle (connect, disconnect, cleanup).\n * Multiple LLMChannels can exist simultaneously for different meetings.\n */\nexport default class LLMChannel extends (Mercury as any) implements ILLMChannel {\n namespace = LLM;\n\n private webSocketUrl?: string;\n private binding?: string;\n private locusUrl?: string;\n private datachannelUrl?: string;\n private datachannelToken?: string;\n private refreshHandler?: () => Promise<{\n body: {datachannelToken: string; datachannelTokenType: DataChannelTokenType};\n }>;\n\n /** In-flight connection promise for deduplication. */\n private connectingPromise?: Promise<RegisterAndConnectTiming | void>;\n\n /**\n * Check if a connection is currently in progress.\n * @returns {boolean} True if connecting\n */\n public isConnecting(): boolean {\n return !!this.connectingPromise;\n }\n\n /**\n * Register to the websocket\n * @param {string} llmSocketUrl\n * @param {string} datachannelToken\n * @returns {Promise<object>} Promise resolving to {webSocketUrl, binding}\n */\n private register = async (\n llmSocketUrl: string,\n datachannelToken?: string\n ): Promise<{webSocketUrl: string; binding: string}> => {\n const isDataChannelTokenEnabled = await this.isDataChannelTokenEnabled();\n\n return this.request({\n method: 'POST',\n url: llmSocketUrl,\n body: {deviceUrl: this.webex.internal.device.url},\n headers:\n isDataChannelTokenEnabled && datachannelToken\n ? {'Data-Channel-Auth-Token': datachannelToken}\n : {},\n })\n .then((res: {body: {webSocketUrl: string; binding: string}}) => res.body)\n .catch((error: any) => {\n this.logger.error(`Error connecting to websocket for : ${error}`);\n throw error;\n });\n };\n\n /**\n * Register and connect to the websocket.\n * Handles deduplication: returns existing promise if connection in progress,\n * or resolves immediately if already connected to the same URLs.\n * @param {string} locusUrl\n * @param {string} datachannelUrl\n * @param {string} datachannelToken\n * @returns {Promise<RegisterAndConnectTiming | void>}\n */\n public registerAndConnect = (\n locusUrl: string,\n datachannelUrl: string,\n datachannelToken?: string\n ): Promise<RegisterAndConnectTiming | void> => {\n // Deduplicate concurrent calls while a connection is in-flight\n if (this.connectingPromise) {\n return this.connectingPromise;\n }\n\n // If already connected to the exact same datachannel URL, avoid triggering\n // a reconnect that would cause the server to replace with 4000 Replaced\n if (\n this.isConnected() &&\n this.datachannelUrl === datachannelUrl &&\n this.locusUrl === locusUrl\n ) {\n return Promise.resolve();\n }\n\n this.locusUrl = locusUrl;\n this.datachannelUrl = datachannelUrl;\n const registerStart = performance.now();\n\n const connectionPromise: Promise<RegisterAndConnectTiming | void> = this.register(\n datachannelUrl,\n datachannelToken\n )\n .then(async ({webSocketUrl, binding}) => {\n // Check if this operation was invalidated by a disconnect\n if (this.connectingPromise !== connectionPromise) {\n return;\n }\n\n this.webSocketUrl = webSocketUrl;\n this.binding = binding;\n\n const clientLLMDatachannelResponseTime = Math.round(performance.now() - registerStart);\n const isDataChannelTokenEnabled = await this.isDataChannelTokenEnabled();\n\n // Check again after async operation - disconnect may have run during the await\n if (this.connectingPromise !== connectionPromise) {\n return;\n }\n\n const connectUrl =\n isDataChannelTokenEnabled && this.webSocketUrl\n ? LLMChannel.buildUrlWithAwareSubchannels(this.webSocketUrl, AWARE_DATA_CHANNEL)\n : this.webSocketUrl;\n\n const connectStart = performance.now();\n\n try {\n await this.connect(connectUrl);\n } catch (error) {\n // register() succeeded; only connect() failed. Attach the measured datachannel time so\n // callers don't misreport a websocket failure as a registration that never completed.\n // @ts-ignore\n error.timing = {clientLLMDatachannelResponseTime};\n throw error;\n }\n\n const clientLLMWebSocketConnectTime = Math.round(performance.now() - connectStart);\n\n return {clientLLMDatachannelResponseTime, clientLLMWebSocketConnectTime};\n })\n .finally(() => {\n // Only clear if this operation is still current\n if (this.connectingPromise === connectionPromise) {\n this.connectingPromise = undefined;\n }\n });\n\n this.connectingPromise = connectionPromise;\n\n return this.connectingPromise;\n };\n\n /**\n * Tells if LLM socket is connected\n * @returns {boolean} connected\n */\n public isConnected = (): boolean => this.connected;\n\n /**\n * Tells if LLM socket is binding\n * @returns {string | undefined} binding\n */\n public getBinding = (): string | undefined => this.binding;\n\n /**\n * Get Locus URL for the connection\n * @returns {string | undefined} locus Url\n */\n public getLocusUrl = (): string | undefined => this.locusUrl;\n\n /**\n * Get data channel URL for the connection\n * @returns {string | undefined} data channel Url\n */\n public getDatachannelUrl = (): string | undefined => this.datachannelUrl;\n\n /**\n * Get data channel token for this connection.\n * @returns {string | undefined}\n */\n public getDatachannelToken = (): string | undefined => this.datachannelToken;\n\n /**\n * Store the data channel token for this connection.\n * @param {string} token\n * @returns {void}\n */\n public setDatachannelToken = (token: string): void => {\n this.datachannelToken = token;\n };\n\n /**\n * Clear the data channel token for this connection.\n * @returns {void}\n */\n public clearDatachannelToken = (): void => {\n this.datachannelToken = undefined;\n };\n\n /**\n * Set the handler used to refresh the DataChannel token.\n * @param {function} handler\n * @returns {void}\n */\n public setRefreshHandler = (\n handler: () => Promise<{\n body: {datachannelToken: string; datachannelTokenType: DataChannelTokenType};\n }>\n ): void => {\n this.refreshHandler = handler;\n };\n\n /**\n * Refresh the data channel token using the injected handler.\n * @returns {Promise<object | null>}\n */\n public async refreshDataChannelToken() {\n if (!this.refreshHandler) {\n this.logger.warn(\n 'llm#refreshDataChannelToken --> LLM refreshHandler is not set, skipping token refresh'\n );\n\n return null;\n }\n\n try {\n return await this.refreshHandler();\n } catch (error: any) {\n this.logger.warn(\n `llm#refreshDataChannelToken --> DataChannel token refresh failed: ${\n error?.message || error\n }`\n );\n\n return null;\n }\n }\n\n /**\n * Disconnects the WebSocket and clears all connection state.\n * Overrides Mercury's disconnect to also clear LLM-specific state.\n * Clears connectingPromise first to invalidate any in-flight operations,\n * then clears state before calling super.disconnect(). This ensures:\n * 1. Stale register() responses won't overwrite state (they check promise identity)\n * 2. No deadlock with Mercury's _connectWithBackoff() (we don't await connectingPromise)\n * 3. State is cleared before 'disconnected' event fires\n * @param {object} [options]\n * @returns {Promise<void>}\n */\n public async disconnect(options?: {code: number; reason: string}): Promise<void> {\n // Clear connectingPromise first to invalidate any in-flight operations.\n // Their promise identity checks will detect they've been superseded.\n this.connectingPromise = undefined;\n\n // Clear LLM-specific state before Mercury emits 'disconnected'\n this.webSocketUrl = undefined;\n this.binding = undefined;\n this.locusUrl = undefined;\n this.datachannelUrl = undefined;\n this.datachannelToken = undefined;\n this.refreshHandler = undefined;\n\n await super.disconnect(options);\n }\n\n /**\n * Matches a request URL to a stored datachannel registration URL.\n * Host can differ (e.g. rewritten by hostmap interceptor), so we first\n * try full URL prefix and then fall back to pathname prefix.\n * @param {string} requestUrl\n * @param {string} registrationUrl\n * @returns {boolean}\n */\n public static matchesDatachannelRequestUrl(requestUrl: string, registrationUrl: string): boolean {\n if (!requestUrl || !registrationUrl) {\n return false;\n }\n\n if (requestUrl.startsWith(registrationUrl)) {\n return true;\n }\n\n try {\n const request = new URL(requestUrl);\n const registration = new URL(registrationUrl);\n\n return request.pathname.startsWith(registration.pathname);\n } catch (error) {\n return false;\n }\n }\n\n /**\n * Returns true if the data channel token feature flag is enabled.\n * @returns {Promise<boolean>}\n */\n public isDataChannelTokenEnabled(): Promise<boolean> {\n // @ts-ignore\n return this.webex.internal.feature.getFeature('developer', DATA_CHANNEL_WITH_JWT_TOKEN);\n }\n\n /**\n * Builds a WebSocket URL with the `subscriptionAwareSubchannels` query parameter.\n * @param {string} baseUrl\n * @param {string[]} subchannels\n * @returns {string}\n */\n public static buildUrlWithAwareSubchannels = (baseUrl: string, subchannels: string[]) => {\n const urlObj = new URL(baseUrl);\n urlObj.searchParams.set(SUBSCRIPTION_AWARE_SUBCHANNELS_PARAM, subchannels.join(','));\n\n return urlObj.to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}
|
package/dist/llm.types.js
CHANGED
|
@@ -13,5 +13,13 @@ var DataChannelTokenType = exports.DataChannelTokenType = /*#__PURE__*/function
|
|
|
13
13
|
/**
|
|
14
14
|
* Latencies (in milliseconds) captured during register + websocket connect.
|
|
15
15
|
*/
|
|
16
|
+
/**
|
|
17
|
+
* ILLMChannel — interface for a single LLM WebSocket connection.
|
|
18
|
+
* Created via `webex.internal.llm.createChannel()`.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* ILLMPlugin — interface for the LLM plugin factory.
|
|
22
|
+
* Accessed via `webex.internal.llm`.
|
|
23
|
+
*/
|
|
16
24
|
// eslint-disable-next-line import/prefer-default-export
|
|
17
25
|
//# sourceMappingURL=llm.types.js.map
|
package/dist/llm.types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DataChannelTokenType","exports"],"sources":["llm.types.ts"],"sourcesContent":["export enum DataChannelTokenType {\n Default = 'llm-default-session',\n PracticeSession = 'llm-practice-session',\n}\n\ntype DataChannelTokenKey = DataChannelTokenType | string;\n\n/**\n * Latencies (in milliseconds) captured during register + websocket connect.\n */\ntype RegisterAndConnectTiming = {\n clientLLMDatachannelResponseTime?: number;\n clientLLMWebSocketConnectTime?: number;\n};\n\ninterface ILLMChannel {\n registerAndConnect: (\n locusUrl: string,\n datachannelUrl: string,\n datachannelToken?: string
|
|
1
|
+
{"version":3,"names":["DataChannelTokenType","exports"],"sources":["llm.types.ts"],"sourcesContent":["export enum DataChannelTokenType {\n Default = 'llm-default-session',\n PracticeSession = 'llm-practice-session',\n}\n\ntype DataChannelTokenKey = DataChannelTokenType | string;\n\n/**\n * Latencies (in milliseconds) captured during register + websocket connect.\n */\ntype RegisterAndConnectTiming = {\n clientLLMDatachannelResponseTime?: number;\n clientLLMWebSocketConnectTime?: number;\n};\n\n/**\n * ILLMChannel — interface for a single LLM WebSocket connection.\n * Created via `webex.internal.llm.createChannel()`.\n */\ninterface ILLMChannel {\n /** Register with the server and connect the WebSocket. */\n registerAndConnect: (\n locusUrl: string,\n datachannelUrl: string,\n datachannelToken?: string\n ) => Promise<void>;\n\n /** Returns true if the WebSocket is connected. */\n isConnected: () => boolean;\n\n /** Returns true if a connection is currently in progress. */\n isConnecting: () => boolean;\n\n /** Get the underlying WebSocket. */\n getSocket: () => any;\n\n /** Get the binding ID for this connection. */\n getBinding: () => string | undefined;\n\n /** Get the Locus URL associated with this connection. */\n getLocusUrl: () => string | undefined;\n\n /** Get the datachannel URL for this connection. */\n getDatachannelUrl: () => string | undefined;\n\n /** Get the stored datachannel token. */\n getDatachannelToken: () => string | undefined;\n\n /** Store a datachannel token for this connection. */\n setDatachannelToken: (datachannelToken: string) => void;\n\n /** Clear the stored datachannel token. */\n clearDatachannelToken: () => void;\n\n /** Set the handler used to refresh the datachannel token. */\n setRefreshHandler: (\n handler: () => Promise<{\n body: {datachannelToken: string; datachannelTokenType: DataChannelTokenType};\n }>\n ) => void;\n\n /** Refresh the datachannel token using the injected handler. */\n refreshDataChannelToken: () => Promise<{\n body: {datachannelToken: string; datachannelTokenType: DataChannelTokenType};\n } | null>;\n\n /** Disconnect the WebSocket and clean up state. */\n disconnect: (options?: {code: number; reason: string}) => Promise<void>;\n\n /** Check if the datachannel token feature flag is enabled. */\n isDataChannelTokenEnabled: () => Promise<boolean>;\n}\n\n/**\n * ILLMPlugin — interface for the LLM plugin factory.\n * Accessed via `webex.internal.llm`.\n */\ninterface ILLMPlugin {\n /** Create a new LLM channel instance. */\n createChannel: () => ILLMChannel;\n\n /** Check if the datachannel token feature flag is enabled globally. */\n isDataChannelTokenEnabled: () => Promise<boolean>;\n\n /** Find a channel by matching a request URL to its datachannel URL. */\n getChannelByDatachannelUrl: (url: string) => ILLMChannel | undefined;\n\n /** Get all active channels. */\n getAllChannels: () => Set<ILLMChannel>;\n\n /** Disconnect all active channels. */\n disconnectAllChannels: (options?: {code: number; reason: string}) => Promise<void>;\n}\n\n// eslint-disable-next-line import/prefer-default-export\nexport type {ILLMChannel, ILLMPlugin, DataChannelTokenKey, RegisterAndConnectTiming};\n"],"mappings":";;;;;;;IAAYA,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;AAOhC;AACA;AACA;AAMA;AACA;AACA;AACA;AAuDA;AACA;AACA;AACA;AAkBA","ignoreList":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: ADR
|
|
3
|
+
title: ADR-0001 - Retain the product README
|
|
4
|
+
description: Stage 0 keeps README.md as product documentation and does not route it as a spec source.
|
|
5
|
+
tags: [adr]
|
|
6
|
+
timestamp: 2026-10-07T00:00:00Z
|
|
7
|
+
status: accepted
|
|
8
|
+
---
|
|
9
|
+
<!-- sdd-generated-metadata
|
|
10
|
+
doc_kind: standing-doc
|
|
11
|
+
generated_from: adr@0.3.0
|
|
12
|
+
generated_by: claude-cowork
|
|
13
|
+
approved_by: akulakum@cisco.com
|
|
14
|
+
updated_at: 2026-10-08T10:12:58Z
|
|
15
|
+
validation_status: pass-with-warnings
|
|
16
|
+
-->
|
|
17
|
+
|
|
18
|
+
# ADR-0001 - Retain the product README
|
|
19
|
+
|
|
20
|
+
| Field | Value |
|
|
21
|
+
| ------------- | ----- |
|
|
22
|
+
| Status | Accepted |
|
|
23
|
+
| Decision date | 2026-10-07 |
|
|
24
|
+
| Deciders | akulakum@cisco.com (bootstrap questionnaire, SPARK-853121) |
|
|
25
|
+
| Supersedes | N/A |
|
|
26
|
+
| Superseded by | N/A |
|
|
27
|
+
|
|
28
|
+
## Context
|
|
29
|
+
|
|
30
|
+
Stage 0 found one existing document, `README.md`. It is the npm usage page. It shows installation,
|
|
31
|
+
`registerAndConnect` for the default session and named sessions, the `:<sessionId>` event suffix,
|
|
32
|
+
token get and set, `setRefreshHandler`, `refreshDataChannelToken`, the per-session accessors,
|
|
33
|
+
`getAllConnections`, `disconnectLLM`, and `disconnectAllLLM`.
|
|
34
|
+
|
|
35
|
+
The implementation in `src/` also has the owner-meeting checks, `clearDatachannelToken`,
|
|
36
|
+
`getWebSocketUrl`, the data-channel URL lookups, the `RegisterAndConnectTiming` result and
|
|
37
|
+
`error.timing`, the JWT feature toggle, the `subscriptionAwareSubchannels` query, and the `config.llm`
|
|
38
|
+
defaults. The README does not describe them. Its usage block also suggests importing
|
|
39
|
+
`DataChannelTokenType` from a source path, while `src/index.ts` exports it from the package root. No
|
|
40
|
+
other intent, design, or AI-authored spec exists in this package.
|
|
41
|
+
|
|
42
|
+
## Decision
|
|
43
|
+
|
|
44
|
+
Keep `README.md` unchanged. Do not migrate it into the module specification. Record
|
|
45
|
+
`spec_source_policy.mode` as `keep-separate` with `migrated_source_disposition` `retain` and an
|
|
46
|
+
empty `spec_sources` list.
|
|
47
|
+
|
|
48
|
+
The canonical behavior is `src/` plus `test/`. Where the README is incomplete, code wins.
|
|
49
|
+
|
|
50
|
+
## Why
|
|
51
|
+
|
|
52
|
+
The README is the npm-facing page. Rewriting it is a product-doc change, not a requirement of making
|
|
53
|
+
the package SDD-ready. The calls it shows exist in `src/llm.ts` with matching argument order, so
|
|
54
|
+
routing it as a spec source would add little beyond what the code already establishes.
|
|
55
|
+
|
|
56
|
+
## Alternatives considered
|
|
57
|
+
|
|
58
|
+
| Alternative | Why it was not selected |
|
|
59
|
+
| ----------- | ----------------------- |
|
|
60
|
+
| Migrate the README into `src/docs/README.md` and delete it | The page is retained product documentation, and deletion was not requested |
|
|
61
|
+
| Expand the README during Stage 0 | Stage 0 writes the SDD tree only and does not edit `README.md` |
|
|
62
|
+
|
|
63
|
+
## Consequences
|
|
64
|
+
|
|
65
|
+
**Positive:**
|
|
66
|
+
|
|
67
|
+
- The npm page stays stable for consumers.
|
|
68
|
+
- The module specification is the single behavioral reference.
|
|
69
|
+
|
|
70
|
+
**Negative / tradeoffs:**
|
|
71
|
+
|
|
72
|
+
- Agents must not treat `README.md` as the full list of methods, config keys, or ownership rules.
|
|
73
|
+
- README improvements remain a separate product-doc change.
|
|
74
|
+
|
|
75
|
+
## Constraint on future changes
|
|
76
|
+
|
|
77
|
+
Do not delete `README.md` as part of spec maintenance. If its usage text changes, keep the module
|
|
78
|
+
specification aligned with code rather than with the README.
|
|
79
|
+
|
|
80
|
+
## Follow-up
|
|
81
|
+
|
|
82
|
+
- [ ] None required for Stage 0.
|
|
83
|
+
|
|
84
|
+
## Revisit when
|
|
85
|
+
|
|
86
|
+
- A maintainer chooses to document ownership checks, timing results, or config defaults on the npm
|
|
87
|
+
page.
|
|
88
|
+
|
|
89
|
+
## References
|
|
90
|
+
|
|
91
|
+
- `README.md`
|
|
92
|
+
- `src/index.ts`
|
|
93
|
+
- `src/llm.ts`
|
|
94
|
+
- `.sdd/manifest.json` `spec_source_policy`
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!-- sdd-generated-metadata
|
|
2
|
+
doc_kind: standing-doc
|
|
3
|
+
generated_from: adr-index@0.3.0
|
|
4
|
+
generated_by: claude-cowork
|
|
5
|
+
approved_by: akulakum@cisco.com
|
|
6
|
+
updated_at: 2026-10-08T10:12:58Z
|
|
7
|
+
validation_status: pass-with-warnings
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
# Architectural decision records
|
|
11
|
+
|
|
12
|
+
Numbered, append-only records of structural decisions for this package and its documentation. The
|
|
13
|
+
module specification owns current behavior. An ADR owns why a documentation or structural choice was
|
|
14
|
+
made. Supersede an accepted ADR with a new one instead of editing its outcome.
|
|
15
|
+
|
|
16
|
+
## Index
|
|
17
|
+
|
|
18
|
+
| ADR | Title | Status |
|
|
19
|
+
| --- | ----- | ------ |
|
|
20
|
+
| [0001](0001-retain-product-readme.md) | Retain the product README and treat code as the behavioral authority | Accepted |
|
|
21
|
+
|
|
22
|
+
Keep this list in numeric order.
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: Architecture
|
|
3
|
+
title: '@webex/internal-plugin-llm architecture'
|
|
4
|
+
description: Package-wide boundaries, resources, interactions, dependencies, and cross-cutting architecture.
|
|
5
|
+
tags: [architecture]
|
|
6
|
+
---
|
|
7
|
+
<!-- sdd-generated-metadata
|
|
8
|
+
doc_kind: standing-doc
|
|
9
|
+
generated_from: architecture@0.3.0
|
|
10
|
+
generated_by: claude-cowork
|
|
11
|
+
approved_by: akulakum@cisco.com
|
|
12
|
+
updated_at: 2026-10-08T10:12:58Z
|
|
13
|
+
validation_status: pass-with-warnings
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
# @webex/internal-plugin-llm architecture
|
|
17
|
+
|
|
18
|
+
Canonical architecture for this package. LLM channel behavior lives in the
|
|
19
|
+
[LLM channel plugin specification](../src/docs/README.md). This page owns package boundaries, the
|
|
20
|
+
plugin registration, the contract index, and how the package meets the rest of the SDK.
|
|
21
|
+
|
|
22
|
+
Related context: [specification registry](specs/README.md) ·
|
|
23
|
+
[package agent instructions](../AGENTS.md)
|
|
24
|
+
|
|
25
|
+
## Applicability
|
|
26
|
+
|
|
27
|
+
| Condition ID | Status | Evidence or reason | Owned section |
|
|
28
|
+
| ------------------------------------ | ---------- | ------------------ | ------------- |
|
|
29
|
+
| `repo.owns_datastore` | N/A | No database, file store, or migration in `src/` | Repository data and schema |
|
|
30
|
+
| `repo.holds_client_state` | Applicable | `LLMChannel` keeps a per-session `connections` map in memory | Client state model |
|
|
31
|
+
| `repo.components_interact` | Applicable | `src/index.ts` registers `src/llm.ts`, which imports `src/constants.ts` and `src/llm.types.ts` | Dependency and interaction topology |
|
|
32
|
+
| `repo.domain_data_across_components` | N/A | One class owns all state; no record is shared across resources | Object and data ownership |
|
|
33
|
+
| `repo.caches_data` | Applicable | `datachannelTokens` in `src/llm.ts` caches data-channel tokens by key | Caching catalog |
|
|
34
|
+
| `repo.observability_convention` | Applicable | `llm#<method> -->` log prefixes and latency timing returned to callers | Observability patterns |
|
|
35
|
+
| `repo.deploys_to_infra` | N/A | Library published to npm. No service runtime. | Runtime and infrastructure |
|
|
36
|
+
| `repo.shared_base_libs` | Applicable | Inherits Mercury and the legacy build, lint, and test stack | Shared and base libraries |
|
|
37
|
+
| `repo.is_monorepo` | N/A | This SDD root is one package. The workspace around it is out of scope. | Package map and inter-package dependencies |
|
|
38
|
+
| `repo.multi_platform` | N/A | No platform-specific file or `browser` field; platform WebSocket selection is in Mercury | Platform matrix |
|
|
39
|
+
| `repo.published_package` | Applicable | `package.json` `name` is `@webex/internal-plugin-llm` and `deploy:npm` publishes it | Release and versioning |
|
|
40
|
+
| `repo.embedded_in_host` | N/A | No host theme or embed API | Host integration and theming |
|
|
41
|
+
| `repo.exposes_commands_or_artifacts` | Applicable | `build:src` writes `dist/` | Commands and generated artifacts |
|
|
42
|
+
| `repo.cross_repo_deps_material` | Applicable | Behavior depends on the Mercury superclass and on callers in sibling packages | Cross-repository topology |
|
|
43
|
+
| `repo.security_arch_warranted` | Applicable | Data-channel tokens cross to the data-channel service in a request header | Security architecture |
|
|
44
|
+
|
|
45
|
+
## Design overview
|
|
46
|
+
|
|
47
|
+
`@webex/internal-plugin-llm` is a published library with one module. Importing it registers
|
|
48
|
+
`LLMChannel` as the internal plugin `llm`, so every webex instance has `webex.internal.llm`. A
|
|
49
|
+
meeting calls `registerAndConnect` with its locus and data-channel URLs, then listens on
|
|
50
|
+
`webex.internal.llm` for `online` and `event:<type>` events.
|
|
51
|
+
|
|
52
|
+
`LLMChannel` adds an HTTP registration step, per-session metadata, an ownership model, and a token
|
|
53
|
+
cache on top of the Mercury plugin it extends. Mercury owns the socket, retries, keepalive, and event
|
|
54
|
+
emission. Keeping the subclass thin means LLM sockets behave like every other Mercury socket.
|
|
55
|
+
|
|
56
|
+
The package makes outbound HTTP and WebSocket calls only. It serves no routes and persists nothing.
|
|
57
|
+
|
|
58
|
+
## Resource inventory and responsibilities
|
|
59
|
+
|
|
60
|
+
| Resource | Kind | Responsibility | Owner | Source | Detailed specification |
|
|
61
|
+
| -------- | ---- | -------------- | ----- | ------ | ---------------------- |
|
|
62
|
+
| LLM channel plugin | module | Registration, session metadata, ownership, tokens, URL lookup | @webex/web-client, @webex/web-sdk | `src/` | `src/docs/README.md` |
|
|
63
|
+
| Published package | package | npm entry points and the registration side effect | @webex/web-client, @webex/web-sdk | `package.json` | `docs/architecture.md` |
|
|
64
|
+
|
|
65
|
+
## Interaction and execution flows
|
|
66
|
+
|
|
67
|
+
```mermaid
|
|
68
|
+
flowchart LR
|
|
69
|
+
importer[Package importer]
|
|
70
|
+
index[src_index_ts]
|
|
71
|
+
core[webex_core_registerInternalPlugin]
|
|
72
|
+
llm[src_llm_ts LLMChannel]
|
|
73
|
+
mercury[Mercury superclass]
|
|
74
|
+
dc[Data-channel service]
|
|
75
|
+
ws[LLM WebSocket service]
|
|
76
|
+
meetings[plugin-meetings]
|
|
77
|
+
importer --> index
|
|
78
|
+
index --> core
|
|
79
|
+
index --> llm
|
|
80
|
+
meetings -->|registerAndConnect, tokens, disconnectLLM| llm
|
|
81
|
+
llm -->|HTTP POST registration| dc
|
|
82
|
+
llm -->|connect and disconnect| mercury
|
|
83
|
+
mercury -->|WebSocket| ws
|
|
84
|
+
mercury -->|online and event emits| meetings
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
| From | To | Interaction or transport | Purpose | Failure or compatibility behavior |
|
|
88
|
+
| ---- | -- | ------------------------ | ------- | --------------------------------- |
|
|
89
|
+
| Importer | `src/index.ts` | package import | Register the plugin | Without the import, `webex.internal.llm` is absent |
|
|
90
|
+
| plugin-meetings | `webex.internal.llm` | method calls and event listeners | Connect sessions, manage tokens and ownership | See the module spec failure modes |
|
|
91
|
+
| `src/llm.ts` | Data-channel service | HTTP POST | Obtain socket URL and binding | Request errors reject `registerAndConnect` |
|
|
92
|
+
| `src/llm.ts` | Mercury superclass | inherited method calls | Open and close sockets | Connect errors reject with `timing` |
|
|
93
|
+
| Mercury superclass | plugin-meetings | events on `webex.internal.llm` | Deliver online state and envelopes | Default session unsuffixed; others suffixed |
|
|
94
|
+
|
|
95
|
+
## Dependency topology
|
|
96
|
+
|
|
97
|
+
| Dependency | Type | Used by | Purpose | Version, failure, or fallback policy |
|
|
98
|
+
| ---------- | ---- | ------- | ------- | ------------------------------------ |
|
|
99
|
+
| `@webex/internal-plugin-mercury` | Internal | `src` | Superclass; inherited behavior is under Shared and base libraries | `workspace:*` in `package.json` |
|
|
100
|
+
| `@webex/webex-core` | Internal | `src` | Plugin registration, request, logger, config | Resolved through the workspace; not listed in `package.json` |
|
|
101
|
+
| `@webex/internal-plugin-device` | Internal | `src` | `device.url` for the registration body | Loaded by Mercury's barrel |
|
|
102
|
+
| `@webex/internal-plugin-feature` | Internal | `src` | JWT data-channel toggle | Loaded by Mercury's barrel |
|
|
103
|
+
|
|
104
|
+
Ordering constraint: Mercury's barrel imports the device, feature, and metrics plugins first, and
|
|
105
|
+
`src/llm.ts` imports Mercury, so those plugins are registered before `llm`. No dependency cycle exists
|
|
106
|
+
inside the package.
|
|
107
|
+
|
|
108
|
+
## Public and consumer surfaces
|
|
109
|
+
|
|
110
|
+
| Surface | Type | Owner | Consumers | Compatibility policy | Source |
|
|
111
|
+
| ------- | ---- | ----- | --------- | -------------------- | ------ |
|
|
112
|
+
| `llm-sdk` (published) | SDK | LLM channel plugin | plugin-meetings, internal-plugin-voicea | Internal plugin; README says semver is not strictly followed | `package.json` |
|
|
113
|
+
| `llm-plugin-events` (published) | Event | LLM channel plugin | plugin-meetings | Inherited Mercury event names; renaming is breaking | `src/llm.ts` |
|
|
114
|
+
| `llm-datachannel-protocol` (internal) | RPC | LLM channel plugin | Data-channel service | Must match the service request and response | `src/llm.ts` |
|
|
115
|
+
| `mercury-plugin-base` (required) | SDK | sibling package internal-plugin-mercury | LLM channel plugin | Superclass; method changes ship together | `@webex/internal-plugin-mercury` |
|
|
116
|
+
| `webex-core-plugin-host` (required) | RPC | sibling package webex-core | LLM channel plugin | External | `@webex/webex-core` |
|
|
117
|
+
| `webex-device-registration` (required) | SDK | sibling package internal-plugin-device | LLM channel plugin | External | `@webex/internal-plugin-device` |
|
|
118
|
+
| `webex-feature-toggles` (required) | SDK | sibling package internal-plugin-feature | LLM channel plugin | External | `@webex/internal-plugin-feature` |
|
|
119
|
+
|
|
120
|
+
`llm-sdk` entry points: `main` `dist/index.js` and `devMain` `src/index.ts`. No HTTP surface is
|
|
121
|
+
served, so `api-specs/openapi.yaml` is omitted.
|
|
122
|
+
|
|
123
|
+
## Client state model
|
|
124
|
+
|
|
125
|
+
| State or slice | Owner | Transition triggers | Persistence or reset boundary |
|
|
126
|
+
| -------------- | ----- | ------------------- | ----------------------------- |
|
|
127
|
+
| Session map `connections` | LLM channel plugin | register, owner and handler setters, disconnect | In memory per webex instance; cleared by `disconnectAllLLM` |
|
|
128
|
+
| Sockets per session | Mercury superclass | connect, close, disconnect | Owned by Mercury |
|
|
129
|
+
|
|
130
|
+
Slice detail is in the module spec.
|
|
131
|
+
|
|
132
|
+
## Cross-cutting architecture
|
|
133
|
+
|
|
134
|
+
### Security
|
|
135
|
+
|
|
136
|
+
- Trust boundaries and identity flow: see Security architecture.
|
|
137
|
+
- Sensitive surfaces and data classes: data-channel tokens and envelope content; controls and gaps
|
|
138
|
+
are in Security architecture.
|
|
139
|
+
- Encryption and secret boundaries: transport encryption is whatever scheme the caller-supplied and
|
|
140
|
+
service-returned URLs use; tokens are held only in memory.
|
|
141
|
+
|
|
142
|
+
### Observability and operations
|
|
143
|
+
|
|
144
|
+
- Logging and correlation: conventions are under Observability patterns.
|
|
145
|
+
- Metrics, traces, and audit signals: listed under Observability patterns.
|
|
146
|
+
- Ownership and operational entry points: no runtime to deploy or monitor; owners are listed in
|
|
147
|
+
References and maintenance.
|
|
148
|
+
|
|
149
|
+
### Quality attributes
|
|
150
|
+
|
|
151
|
+
- Availability: sockets reconnect through Mercury; registration is not retried here.
|
|
152
|
+
- Compatibility: session ids, token keys, and event names are relied on by plugin-meetings.
|
|
153
|
+
- Isolation: ownership checks keep one meeting from tearing down another meeting's session.
|
|
154
|
+
|
|
155
|
+
## Dependency and interaction topology
|
|
156
|
+
|
|
157
|
+
```mermaid
|
|
158
|
+
flowchart TD
|
|
159
|
+
indexTs[src_index_ts]
|
|
160
|
+
llmTs[src_llm_ts]
|
|
161
|
+
typesTs[src_llm_types_ts]
|
|
162
|
+
constTs[src_constants_ts]
|
|
163
|
+
indexTs --> llmTs
|
|
164
|
+
indexTs --> typesTs
|
|
165
|
+
indexTs --> constTs
|
|
166
|
+
llmTs --> typesTs
|
|
167
|
+
llmTs --> constTs
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
| From | To | Kind | Purpose | Ordering or failure boundary |
|
|
171
|
+
| ---- | -- | ---- | ------- | ---------------------------- |
|
|
172
|
+
| `src/index.ts` | `src/llm.ts` | Import | Register the class and its `config` | Registration runs at import time |
|
|
173
|
+
| `src/llm.ts` | `src/constants.ts` | Import | Namespace, session ids, toggle and query names | Load-time only |
|
|
174
|
+
| `src/llm.ts` | `src/llm.types.ts` | Import | Token enum and interface | Load-time only |
|
|
175
|
+
|
|
176
|
+
## Caching catalog
|
|
177
|
+
|
|
178
|
+
| Cache | Owner | Backend | Contents | TTL or bound | Invalidation trigger | Failure behavior |
|
|
179
|
+
| ----- | ----- | ------- | -------- | ------------ | -------------------- | ---------------- |
|
|
180
|
+
| `datachannelTokens` | LLM channel plugin | In-memory object | Data-channel token per token key | No TTL; unbounded keys | `clearDatachannelToken` by the owner only; disconnects do not clear it | A miss or non-owner read returns `undefined` |
|
|
181
|
+
|
|
182
|
+
## Observability patterns
|
|
183
|
+
|
|
184
|
+
| Signal | Convention or required fields | Propagation or naming rule | Primary evidence |
|
|
185
|
+
| ------ | ----------------------------- | -------------------------- | ---------------- |
|
|
186
|
+
| Logs | `llm#<method> -->` prefix with the session id; inherited Mercury lines use the `llm` namespace | Through `this.logger`; tokens are not logged | `src/llm.ts` |
|
|
187
|
+
| Metrics | N/A — no metric is submitted here; `registerAndConnect` returns latency fields that callers report | Field names are in the module spec | `src/llm.ts` |
|
|
188
|
+
| Traces | N/A — no spans | — | `src/llm.ts` |
|
|
189
|
+
| Audit | N/A — no audited actions | — | `src/llm.ts` |
|
|
190
|
+
|
|
191
|
+
## Shared and base libraries
|
|
192
|
+
|
|
193
|
+
| Library | Inherited responsibility | Consumers | Version floor | Compatibility rule |
|
|
194
|
+
| ------- | ------------------------ | --------- | ------------- | ------------------ |
|
|
195
|
+
| Mercury from `@webex/internal-plugin-mercury` | Socket lifecycle, retries, keepalive, event emission | `src/llm.ts` | workspace | Change socket behavior in Mercury |
|
|
196
|
+
| `WebexPlugin` from `@webex/webex-core` (through Mercury) | `this.config` bound to `config.llm`, `this.request`, `this.logger` | `src/llm.ts` | workspace | Follow webex-core plugin conventions |
|
|
197
|
+
| `@webex/babel-config-legacy`, `@webex/eslint-config-legacy`, `@webex/jest-config-legacy` | Build, lint, and Jest config passthroughs | `babel.config.js`, `.eslintrc.js`, `jest.config.js` | workspace | Change upstream, not in the passthrough files |
|
|
198
|
+
| `@webex/legacy-tools` | `webex-legacy-tools` build and test runners | `package.json` scripts | workspace | Scripts call it; do not replace locally |
|
|
199
|
+
|
|
200
|
+
## Release and versioning
|
|
201
|
+
|
|
202
|
+
| Artifact | Publish target | Versioning rule | Deprecation window | Changelog or migration obligation |
|
|
203
|
+
| -------- | -------------- | --------------- | ------------------ | --------------------------------- |
|
|
204
|
+
| `@webex/internal-plugin-llm` | npm, through the `deploy:npm` script, which wraps Yarn's npm publish | Workspace release tooling; README says the internal plugin does not strictly follow semver | None declared in code | No package-local changelog; workspace tooling owns it |
|
|
205
|
+
|
|
206
|
+
## Commands and generated artifacts
|
|
207
|
+
|
|
208
|
+
| Command or artifact | Owner | Inputs | Output or side effect | Compatibility boundary |
|
|
209
|
+
| ------------------- | ----- | ------ | --------------------- | ---------------------- |
|
|
210
|
+
| `yarn install` | workspace | root `package.json` and lockfile | workspace `node_modules` | Run from the workspace root |
|
|
211
|
+
| `yarn workspace @webex/internal-plugin-llm build` | package | `src/` | `dist/` through `build:src` | `dist/` is never edited by hand |
|
|
212
|
+
| `yarn workspace @webex/internal-plugin-llm build:src` | package | `src/` (`.js` and `.ts`) | `dist/` with source maps | Markdown under `src/` is not processed |
|
|
213
|
+
| `yarn workspace @webex/internal-plugin-llm test:unit` | package | `test/unit/spec/` | jest result | — |
|
|
214
|
+
| `yarn workspace @webex/internal-plugin-llm test:browser` | package | integration files only | karma result; no files today | See Getting started |
|
|
215
|
+
| `yarn workspace @webex/internal-plugin-llm test:style` | package | files under `src/` | eslint result | Markdown is reported as ignored |
|
|
216
|
+
| `yarn workspace @webex/internal-plugin-llm deploy:npm` | package | `dist/`, `package.json` | npm publish | Release pipeline only |
|
|
217
|
+
|
|
218
|
+
## Cross-repository topology
|
|
219
|
+
|
|
220
|
+
| Repository or external system | Relationship | Exchanged contract or artifact | Owner | Sequencing constraint |
|
|
221
|
+
| ----------------------------- | ------------ | ------------------------------ | ----- | --------------------- |
|
|
222
|
+
| Sibling package internal-plugin-mercury | Consumes | `mercury-plugin-base` | @webex/web-client, @webex/web-sdk | Superclass changes ship with LLM checks |
|
|
223
|
+
| Sibling package webex-core | Consumes | `webex-core-plugin-host` | @webex/web-client, @webex/web-sdk | Plugin host must exist before registration |
|
|
224
|
+
| Sibling package internal-plugin-device | Consumes | `webex-device-registration` | @webex/web-client, @webex/web-sdk | Device URL must exist before registration |
|
|
225
|
+
| Sibling package internal-plugin-feature | Consumes | `webex-feature-toggles` | @webex/web-sdk (CODEOWNERS default rule) | Toggle read on each call |
|
|
226
|
+
| Sibling package plugin-meetings | Provides | `llm-sdk`, `llm-plugin-events` | @webex/web-client, @webex/web-sdk | Method and session-id changes ship with meetings changes |
|
|
227
|
+
| Sibling package internal-plugin-voicea | Provides | `llm-sdk` (`LLM_PRACTICE_SESSION`) | @webex/web-client, @webex/web-sdk | Constant changes ship together |
|
|
228
|
+
| Data-channel service | Coordinates | `llm-datachannel-protocol` | External Webex service; owner not recorded in this repository | Request and response fields must match |
|
|
229
|
+
|
|
230
|
+
These are sibling workspace packages and an external service outside this package-scoped SDD root.
|
|
231
|
+
|
|
232
|
+
## Security architecture
|
|
233
|
+
|
|
234
|
+
Threats addressed: data-channel token leakage across meetings, and tokens reaching the network
|
|
235
|
+
outside the JWT flow.
|
|
236
|
+
|
|
237
|
+
```mermaid
|
|
238
|
+
flowchart LR
|
|
239
|
+
meeting[plugin-meetings] -->|setDatachannelToken with owner id| cache[datachannelTokens]
|
|
240
|
+
meeting -->|token argument| llm[LLMChannel register]
|
|
241
|
+
toggle[JWT toggle] --> llm
|
|
242
|
+
llm -->|Data-Channel-Auth-Token header| dc[Data-channel service]
|
|
243
|
+
handler[caller refresh handler] -->|new token| meeting
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Controls in this package:
|
|
247
|
+
|
|
248
|
+
- The token is sent only as a request header, and only when the JWT toggle is on (module spec
|
|
249
|
+
`INV-004`). It is never added to a URL or a log line.
|
|
250
|
+
- Owner-meeting checks guard token reads and writes, refresh-handler writes, and single-session
|
|
251
|
+
disconnect (module spec `INV-002`).
|
|
252
|
+
- Token refresh is delegated to the caller's handler; this package does not request tokens itself.
|
|
253
|
+
|
|
254
|
+
Known gaps are recorded where the code lives: the omitted-owner path, the unguarded
|
|
255
|
+
`disconnectAllLLM`, and token-key ownership in the module spec Pitfalls.
|
|
256
|
+
|
|
257
|
+
The workspace root `SECURITY.md` is the security policy; this package adds none.
|
|
258
|
+
|
|
259
|
+
## Domain language
|
|
260
|
+
|
|
261
|
+
| Term | Repository-specific meaning | Authoritative source |
|
|
262
|
+
| ---- | --------------------------- | -------------------- |
|
|
263
|
+
| LLM channel | The data-channel WebSocket a meeting uses, opened by `LLMChannel` | `src/llm.ts` |
|
|
264
|
+
| Session | One connection keyed by session id; default `llm-default-session` | `src/constants.ts` |
|
|
265
|
+
| Data-channel URL | The registration URL a meeting supplies; also the key for request lookup | `src/llm.ts` |
|
|
266
|
+
| Binding | The value returned by registration and kept per session | `src/llm.ts` |
|
|
267
|
+
| Owner meeting | The meeting id allowed to change or close a session | `src/llm.ts` |
|
|
268
|
+
| Token key | The key in the token cache; the built-in keys are the `DataChannelTokenType` values | `src/llm.types.ts` |
|
|
269
|
+
| Subscription-aware subchannel | A subchannel named in the `subscriptionAwareSubchannels` query | `src/constants.ts` |
|
|
270
|
+
|
|
271
|
+
## References and maintenance
|
|
272
|
+
|
|
273
|
+
- Decisions: [adr/](adr/), including [ADR 0001](adr/0001-retain-product-readme.md)
|
|
274
|
+
- Instantiated specifications and routing: [specs/README.md](specs/README.md)
|
|
275
|
+
- Module spec: `src/docs/README.md`
|
|
276
|
+
- Owner: `@webex/web-client @webex/web-sdk` in the monorepo `.github/CODEOWNERS`
|
|
277
|
+
- Manifest: `.sdd/manifest.json`
|
|
278
|
+
- Update this document in the same change that alters package boundaries, contracts, or
|
|
279
|
+
cross-cutting behavior.
|