@telia-ace/widget-conversational-agent 1.1.123-rc.6 → 1.1.123-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/index.mjs +7 -3
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -1413,4 +1413,4 @@ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An err
|
|
|
1413
1413
|
button:hover {
|
|
1414
1414
|
filter: brightness(150%);
|
|
1415
1415
|
}
|
|
1416
|
-
`];ca([Bo({context:Fs}),C({attribute:!1})],bn.prototype,"application",2);bn=ca([Qc("ace-restart-dialog")],bn);class Qs extends Cl{constructor(e,t){super(e,t),this.isConnected=!1,this.rehydrating=!1,this.lastReceivedMessageWasComplete=!0,this.isReady=!1,this.lastWrittenEntry=null,this.agent=this.createAgent(""),this.user=this.createUser(""),this.shouldRestartSubject$=new H(!1),this.connection=this.createConnection(t.properties),this.connection.store$.subscribe(s=>{s={...s,messages:s.messages.filter(i=>!i.reconnectResponsePayload)},this.save(s)}),this.connection.isConnected().subscribe(s=>{this.isConnected=s,s?(this.component.enableInput(),this.setShouldRestart(!1)):this.component.disableInput()}),this.connection.agent().subscribe(s=>{this.agent.name=s.name}),this.connection.messages().subscribe(s=>{if(s.type==="stream"){let i=null;if(this.lastReceivedMessageWasComplete||!this.lastWrittenEntry)i=this.printAgent(s.text),i&&(this.lastWrittenEntry={entry:i,messages:[s]});else if(this.lastWrittenEntry){const r=this.mergeMessageParts(this.lastWrittenEntry.messages);s.isComplete?(this.updateEntry(this.lastWrittenEntry.entry,`${r}${s.text}`),this.lastWrittenEntry.messages.push(s)):(this.updateEntry(this.lastWrittenEntry.entry,`${r}${s.text}`),this.lastWrittenEntry.messages.push(s))}this.lastReceivedMessageWasComplete=s.isComplete}else s.sender==="user"?this.printUser(s.text):this.printAgent(s.text)}),this.connection.events().subscribe(s=>{switch(s.event){case"disconnected":this.printAgent("You were disconnected from the chat session."),this.showRestartDialog();break;case"handover":this.showRestartDialog();break}})}static getInstance(e,t){return t.providerInstance||(t.providerInstance=new Qs(e,t)),t.providerInstance}setShouldRestart(e){this.shouldRestartSubject$.next(e)}get shouldRestart$(){return this.shouldRestartSubject$.asObservable()}printAgent(e){return this.setTypingState(!1),this.agent.print(e,"markdown")}printUser(e){const t=cs(Hi(e));return this.user.print(t)}printSystem(e){const t=cs(Hi(e));return this.system.print(t)}showRestartDialog(){this.restartDialogEntry&&this.restartDialogEntry.remove(),this.component.disableInput(),this.restartDialogEntry=new It(be.System,{name:""},[{items:[["ace-restart-dialog",{content:""}]]}]),this.printEntry(this.restartDialogEntry),this.restartDialogEntry.actions$.pipe(wl(e=>e.key==="restart-session"),Ie(1)).subscribe(async()=>{this.restartDialogEntry&&this.restartDialogEntry.remove(),this.restartConversation(),this.component.clearMessages()})}onUserSubmit(e){if(!this.isConnected){this.printAgent("The connection have been closed. Please reload the page to start a new session.");return}this.printUser(e.text),this.connection.sendMessage({text:e.text}),!(e.text.includes("__agent__")||e.text.includes("__mockad agent__"))&&this.setTypingState(!0)}mergeMessageParts(e){return e.length?e.map(t=>t.text).join(""):""}updateEntry(e,t){e.update([["markdown",{content:t}]])}createConnection(e){this.connection&&this.connection.dispose();const
|
|
1416
|
+
`];ca([Bo({context:Fs}),C({attribute:!1})],bn.prototype,"application",2);bn=ca([Qc("ace-restart-dialog")],bn);class Qs extends Cl{constructor(e,t){super(e,t),this.isConnected=!1,this.rehydrating=!1,this.lastReceivedMessageWasComplete=!0,this.isReady=!1,this.lastWrittenEntry=null,this.agent=this.createAgent(""),this.user=this.createUser(""),this.shouldRestartSubject$=new H(!1),this.connection=this.createConnection(t.properties),this.connection.store$.subscribe(s=>{s={...s,messages:s.messages.filter(i=>!i.reconnectResponsePayload)},this.save(s)}),this.connection.isConnected().subscribe(s=>{this.isConnected=s,s?(this.component.enableInput(),this.setShouldRestart(!1)):this.component.disableInput()}),this.connection.agent().subscribe(s=>{this.agent.name=s.name}),this.connection.messages().subscribe(s=>{if(s.type==="stream"){let i=null;if(this.lastReceivedMessageWasComplete||!this.lastWrittenEntry)i=this.printAgent(s.text),i&&(this.lastWrittenEntry={entry:i,messages:[s]});else if(this.lastWrittenEntry){const r=this.mergeMessageParts(this.lastWrittenEntry.messages);s.isComplete?(this.updateEntry(this.lastWrittenEntry.entry,`${r}${s.text}`),this.lastWrittenEntry.messages.push(s)):(this.updateEntry(this.lastWrittenEntry.entry,`${r}${s.text}`),this.lastWrittenEntry.messages.push(s))}this.lastReceivedMessageWasComplete=s.isComplete}else s.sender==="user"?this.printUser(s.text):this.printAgent(s.text)}),this.connection.events().subscribe(s=>{switch(s.event){case"disconnected":this.printAgent("You were disconnected from the chat session."),this.showRestartDialog();break;case"handover":this.showRestartDialog();break}})}static getInstance(e,t){return t.providerInstance||(t.providerInstance=new Qs(e,t)),t.providerInstance}setShouldRestart(e){this.shouldRestartSubject$.next(e)}get shouldRestart$(){return this.shouldRestartSubject$.asObservable()}printAgent(e){return this.setTypingState(!1),this.agent.print(e,"markdown")}printUser(e){const t=cs(Hi(e));return this.user.print(t)}printSystem(e){const t=cs(Hi(e));return this.system.print(t)}showRestartDialog(){this.restartDialogEntry&&this.restartDialogEntry.remove(),this.component.disableInput(),this.restartDialogEntry=new It(be.System,{name:""},[{items:[["ace-restart-dialog",{content:""}]]}]),this.printEntry(this.restartDialogEntry),this.restartDialogEntry.actions$.pipe(wl(e=>e.key==="restart-session"),Ie(1)).subscribe(async()=>{this.restartDialogEntry&&this.restartDialogEntry.remove(),this.restartConversation(),this.component.clearMessages()})}onUserSubmit(e){if(!this.isConnected){this.printAgent("The connection have been closed. Please reload the page to start a new session.");return}this.printUser(e.text),this.connection.sendMessage({text:e.text}),!(e.text.includes("__agent__")||e.text.includes("__mockad agent__"))&&this.setTypingState(!0)}mergeMessageParts(e){return e.length?e.map(t=>t.text).join(""):""}updateEntry(e,t){e.update([["markdown",{content:t}]])}createConnection(e){var r;this.connection&&this.connection.dispose();const t=(r=this.component.application.settings.agents)==null?void 0:r.extension;if(!t)throw new Error("Extension is required, config misconfigured. See agents.extension");const s=`wss://knowledge-dev.ace.teliacompany.net/v1/dialogflow/ws?agent_id=${t}&project=know-sandbox-dev`,i=e.webconnectorUrl||s;return e.extension?new zr({connectionUri:i,extension:e.extension.toString()},this.component,this):(console.warn("ConversationalAgentProvider has not defined an extension. Using default extension 1792."),new zr({connectionUri:i,extension:"1936"},this.component,this))}restartConversation(){if(this.isConnected){this.setShouldRestart(!0),this.connection.endSession();return}this.connection.connect()}save(e){this.rehydrating||this.saveToCurrentSession$.next(e)}async rehydrate(e){this.rehydrating=!0,this.connection&&this.connection.rehydrate(e)}connect(e){super.connect(),this.rehydrating=!1,this.component.application.root&&this.component.application.root.isReady.subscribe(t=>{t&&!this.isReady&&(this.connection.connect(),this.isReady=!0)})}}const Br="ace-conversational-agent-provider",Zh=async n=>{(await Ss.getInstance(n.container)).registerProvider(Br,t=>Qs.getInstance(Br,t))};exports.ConversationalAgentProviderPlugin=Zh;
|
package/index.mjs
CHANGED
|
@@ -8053,11 +8053,15 @@ class Qs extends Cl {
|
|
|
8053
8053
|
e.update([["markdown", { content: t }]]);
|
|
8054
8054
|
}
|
|
8055
8055
|
createConnection(e) {
|
|
8056
|
+
var r;
|
|
8056
8057
|
this.connection && this.connection.dispose();
|
|
8057
|
-
const
|
|
8058
|
+
const t = (r = this.component.application.settings.agents) == null ? void 0 : r.extension;
|
|
8059
|
+
if (!t)
|
|
8060
|
+
throw new Error("Extension is required, config misconfigured. See agents.extension");
|
|
8061
|
+
const s = `wss://knowledge-dev.ace.teliacompany.net/v1/dialogflow/ws?agent_id=${t}&project=know-sandbox-dev`, i = e.webconnectorUrl || s;
|
|
8058
8062
|
return e.extension ? new zr(
|
|
8059
8063
|
{
|
|
8060
|
-
connectionUri:
|
|
8064
|
+
connectionUri: i,
|
|
8061
8065
|
extension: e.extension.toString()
|
|
8062
8066
|
},
|
|
8063
8067
|
this.component,
|
|
@@ -8066,7 +8070,7 @@ class Qs extends Cl {
|
|
|
8066
8070
|
"ConversationalAgentProvider has not defined an extension. Using default extension 1792."
|
|
8067
8071
|
), new zr(
|
|
8068
8072
|
{
|
|
8069
|
-
connectionUri:
|
|
8073
|
+
connectionUri: i,
|
|
8070
8074
|
extension: "1936"
|
|
8071
8075
|
},
|
|
8072
8076
|
this.component,
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/widget-conversational-agent",
|
|
3
|
-
"version": "1.1.123-rc.
|
|
3
|
+
"version": "1.1.123-rc.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@telia-ace/widget-conversation-flamingo": "1.1.123-rc.
|
|
9
|
+
"@telia-ace/widget-conversation-flamingo": "1.1.123-rc.7",
|
|
10
10
|
"rxjs": "^7.8.2",
|
|
11
|
-
"@telia-ace/widget-core-flamingo": "1.1.123-rc.
|
|
11
|
+
"@telia-ace/widget-core-flamingo": "1.1.123-rc.7",
|
|
12
12
|
"lit": "^3.0.2",
|
|
13
13
|
"@lit/context": "^1.1.4"
|
|
14
14
|
},
|