@helpai/elements 6.6.0 → 6.6.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/step-display.d.ts CHANGED
@@ -123,8 +123,13 @@ export type StepDecider = 'you' | 'visitor' | 'teamMember' | 'rules';
123
123
  export interface StepDecision {
124
124
  approved: boolean;
125
125
  by: StepDecider;
126
- /** "You approved", "Approved by Sara Kim", "Approved by the visitor", "Approved automatically". */
126
+ /**
127
+ * The mark's words, as short as says who: "Approved" for the reader's own decision and for a named team member (whose
128
+ * picture or initials the surface draws beside it), else who decided ("Visitor approved", "Auto-approved").
129
+ */
127
130
  label: string;
131
+ /** The whole sentence, for hover and screen readers: "You approved", "Approved by Sara Kim". */
132
+ title: string;
128
133
  /** The team member who decided, when it was someone else: a surface shows who they are (their picture, their email). */
129
134
  userId?: string;
130
135
  }
@@ -222,6 +227,7 @@ export interface StepGroupLine {
222
227
  marks: Array<{
223
228
  approved: boolean;
224
229
  label: string;
230
+ title: string;
225
231
  userId?: string;
226
232
  }>;
227
233
  failed: number;
package/step-display.mjs CHANGED
@@ -1,3 +1,3 @@
1
- const e={attach:`Attach files`,file:`File`,attachmentMimeRejected:`{name} isn't a file type this chat accepts.`,attachmentTooLarge:`{name} is too large. Files can be up to {max} together.`,poweredBy:`Powered by {name}`,attachmentTooMany:`The attachment limit is {count}.`,attachmentUploadFailed:`{name} couldn't be uploaded.`,conversationLoading:`Loading chat…`,loadPreviousMessages:`Load previous messages`,close:`Close`,collapse:`Collapse`,collapseSidebar:`Collapse sidebar`,composerPlaceholder:`Type a message…`,dateLastWeek:`Last 7 days`,dateOlder:`Older`,dateToday:`Today`,dateYesterday:`Yesterday`,dropZone:`Drop files to attach`,dropZoneRejected:`These files can't be attached here`,errorGeneric:`Something went wrong`,errorRateLimited:`Too many requests — please try again in a moment.`,errorRateLimitedIn:`Too many requests — please try again in {seconds} s.`,errorOffline:`Can't reach the server. Check your connection and try again.`,errorServer:`Something went wrong on our side. Please try again.`,errorOriginNotAllowed:`This chat isn't set up for this website yet.`,errorMessageTooLong:`That message is too long. Shorten it and send it again.`,errorReconnecting:`Connection lost. Reconnecting…`,errorRetry:`Retry`,expand:`Expand`,expandSidebar:`Expand sidebar`,exitFullscreen:`Exit fullscreen`,fullscreen:`Fullscreen`,history:`History`,historyBack:`Back to chat`,historyEmpty:`No previous chats yet`,historyLoading:`Loading your chats…`,historyContinue:`Continue the chat`,historyTitle:`Chat history`,loadMoreConversations:`Load more conversations`,language:`Language`,launcherOpen:`Open chat`,launcherAsk:`Ask {name}`,micBlocked:`The microphone is blocked for this site, so voice input can't start.`,micStart:`Start voice input`,micStop:`Stop voice input`,moreActions:`More actions`,newConversation:`New chat`,panelTitle:`Chat`,popOut:`Open in new tab`,resizeHandle:`Drag to resize`,scrollToBottom:`Scroll to latest`,send:`Send`,queueMessage:`Queue message`,removeQueuedMessage:`Remove queued message`,removeAttachment:`Remove {name}`,suggestedReplies:`Suggested replies`,compactingContext:`Optimizing conversation context…`,soundOff:`Sound off`,soundOn:`Sound on`,talkToOperator:`Talk to a person`,connectingOperator:`Connecting you to a person…`,noOperatorAvailable:`No one's available right now — leave your details and we'll follow up.`,chattingWithOperator:`You're chatting with {operator}`,operatorBadgeTitle:`Live chat`,chatNotice:`You're chatting with an AI assistant.`,cancelOperatorRequest:`Keep chatting with the AI`,loginPrompt:`Log in for faster, more personalized support`,loginAction:`Log in`,loginRequired:`Log in to chat with us`,loginExpired:`Your login expired. Log in to continue this chat.`,loginExpiredGuest:`Your login expired. Log in to continue this chat, or start a new conversation as a guest.`,startAsGuest:`Start new conversation`,loggedInAs:`Logged in as {name}`,loggedIn:`Logged in`,dismissLoginPrompt:`Hide`,emailTranscript:`Email transcript`,emailTranscriptPrompt:`Get a copy of this conversation by email.`,emailTranscriptEmailLabel:`Email address`,emailTranscriptSend:`Send transcript`,emailTranscriptSending:`Sending…`,emailTranscriptSent:`Sent to {email}.`,emailTranscriptAlreadySent:`This conversation was already emailed. Send a new message to email it again.`,emailTranscriptLimited:`You've reached the limit for now. Try again later.`,emailTranscriptFailed:`Couldn't send it. Try again.`,emailTranscriptNotDelivered:`Couldn't send to this address. Check it and try again.`,emailTranscriptCancel:`Cancel`,emailTranscriptDone:`Done`,stop:`Stop`,theme:`Theme`,themeAuto:`Auto`,themeDark:`Dark`,themeLight:`Light`,textSize:`Text size`,textSizeSmall:`Small`,textSizeNormal:`Normal`,textSizeLarge:`Large`,loading:`Loading…`,visualPreparing:`Preparing visual…`,visualError:`This visual could not be displayed.`,visualPartial:`Some parts of this visual could not be displayed.`,visualSoldOut:`Sold out`,visualCartEmpty:`Your cart is empty.`,visualQuantity:`Qty`,visualChoose:`Choose`,thinking:`Thinking…`,thought:`Thought`,thoughtFor:`Thought for {time}`,toolResult:`Result`,sources:`Sources`,feedbackUp:`Good response`,feedbackDown:`Bad response`,feedbackThanks:`Thanks for your feedback`,copy:`Copy`,copied:`Copied`,copyTicketReference:`Ticket {reference}, copy`,tabHome:`Home`,tabConversations:`Chats`,tabHelp:`Help`,tabNews:`News`,modulesEmpty:`Nothing here yet`,chatUnavailable:`This chat isn't available right now`,moduleBack:`Back`,contentLoading:`Loading…`,contentHelpful:`Was this helpful?`,homeGreeting:`How can we help?`,homeGreetingNamed:`Hi {name} 👋`,homeGreetingLead:`How can we help?`,homeSearchPlaceholder:`Search for help`,homeAskPlaceholder:`Ask a question…`,homeWhatsNew:`What's new`,homeContentTitle:`Popular articles`,homeStatus:`Status`,helpTitle:`Help`,helpSearchPlaceholder:`Search for help`,helpEmpty:`No help articles yet`,helpLoading:`Loading help…`,helpSearchEmpty:`No results for “{query}”`,helpShowMore:`Show more`,newsTitle:`News`,newsEmpty:`No news yet`,newsLoading:`Loading news…`,newsShowMore:`Show more`,newsUnseen:`New post`,unread:`Unread`,formRequired:`This field is required`,formInvalidEmail:`Enter a valid email address`,formInvalidTel:`Enter a valid phone number`,formInvalidNumber:`Enter a valid number`,formOtherPlaceholder:`Type your answer…`,inputRequired:`Questions for you`,askFallbackQuestion:`Please provide the missing information.`,inputBadge:`Questions`,inputAnswered:`Answered`,inputSkipped:`Skipped`,showOptions:`Show options`,hideOptions:`Hide options`,qtypeText:`Your answer`,qtypeEmail:`Email address`,qtypePhone:`Phone number`,qtypeNumber:`Number`,qtypeDate:`Date`,qtypeChooseOne:`Pick one`,qtypeChooseAny:`Pick any`,qtypeBoolean:`Yes / No`,inputSubmit:`Submit answers`,inputSubmitHint:`Enter to send · Shift+Enter = new line`,inputSkip:`Skip`,confirmYes:`Yes`,confirmNo:`No`,approve:`Approve`,decline:`Decline`,changeAnswer:`Change answer`,approvalPrompt:`{action}?`,approvalEditHint:`You can change your answer until this step continues.`,stepInput:`Input`,stepWorking:`Working`,stepWorkingOnIt:`Working on it…`,stepNeedsYourApproval:`Needs your approval`,stepWaitingForVisitor:`Waiting for the visitor`,stepApproved:`Approved`,stepDeclined:`Declined`,stepReplaced:`Replaced`,stepFailed:`Failed`,stepDidNotWork:`Didn't work`,decidedYouApproved:`You approved`,decidedYouDeclined:`You declined`,decidedVisitorApproved:`Approved by the visitor`,decidedVisitorDeclined:`Declined by the visitor`,decidedTeamApproved:`Approved by a team member`,decidedTeamDeclined:`Declined by a team member`,decidedMemberApproved:`Approved by {name}`,decidedMemberDeclined:`Declined by {name}`,stepRawData:`Raw data`,decidedRulesApproved:`Approved automatically`,decidedRulesDeclined:`Declined automatically`,edit:`Edit`,statusError:`Error`,toolStepsFailed:`{count} failed`,statusStopped:`Stopped`,toolStepsStopped:`Stopped after {count} steps`,toolStepsStoppedOne:`Stopped after 1 step`},t={simple:{showSteps:!1,showStepDetails:!1,showStepSystem:!1,showDecidedBy:!1,foldApprovals:!0},technical:{showSteps:!0,showStepDetails:!0,showStepSystem:!0,showDecidedBy:!0,foldApprovals:!0}},n=[`showSteps`,`showStepDetails`,`showStepSystem`,`showDecidedBy`,`foldApprovals`];function r(e){return Object.hasOwn(t,e)}function i(e,n){return{...t[n],...e}}function a(e){return Object.keys(t).filter(r).find(r=>n.every(n=>t[r][n]===e[n]))}const o=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function s(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function c(e){if(e.title)return e.title;let t=e.toolName.replace(/^tool[:-]/,``),n=t.indexOf(`__`);return s(n>0?t.slice(n+2):t)}function l(e,t,n){let r=e.approval;return r?.replacedByMessageId?`replaced`:e.state===`output-available`?n.error===void 0?`done`:`failed`:e.state===`output-error`?t.interrupted?`stopped`:`failed`:e.state===`output-denied`||r?.approved===!1?`declined`:e.state===`approval-responded`||r?.approved===!0?t.cutOff?`stopped`:`approved`:e.state===`approval-requested`?t.submitted?`submitted`:t.cutOff?`stopped`:t.superseded?`replaced`:`waiting`:t.live?`running`:`stopped`}function u(e,t){if(e.isAutomatic)return`rules`;let n=e.respondedBy;return n?.visitorId?`visitor`:n?.userId?n.userId===t.userId?`you`:`teamMember`:t.decides?`you`:`visitor`}function d(e,t,n,r){return e===`teamMember`&&n?r[t?`decidedMemberApproved`:`decidedMemberDeclined`].replace(`{name}`,n):r[f[e][+!t]]}const f={you:[`decidedYouApproved`,`decidedYouDeclined`],visitor:[`decidedVisitorApproved`,`decidedVisitorDeclined`],teamMember:[`decidedTeamApproved`,`decidedTeamDeclined`],rules:[`decidedRulesApproved`,`decidedRulesDeclined`]};function p(e,t){switch(e){case`running`:return t.strings.stepWorking;case`waiting`:return t.reader.decides?t.strings.stepNeedsYourApproval:t.strings.stepWaitingForVisitor;case`submitted`:return t.strings.stepWorkingOnIt;case`approved`:return t.strings.stepApproved;case`declined`:return t.strings.stepDeclined;case`replaced`:return t.strings.stepReplaced;case`stopped`:return t.strings.statusStopped;case`failed`:return t.display.showStepDetails?t.strings.stepFailed:t.strings.stepDidNotWork;case`done`:return``;default:return e}}function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function h(e){return typeof e==`string`?e.trim():typeof e==`number`||typeof e==`boolean`?String(e):``}function g(e){return h(e)||(typeof e==`object`&&e?JSON.stringify(e):``)}function _(e){if(!m(e))return g(e);let[t,...n]=Object.values(e).map(g).filter(Boolean);return t===void 0?``:n.length>0?`${t} (${n.join(`, `)})`:t}function v(e,t){if(!m(e))return[];let n=[];function r(e,i){if(Array.isArray(e)){let t=e.map(_).filter(Boolean).join(`, `);t&&n.push({path:i,value:t});return}if(m(e)){for(let[t,n]of Object.entries(e))r(n,[...i,t]);return}let a=h(e);a&&(t.withIds||!o.test(a))&&n.push({path:i,value:a})}r(e,[]);let i=n.map(({path:e})=>s(e.at(-1)??``));return n.map(({path:e,value:t},n)=>{let r=i[n]??``;return{label:i.filter(e=>e===r).length>1&&e.length>1?`${s(e.at(-2)??``)} · ${r.toLowerCase()}`:r,value:t}})}function y(e){if(m(e))return Object.values(e).find(e=>typeof e==`string`&&e.trim().length>0&&!o.test(e.trim()))?.trim()}function b(e,t=1/0){if(e==null)return;let n=typeof e==`string`?e:JSON.stringify(e,null,2);if(n&&n!==`{}`&&n!==`[]`&&n!==`""`)return n.length>t?`${n.slice(0,t)}…`:n}function x(e){let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function S(e){if(m(e)&&e.storage===`tool-result-ref`&&`summary`in e)return{value:e.summary};if(m(e)&&Array.isArray(e.content)){let t=e.content.flatMap(e=>m(e)&&typeof e.text==`string`?[e.text]:[]).join(`
2
- `),n=m(e.structuredContent)?e.structuredContent:x(t);return e.isError===!0?{value:n,error:m(n)&&typeof n.error==`string`?n.error:t}:{value:n}}return m(e)&&typeof e.error==`string`&&typeof e.instruction==`string`?{value:e,error:e.error}:{value:e}}function C(e){return b(e.input)!==void 0||b(e.output)!==void 0||!!e.errorText}function w(e,t,n){let{display:r}=n,i=e.approval;if(typeof e.toolMetadata?.card==`string`&&i)return`card`;let a=i!==void 0&&!i.isAutomatic;if(a&&T(e,n.turn))return`card`;let o=t.decision?.by===`you`||a&&t.decision===void 0&&n.reader.decides;return a&&o?r.foldApprovals?`step`:`card`:a?r.showSteps||r.showDecidedBy?r.foldApprovals?`step`:`card`:`hidden`:i?.isAutomatic?r.showSteps||r.showDecidedBy?`step`:`hidden`:r.showSteps&&C(e)?`step`:`hidden`}function T(e,t){return e.approval?.replacedByMessageId||(t.superseded||t.cutOff)&&e.approval?.approved===void 0?!1:e.state===`approval-requested`||e.state===`approval-responded`}function E(e,t){let{turn:n,reader:r,display:i,strings:a}=t,o=S(e.output),s=l(e,n,o),f=e.approval,m=f?.replacedByMessageId?void 0:f?.approved,h=f&&m!==void 0?u(f,r):void 0,g=h===`teamMember`?f?.respondedBy?.userId:void 0,_=h&&m!==void 0&&(h===`you`||i.showDecidedBy)?{approved:m,by:h,label:d(h,m,g&&t.names?.get(g),a),...g?{userId:g}:{}}:void 0,x=c(e),C=typeof e.toolMetadata?.system==`string`&&(i.showStepSystem||e.toolMetadata.nameShared===!0)?e.toolMetadata.system:void 0,E=y(e.input),O=e.errorText??o.error,k=i.showStepDetails&&o.error===void 0?v(o.value,{withIds:!0}):[],A=i.showStepDetails?{input:b(e.input),output:b(o.value,4e3)}:void 0,j=f!==void 0&&!f.isAutomatic&&!e.toolMetadata?.card,M={toolCallId:e.toolCallId,placement:`hidden`,...typeof e.toolMetadata?.card==`string`&&f?{card:e.toolMetadata.card}:{},name:x,...C?{system:C}:{},status:s,statusLabel:p(s,{reader:r,display:i,strings:a}),..._?{decision:_}:{},..._?.by===`rules`&&f?.reason?{reason:f.reason}:{},...E?{summary:E}:{},fields:v(e.input,{withIds:i.showStepDetails||f!==void 0&&!f.isAutomatic&&T(e,n)}),...k.length>0?{resultFields:k}:{},...O&&i.showStepDetails?{error:O}:{},...A?{raw:A}:{},...j?{approval:D(e,s,{turn:n,reader:r,strings:a,name:x})}:{}};return{...M,placement:w(e,M,{turn:n,reader:r,display:i})}}function D(e,t,n){let r=n.strings.approvalPrompt.replace(`{action}`,n.name);return t===`waiting`?{ask:r,buttons:n.reader.decides?`decide`:`none`}:t===`submitted`||!T(e,n.turn)?{ask:r,buttons:`none`}:n.turn.canAct&&n.reader.decides?{ask:r,buttons:`change`,note:n.strings.approvalEditHint}:t===`approved`?{ask:r,buttons:`none`,note:n.strings.stepWorkingOnIt}:{ask:r,buttons:`none`}}function O(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n.name,(t.get(n.name)??0)+1);let n=/* @__PURE__ */ new Map;for(let{decision:t}of e){if(!t)continue;let e=n.get(t.label)??{approved:t.approved,label:t.label,...t.userId?{userId:t.userId}:{},count:0};n.set(t.label,{...e,count:e.count+1})}let[r]=e,i=e.some(e=>e.status===`stopped`);return{tools:[...t].map(([e,t])=>({name:e,count:t})),...e.length===1&&r?{single:{name:r.name,...r.system?{system:r.system}:{},...r.summary?{summary:r.summary}:{},...k(r)}}:{},marks:[...n.values()].map(({count:e,...t})=>Object.assign(t,{label:e>1?`${t.label} ×${e}`:t.label})),failed:e.filter(e=>e.status===`failed`).length,...i?{stopped:{finished:e.filter(e=>e.status!==`stopped`).length}}:{}}}function k(e){return!e.decision&&(e.status===`replaced`||e.status===`declined`)?{outcome:e.statusLabel}:{}}function A(e,t){return e===0?t.statusStopped:e===1?t.toolStepsStoppedOne:t.toolStepsStopped.replace(`{count}`,String(e))}const j=e;export{n as STEP_DISPLAY_KEYS,t as STEP_DISPLAY_PRESETS,j as STEP_STRINGS_EN,r as isStepDisplayPreset,a as matchStepDisplayPreset,s as nameInWords,b as rawText,i as resolveStepDisplay,E as stepCallView,v as stepFields,O as stepGroupLine,c as stepName,S as stepResult,A as stoppedLineLabel};
1
+ const e={attach:`Attach files`,file:`File`,attachmentMimeRejected:`{name} isn't a file type this chat accepts.`,attachmentTooLarge:`{name} is too large. Files can be up to {max} together.`,poweredBy:`Powered by {name}`,attachmentTooMany:`The attachment limit is {count}.`,attachmentUploadFailed:`{name} couldn't be uploaded.`,conversationLoading:`Loading chat…`,loadPreviousMessages:`Load previous messages`,close:`Close`,collapse:`Collapse`,collapseSidebar:`Collapse sidebar`,composerPlaceholder:`Type a message…`,dateLastWeek:`Last 7 days`,dateOlder:`Older`,dateToday:`Today`,dateYesterday:`Yesterday`,dropZone:`Drop files to attach`,dropZoneRejected:`These files can't be attached here`,errorGeneric:`Something went wrong`,errorRateLimited:`Too many requests — please try again in a moment.`,errorRateLimitedIn:`Too many requests — please try again in {seconds} s.`,errorOffline:`Can't reach the server. Check your connection and try again.`,errorServer:`Something went wrong on our side. Please try again.`,errorOriginNotAllowed:`This chat isn't set up for this website yet.`,errorMessageTooLong:`That message is too long. Shorten it and send it again.`,errorReconnecting:`Connection lost. Reconnecting…`,errorRetry:`Retry`,expand:`Expand`,expandSidebar:`Expand sidebar`,exitFullscreen:`Exit fullscreen`,fullscreen:`Fullscreen`,history:`History`,historyBack:`Back to chat`,historyEmpty:`No previous chats yet`,historyLoading:`Loading your chats…`,historyContinue:`Continue the chat`,historyTitle:`Chat history`,loadMoreConversations:`Load more conversations`,language:`Language`,launcherOpen:`Open chat`,launcherAsk:`Ask {name}`,micBlocked:`The microphone is blocked for this site, so voice input can't start.`,micStart:`Start voice input`,micStop:`Stop voice input`,moreActions:`More actions`,newConversation:`New chat`,panelTitle:`Chat`,popOut:`Open in new tab`,resizeHandle:`Drag to resize`,scrollToBottom:`Scroll to latest`,send:`Send`,queueMessage:`Queue message`,removeQueuedMessage:`Remove queued message`,removeAttachment:`Remove {name}`,suggestedReplies:`Suggested replies`,compactingContext:`Optimizing conversation context…`,soundOff:`Sound off`,soundOn:`Sound on`,talkToOperator:`Talk to a person`,connectingOperator:`Connecting you to a person…`,noOperatorAvailable:`No one's available right now — leave your details and we'll follow up.`,chattingWithOperator:`You're chatting with {operator}`,operatorBadgeTitle:`Live chat`,chatNotice:`You're chatting with an AI assistant.`,cancelOperatorRequest:`Keep chatting with the AI`,loginPrompt:`Log in for faster, more personalized support`,loginAction:`Log in`,loginRequired:`Log in to chat with us`,loginExpired:`Your login expired. Log in to continue this chat.`,loginExpiredGuest:`Your login expired. Log in to continue this chat, or start a new conversation as a guest.`,startAsGuest:`Start new conversation`,loggedInAs:`Logged in as {name}`,loggedIn:`Logged in`,dismissLoginPrompt:`Hide`,emailTranscript:`Email transcript`,emailTranscriptPrompt:`Get a copy of this conversation by email.`,emailTranscriptEmailLabel:`Email address`,emailTranscriptSend:`Send transcript`,emailTranscriptSending:`Sending…`,emailTranscriptSent:`Sent to {email}.`,emailTranscriptAlreadySent:`This conversation was already emailed. Send a new message to email it again.`,emailTranscriptLimited:`You've reached the limit for now. Try again later.`,emailTranscriptFailed:`Couldn't send it. Try again.`,emailTranscriptNotDelivered:`Couldn't send to this address. Check it and try again.`,emailTranscriptCancel:`Cancel`,emailTranscriptDone:`Done`,stop:`Stop`,theme:`Theme`,themeAuto:`Auto`,themeDark:`Dark`,themeLight:`Light`,textSize:`Text size`,textSizeSmall:`Small`,textSizeNormal:`Normal`,textSizeLarge:`Large`,loading:`Loading…`,visualPreparing:`Preparing visual…`,visualError:`This visual could not be displayed.`,visualPartial:`Some parts of this visual could not be displayed.`,visualSoldOut:`Sold out`,visualCartEmpty:`Your cart is empty.`,visualQuantity:`Qty`,visualChoose:`Choose`,thinking:`Thinking…`,thought:`Thought`,thoughtFor:`Thought for {time}`,toolResult:`Result`,sources:`Sources`,feedbackUp:`Good response`,feedbackDown:`Bad response`,feedbackThanks:`Thanks for your feedback`,copy:`Copy`,copied:`Copied`,copyTicketReference:`Ticket {reference}, copy`,tabHome:`Home`,tabConversations:`Chats`,tabHelp:`Help`,tabNews:`News`,modulesEmpty:`Nothing here yet`,chatUnavailable:`This chat isn't available right now`,moduleBack:`Back`,contentLoading:`Loading…`,contentHelpful:`Was this helpful?`,homeGreeting:`How can we help?`,homeGreetingNamed:`Hi {name} 👋`,homeGreetingLead:`How can we help?`,homeSearchPlaceholder:`Search for help`,homeAskPlaceholder:`Ask a question…`,homeWhatsNew:`What's new`,homeContentTitle:`Popular articles`,homeStatus:`Status`,helpTitle:`Help`,helpSearchPlaceholder:`Search for help`,helpEmpty:`No help articles yet`,helpLoading:`Loading help…`,helpSearchEmpty:`No results for “{query}”`,helpShowMore:`Show more`,newsTitle:`News`,newsEmpty:`No news yet`,newsLoading:`Loading news…`,newsShowMore:`Show more`,newsUnseen:`New post`,unread:`Unread`,formRequired:`This field is required`,formInvalidEmail:`Enter a valid email address`,formInvalidTel:`Enter a valid phone number`,formInvalidNumber:`Enter a valid number`,formOtherPlaceholder:`Type your answer…`,inputRequired:`Questions for you`,askFallbackQuestion:`Please provide the missing information.`,inputBadge:`Questions`,inputAnswered:`Answered`,inputSkipped:`Skipped`,showOptions:`Show options`,hideOptions:`Hide options`,qtypeText:`Your answer`,qtypeEmail:`Email address`,qtypePhone:`Phone number`,qtypeNumber:`Number`,qtypeDate:`Date`,qtypeChooseOne:`Pick one`,qtypeChooseAny:`Pick any`,qtypeBoolean:`Yes / No`,inputSubmit:`Submit answers`,inputSubmitHint:`Enter to send · Shift+Enter = new line`,inputSkip:`Skip`,confirmYes:`Yes`,confirmNo:`No`,approve:`Approve`,decline:`Decline`,changeAnswer:`Change answer`,approvalPrompt:`{action}?`,approvalEditHint:`You can change your answer until this step continues.`,stepInput:`Input`,stepWorking:`Working`,stepWorkingOnIt:`Working on it…`,stepNeedsYourApproval:`Needs your approval`,stepWaitingForVisitor:`Waiting for the visitor`,stepApproved:`Approved`,stepDeclined:`Declined`,stepReplaced:`Replaced`,stepFailed:`Failed`,stepDidNotWork:`Didn't work`,decidedYouApproved:`You approved`,decidedYouDeclined:`You declined`,decidedVisitorApproved:`Visitor approved`,decidedVisitorDeclined:`Visitor declined`,decidedTeamApproved:`Approved by a team member`,decidedTeamDeclined:`Declined by a team member`,decidedMemberApproved:`Approved by {name}`,decidedMemberDeclined:`Declined by {name}`,stepRawData:`Raw data`,decidedRulesApproved:`Auto-approved`,decidedRulesDeclined:`Auto-declined`,edit:`Edit`,statusError:`Error`,toolStepsFailed:`{count} failed`,statusStopped:`Stopped`,toolStepsStopped:`Stopped after {count} steps`,toolStepsStoppedOne:`Stopped after 1 step`},t={simple:{showSteps:!1,showStepDetails:!1,showStepSystem:!1,showDecidedBy:!1,foldApprovals:!0},technical:{showSteps:!0,showStepDetails:!0,showStepSystem:!0,showDecidedBy:!0,foldApprovals:!0}},n=[`showSteps`,`showStepDetails`,`showStepSystem`,`showDecidedBy`,`foldApprovals`];function r(e){return Object.hasOwn(t,e)}function i(e,n){return{...t[n],...e}}function a(e){return Object.keys(t).filter(r).find(r=>n.every(n=>t[r][n]===e[n]))}const o=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function s(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function c(e){if(e.title)return e.title;let t=e.toolName.replace(/^tool[:-]/,``),n=t.indexOf(`__`);return s(n>0?t.slice(n+2):t)}function l(e,t,n){let r=e.approval;return r?.replacedByMessageId?`replaced`:e.state===`output-available`?n.error===void 0?`done`:`failed`:e.state===`output-error`?t.interrupted?`stopped`:`failed`:e.state===`output-denied`||r?.approved===!1?`declined`:e.state===`approval-responded`||r?.approved===!0?t.cutOff?`stopped`:`approved`:e.state===`approval-requested`?t.submitted?`submitted`:t.cutOff?`stopped`:t.superseded?`replaced`:`waiting`:t.live?`running`:`stopped`}function u(e,t){if(e.isAutomatic)return`rules`;let n=e.respondedBy;return n?.visitorId?`visitor`:n?.userId?n.userId===t.userId?`you`:`teamMember`:t.decides?`you`:`visitor`}function d(e,t,n,r){let i=r[t?`stepApproved`:`stepDeclined`];if(e===`teamMember`&&n)return{label:i,title:r[t?`decidedMemberApproved`:`decidedMemberDeclined`].replace(`{name}`,n)};let a=r[f[e][+!t]];return e===`you`?{label:i,title:a}:{label:a,title:a}}const f={you:[`decidedYouApproved`,`decidedYouDeclined`],visitor:[`decidedVisitorApproved`,`decidedVisitorDeclined`],teamMember:[`decidedTeamApproved`,`decidedTeamDeclined`],rules:[`decidedRulesApproved`,`decidedRulesDeclined`]};function p(e,t){switch(e){case`running`:return t.strings.stepWorking;case`waiting`:return t.reader.decides?t.strings.stepNeedsYourApproval:t.strings.stepWaitingForVisitor;case`submitted`:return t.strings.stepWorkingOnIt;case`approved`:return t.strings.stepApproved;case`declined`:return t.strings.stepDeclined;case`replaced`:return t.strings.stepReplaced;case`stopped`:return t.strings.statusStopped;case`failed`:return t.display.showStepDetails?t.strings.stepFailed:t.strings.stepDidNotWork;case`done`:return``;default:return e}}function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function h(e){return typeof e==`string`?e.trim():typeof e==`number`||typeof e==`boolean`?String(e):``}function g(e){return h(e)||(typeof e==`object`&&e?JSON.stringify(e):``)}function _(e){if(!m(e))return g(e);let[t,...n]=Object.values(e).map(g).filter(Boolean);return t===void 0?``:n.length>0?`${t} (${n.join(`, `)})`:t}function v(e,t){if(!m(e))return[];let n=[];function r(e,i){if(Array.isArray(e)){let t=e.map(_).filter(Boolean).join(`, `);t&&n.push({path:i,value:t});return}if(m(e)){for(let[t,n]of Object.entries(e))r(n,[...i,t]);return}let a=h(e);a&&(t.withIds||!o.test(a))&&n.push({path:i,value:a})}r(e,[]);let i=n.map(({path:e})=>s(e.at(-1)??``));return n.map(({path:e,value:t},n)=>{let r=i[n]??``;return{label:i.filter(e=>e===r).length>1&&e.length>1?`${s(e.at(-2)??``)} · ${r.toLowerCase()}`:r,value:t}})}function y(e){if(m(e))return Object.values(e).find(e=>typeof e==`string`&&e.trim().length>0&&!o.test(e.trim()))?.trim()}function b(e,t=1/0){if(e==null)return;let n=typeof e==`string`?e:JSON.stringify(e,null,2);if(n&&n!==`{}`&&n!==`[]`&&n!==`""`)return n.length>t?`${n.slice(0,t)}…`:n}function x(e){let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function S(e){if(m(e)&&e.storage===`tool-result-ref`&&`summary`in e)return{value:e.summary};if(m(e)&&Array.isArray(e.content)){let t=e.content.flatMap(e=>m(e)&&typeof e.text==`string`?[e.text]:[]).join(`
2
+ `),n=m(e.structuredContent)?e.structuredContent:x(t);return e.isError===!0?{value:n,error:m(n)&&typeof n.error==`string`?n.error:t}:{value:n}}return m(e)&&typeof e.error==`string`&&typeof e.instruction==`string`?{value:e,error:e.error}:{value:e}}function C(e){return b(e.input)!==void 0||b(e.output)!==void 0||!!e.errorText}function w(e,t,n){let{display:r}=n,i=e.approval;if(typeof e.toolMetadata?.card==`string`&&i)return`card`;let a=i!==void 0&&!i.isAutomatic;if(a&&T(e,n.turn))return`card`;let o=t.decision?.by===`you`||a&&t.decision===void 0&&n.reader.decides;return a&&o?r.foldApprovals?`step`:`card`:a?r.showSteps||r.showDecidedBy?r.foldApprovals?`step`:`card`:`hidden`:i?.isAutomatic?r.showSteps||r.showDecidedBy?`step`:`hidden`:r.showSteps&&C(e)?`step`:`hidden`}function T(e,t){return e.approval?.replacedByMessageId||(t.superseded||t.cutOff)&&e.approval?.approved===void 0?!1:e.state===`approval-requested`||e.state===`approval-responded`}function E(e,t){let{turn:n,reader:r,display:i,strings:a}=t,o=S(e.output),s=l(e,n,o),f=e.approval,m=f?.replacedByMessageId?void 0:f?.approved,h=f&&m!==void 0?u(f,r):void 0,g=h===`teamMember`?f?.respondedBy?.userId:void 0,_=h&&m!==void 0&&(h===`you`||i.showDecidedBy)?{approved:m,by:h,...d(h,m,g&&t.names?.get(g),a),...g?{userId:g}:{}}:void 0,x=c(e),C=typeof e.toolMetadata?.system==`string`&&(i.showStepSystem||e.toolMetadata.nameShared===!0)?e.toolMetadata.system:void 0,E=y(e.input),O=e.errorText??o.error,k=i.showStepDetails&&o.error===void 0?v(o.value,{withIds:!0}):[],A=i.showStepDetails?{input:b(e.input),output:b(o.value,4e3)}:void 0,j=f!==void 0&&!f.isAutomatic&&!e.toolMetadata?.card,M={toolCallId:e.toolCallId,placement:`hidden`,...typeof e.toolMetadata?.card==`string`&&f?{card:e.toolMetadata.card}:{},name:x,...C?{system:C}:{},status:s,statusLabel:p(s,{reader:r,display:i,strings:a}),..._?{decision:_}:{},..._?.by===`rules`&&f?.reason?{reason:f.reason}:{},...E?{summary:E}:{},fields:v(e.input,{withIds:i.showStepDetails||f!==void 0&&!f.isAutomatic&&T(e,n)}),...k.length>0?{resultFields:k}:{},...O&&i.showStepDetails?{error:O}:{},...A?{raw:A}:{},...j?{approval:D(e,s,{turn:n,reader:r,strings:a,name:x})}:{}};return{...M,placement:w(e,M,{turn:n,reader:r,display:i})}}function D(e,t,n){let r=n.strings.approvalPrompt.replace(`{action}`,n.name);return t===`waiting`?{ask:r,buttons:n.reader.decides?`decide`:`none`}:t===`submitted`||!T(e,n.turn)?{ask:r,buttons:`none`}:n.turn.canAct&&n.reader.decides?{ask:r,buttons:`change`,note:n.strings.approvalEditHint}:t===`approved`?{ask:r,buttons:`none`,note:n.strings.stepWorkingOnIt}:{ask:r,buttons:`none`}}function O(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n.name,(t.get(n.name)??0)+1);let n=/* @__PURE__ */ new Map;for(let{decision:t}of e){if(!t)continue;let e=n.get(t.title)??{approved:t.approved,label:t.label,title:t.title,...t.userId?{userId:t.userId}:{},count:0};n.set(t.title,{...e,count:e.count+1})}let[r]=e,i=e.some(e=>e.status===`stopped`);return{tools:[...t].map(([e,t])=>({name:e,count:t})),...e.length===1&&r?{single:{name:r.name,...r.system?{system:r.system}:{},...r.summary?{summary:r.summary}:{},...k(r)}}:{},marks:[...n.values()].map(({count:e,...t})=>Object.assign(t,{label:e>1?`${t.label} ×${e}`:t.label})),failed:e.filter(e=>e.status===`failed`).length,...i?{stopped:{finished:e.filter(e=>e.status!==`stopped`).length}}:{}}}function k(e){return!e.decision&&(e.status===`replaced`||e.status===`declined`)?{outcome:e.statusLabel}:{}}function A(e,t){return e===0?t.statusStopped:e===1?t.toolStepsStoppedOne:t.toolStepsStopped.replace(`{count}`,String(e))}const j=e;export{n as STEP_DISPLAY_KEYS,t as STEP_DISPLAY_PRESETS,j as STEP_STRINGS_EN,r as isStepDisplayPreset,a as matchStepDisplayPreset,s as nameInWords,b as rawText,i as resolveStepDisplay,E as stepCallView,v as stepFields,O as stepGroupLine,c as stepName,S as stepResult,A as stoppedLineLabel};
3
3
  //# sourceMappingURL=step-display.mjs.map