@webority/chat-core 0.149.0 → 0.150.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/dist/index.js +1 -1
- package/dist/links.js +1 -0
- package/dist/transcript.js +3 -3
- package/dist/types/index.d.ts +1 -0
- package/dist/types/links.d.ts +2 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sniffAudioType as e}from"./audioType.js";import{ChatApiError as t,createChatClient as n,newIdempotencyKey as r}from"./client.js";import{ChatDecodeError as i}from"./decode/primitives.js";import{CHAT_CONTRACT_VERSION as a,CHAT_HANDOFF_REQUEST_ID as o}from"./contract.js";import{decodeChatPart as s}from"./decode/parts.js";import{decodeChatConversationView as c,decodeChatMessageView as l}from"./decode/messages.js";import{createConversationList as u}from"./conversationList.js";import{decodeChatProfileView as d}from"./decode/profile.js";import{decodeChatStreamEvent as f}from"./decode/events.js";import{DICTATION_NO_SPEECH_MS as p,DICTATION_SILENCE_MS as m,createDictation as h}from"./dictation.js";import{createExplain as g}from"./explain.js";import{formatFigure as _,toFigureRuns as v,toFigureText as y}from"./figures.js";import{decodeChatFixture as b}from"./decode/fixture.js";import{createFixtureClient as x}from"./fixtureClient.js";import{formatChatDate as S,formatChatDateTime as C,formatChatDay as w,formatChatValue as T,formatFileSize as E,messagePlainText as D}from"./format.js";import{isHandoffTarget as O}from"./handoff.js";import{IDLE_CHAT_SESSION as k,IDLE_CHAT_STATE as A}from"./idleSession.js";import{DEFAULT_CHAT_LABELS as j,mergeLabels as M}from"./labels.js";import{defaultChatLook as
|
|
1
|
+
import{sniffAudioType as e}from"./audioType.js";import{ChatApiError as t,createChatClient as n,newIdempotencyKey as r}from"./client.js";import{ChatDecodeError as i}from"./decode/primitives.js";import{CHAT_CONTRACT_VERSION as a,CHAT_HANDOFF_REQUEST_ID as o}from"./contract.js";import{decodeChatPart as s}from"./decode/parts.js";import{decodeChatConversationView as c,decodeChatMessageView as l}from"./decode/messages.js";import{createConversationList as u}from"./conversationList.js";import{decodeChatProfileView as d}from"./decode/profile.js";import{decodeChatStreamEvent as f}from"./decode/events.js";import{DICTATION_NO_SPEECH_MS as p,DICTATION_SILENCE_MS as m,createDictation as h}from"./dictation.js";import{createExplain as g}from"./explain.js";import{formatFigure as _,toFigureRuns as v,toFigureText as y}from"./figures.js";import{decodeChatFixture as b}from"./decode/fixture.js";import{createFixtureClient as x}from"./fixtureClient.js";import{formatChatDate as S,formatChatDateTime as C,formatChatDay as w,formatChatValue as T,formatFileSize as E,messagePlainText as D}from"./format.js";import{isHandoffTarget as O}from"./handoff.js";import{IDLE_CHAT_SESSION as k,IDLE_CHAT_STATE as A}from"./idleSession.js";import{DEFAULT_CHAT_LABELS as j,mergeLabels as M}from"./labels.js";import{isSafeLinkUrl as N}from"./links.js";import{defaultChatLook as P,mergeLook as F}from"./look.js";import{pacingDelayMs as I}from"./pacing.js";import{CHAT_FEATURES as L,LOADER_STYLES as R,emptyFeatures as z,featureRecord as B,loaderView as V,resolveFeatures as H,resolveNudge as U,resolveStart as W,showsCaptchaNote as G}from"./profile.js";import{createChatSession as K,createTurnApi as q,handoffSettledIds as J}from"./session.js";import{CHAT_SPEECH_TOKEN_MARGIN_MS as Y,ChatSpeechError as X,createSpeechTokenSource as Z}from"./speech.js";import{humanizeService as Q,selectStarters as $}from"./starters.js";import{createSseParser as ee,createStreamReader as te}from"./stream.js";import{buildTranscript as ne,transcriptToText as re}from"./transcript.js";import{formatClipTime as ie,voiceClipBars as ae}from"./voiceClip.js";export{a as CHAT_CONTRACT_VERSION,L as CHAT_FEATURES,o as CHAT_HANDOFF_REQUEST_ID,Y as CHAT_SPEECH_TOKEN_MARGIN_MS,t as ChatApiError,i as ChatDecodeError,X as ChatSpeechError,j as DEFAULT_CHAT_LABELS,p as DICTATION_NO_SPEECH_MS,m as DICTATION_SILENCE_MS,k as IDLE_CHAT_SESSION,A as IDLE_CHAT_STATE,R as LOADER_STYLES,ne as buildTranscript,n as createChatClient,K as createChatSession,u as createConversationList,h as createDictation,g as createExplain,x as createFixtureClient,Z as createSpeechTokenSource,ee as createSseParser,te as createStreamReader,q as createTurnApi,c as decodeChatConversationView,b as decodeChatFixture,l as decodeChatMessageView,s as decodeChatPart,d as decodeChatProfileView,f as decodeChatStreamEvent,P as defaultChatLook,z as emptyFeatures,B as featureRecord,S as formatChatDate,C as formatChatDateTime,w as formatChatDay,T as formatChatValue,ie as formatClipTime,_ as formatFigure,E as formatFileSize,J as handoffSettledIds,Q as humanizeService,O as isHandoffTarget,N as isSafeLinkUrl,V as loaderView,M as mergeLabels,F as mergeLook,D as messagePlainText,r as newIdempotencyKey,I as pacingDelayMs,H as resolveFeatures,U as resolveNudge,W as resolveStart,$ as selectStarters,G as showsCaptchaNote,e as sniffAudioType,v as toFigureRuns,y as toFigureText,re as transcriptToText,ae as voiceClipBars};
|
package/dist/links.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=/^https?:\/\//i,t=t=>typeof t==`string`&&e.test(t);export{t as isSafeLinkUrl};
|
package/dist/transcript.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{formatFigure as e,toFigureText as t}from"./figures.js";import{formatChatDate as n,formatChatValue as r,formatFileSize as i,messagePlainText as a}from"./format.js";var
|
|
2
|
-
`));for(let r of e.entries){let e=t.speakers?[`${r.speaker}:`]:[];for(let t of r.blocks)e.push(...
|
|
1
|
+
import{formatFigure as e,toFigureText as t}from"./figures.js";import{formatChatDate as n,formatChatValue as r,formatFileSize as i,messagePlainText as a}from"./format.js";import{isSafeLinkUrl as o}from"./links.js";var s=e=>e;function c(e){return e!=null&&e.trim()!==``}function l(e){return{kind:`paragraph`,text:e}}function u(e){return e.split(/\n\s*\n/).map(e=>e.trim()).filter(e=>e!==``).map(l)}function d(e){return o(e.url)?`${e.title} (${e.url})`:e.title}function f(e,t){return t===null?e:`${e??``} (${t})`.trim()}function p(e){let t=[],n=/* @__PURE__ */ new Set,i=e.map(e=>{let r=/* @__PURE__ */ new Map;for(let i of e.points)r.set(i.label,i.value),n.has(i.label)||(n.add(i.label),t.push(i.label));return r});return t.map(e=>[e,...i.map(t=>{let n=t.get(e);return n===void 0?``:r(n,`Decimal`,null)})])}function m(e){return e.map(e=>e.kind===`sup`?`^${e.text}`:e.text).join(``)}function h(t){return Math.abs(t)<.001&&t!==0?m(e(t)):r(t,`Decimal`,null)}function g(e,t){switch(e.kind){case`Text`:case`Notice`:return u(a([e]));case`Sources`:return e.sources.length===0?[]:[l(t.sources),{kind:`list`,ordered:!0,items:e.sources.map(d)}];case`QuickReplies`:case`Handoff`:return[];case`InputRequest`:return e.state!==`Answered`||!c(e.answeredSummary)?[]:[l(e.title===null?e.answeredSummary:`${e.title}: ${e.answeredSummary}`)];case`Action`:{let t=[l(e.title)];return e.lines.length>0&&t.push({kind:`list`,ordered:!1,items:[...e.lines]}),t}case`Table`:return[{kind:`table`,title:e.title,head:e.columns.map(e=>e.label),rows:e.rows.map(t=>e.columns.map((n,i)=>r(t[i]??null,n.type,e.currency)))}];case`Chart`:return e.series.length===0?[]:[{kind:`table`,title:f(e.title,e.unit),head:[``,...e.series.map(e=>e.name)],rows:p(e.series)}];case`Figures`:return e.figures.length===0?[]:[{kind:`table`,title:null,head:[],rows:e.figures.map(e=>[e.label,h(e.value)+(c(e.unit)?` ${e.unit}`:``)])}];case`RecordCard`:{let t=[l(e.subtitle===null?e.title:`${e.title} ${e.subtitle}`)];return e.fields.length>0&&t.push({kind:`table`,title:null,head:[],rows:e.fields.map(e=>[e.label,r(e.value,e.type,null)])}),t}case`Image`:return c(e.alt)?[l(e.alt)]:[];case`File`:return[l(`${e.fileName} (${i(e.length)})`)];case`Ticket`:return[l(`${e.number} ${e.subject}`)];case`VoiceClip`:return c(e.transcript)?[l(e.transcript)]:[];default:return[]}}function _(e,t){switch(e.kind){case`paragraph`:return{kind:`paragraph`,text:t(e.text)};case`list`:return{kind:`list`,ordered:e.ordered,items:e.items.map(e=>t(e))};case`table`:return{kind:`table`,title:e.title===null?null:t(e.title),head:e.head.map(e=>t(e)),rows:e.rows.map(e=>e.map(e=>t(e)))}}}function v(e,t,n){switch(e.kind){case`Visitor`:case`Customer`:return t.you;case`Agent`:return c(e.displayName)?e.displayName:t.agent;case`Assistant`:case`Script`:return c(e.displayName)?e.displayName:c(n)?n:t.assistant;case`System`:throw Error(`A System message has no speaker: buildTranscript skips it.`)}}function y(e,r){let i=r.figureText?t:s,a=[],o=null;for(let t of e){if(t.streaming||t.author.kind===`System`)continue;let e=t.parts.flatMap(e=>g(e,r.labels)).map(e=>_(e,i));e.length!==0&&(a.push({speaker:v(t.author,r.labels,r.assistantName),blocks:e}),o===null&&(o=n(t.createdDateTimeUtc)))}return{title:c(r.title)?r.title:r.labels.untitled,dateText:o,entries:a}}function b(e){switch(e.kind){case`paragraph`:return[e.text];case`list`:return e.items.map((t,n)=>e.ordered?`${n+1}. ${t}`:`- ${t}`);case`table`:{let t=[];e.title!==null&&t.push(e.title),e.head.length>0&&t.push(e.head.join(` | `));for(let n of e.rows)t.push(n.join(` | `));return t}}}function x(e,t){let n=[];t.heading&&n.push([e.title,...e.dateText===null?[]:[e.dateText]].join(`
|
|
2
|
+
`));for(let r of e.entries){let e=t.speakers?[`${r.speaker}:`]:[];for(let t of r.blocks)e.push(...b(t));n.push(e.join(`
|
|
3
3
|
`))}return n.join(`
|
|
4
4
|
|
|
5
|
-
`)}export{
|
|
5
|
+
`)}export{y as buildTranscript,x as transcriptToText};
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/chat-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.150.0",
|
|
4
4
|
"description": "The headless Webority Chat engine: the client over the chat routes, the session state machine over message parts, the stream reader, profile resolution with screen narrowing, the default English labels and a fixture client for sandboxes and tests. No DOM and no UI.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@webority/markdown-core": "^0.171.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@webority/markdown-core": "0.171.
|
|
32
|
+
"@webority/markdown-core": "0.171.2",
|
|
33
33
|
"typescript": "^7.0.2",
|
|
34
34
|
"vite": "^8.1.6",
|
|
35
35
|
"vitest": "5.1.0"
|