refactor: rebrand from cs-agent to BossChat

- Rename Go module: cs-agent → bosschat
- Rename all import paths across 200+ Go files
- Rename SDK: cs-ai-agent-sdk → bosschat-sdk
- Rename message protocol: cs-agent:* → bosschat:*
- Rename JS globals: CSAgentConfig → BossChatConfig
- Rename CSS classes: cs-agent-* → bosschat-*
- Update Makefile APP_NAME and ARCHIVE_NAME
- Update logo assets
- Fix display name: BoosChat → BossChat
This commit is contained in:
Aibo117
2026-05-26 13:17:07 +08:00
parent 0eb804d9d7
commit 0f40930a41
389 changed files with 1242 additions and 1242 deletions
@@ -712,7 +712,7 @@ function WebAccessGuide({ channelId }: { channelId: string }) {
channelId: "${channelId}"
};
</script>
<script async src="${origin}/sdk/cs-ai-agent-sdk.min.js"></script>`
<script async src="${origin}/sdk/bosschat-sdk.min.js"></script>`
}, [channelId, origin])
async function copyText(text: string, successMessage: string) {
@@ -343,7 +343,7 @@ export function ChatPanel() {
const messagesScroll = (
<div
ref={messagesContainerRef}
className="h-full min-h-0 flex-1 overflow-y-auto p-4 cs-agent-scrollbar"
className="h-full min-h-0 flex-1 overflow-y-auto p-4 bosschat-scrollbar"
>
<div ref={messagesContentRef} className="flex flex-col">
{!loading && messages.length > 0 && messagesHasMore ? (
+4 -4
View File
@@ -16,7 +16,7 @@ export default function LoginPage() {
</div>
<div className="space-y-3">
<h2 className="max-w-lg text-5xl font-semibold tracking-tight">
BoosChat
BossChat
</h2>
<p className="max-w-xl text-sm leading-6 text-white/72">
懂问题,更懂用户;快响应,更能落地。
@@ -49,13 +49,13 @@ export default function LoginPage() {
<div className="flex justify-center gap-2 md:justify-start">
<Link href="/dashboard/login" className="flex items-center gap-2 font-medium">
<img
src="/images/logo.svg"
alt="BoosChat"
src="/images/logo.png"
alt="BossChat"
width="32"
height="32"
className="size-7 shrink-0 object-contain"
/>
BoosChat
BossChat
</Link>
</div>
<div className="flex flex-1 items-center justify-center">
+2 -2
View File
@@ -23,8 +23,8 @@ const geistMono = Geist_Mono({
})
export const metadata: Metadata = {
title: "BoosChat",
description: "BoosChat 智能客服系统",
title: "BossChat",
description: "BossChat 智能客服系统",
}
export default function RootLayout({
+3 -3
View File
@@ -48,13 +48,13 @@ export function AppSidebar({ ...props }: ComponentProps<typeof Sidebar>) {
render={<Link href="/dashboard" />}
>
<img
src="/images/logo.svg"
alt="BoosChat"
src="/images/logo.png"
alt="BossChat"
width="32"
height="32"
className="size-7 shrink-0 object-contain"
/>
<span className="text-base font-semibold">BoosChat</span>
<span className="text-base font-semibold">BossChat</span>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
@@ -441,9 +441,9 @@ export function SharedMessageEditor({
function getEditorClassName(variant: SharedMessageEditorVariant) {
if (variant === "customer") {
return "cs-agent-scrollbar min-h-12 max-h-40 overflow-y-auto px-1.5 py-1 text-sm leading-6 text-foreground outline-none [&_p]:m-0 [&_p+*]:mt-2 [&_.cs-agent-editor-image-wrap]:my-2 [&_.cs-agent-editor-image]:max-h-64 [&_.cs-agent-editor-image]:max-w-full [&_.cs-agent-editor-image]:rounded-lg [&_.cs-agent-editor-image]:object-contain [&_.cs-agent-editor-image-wrap-uploading_.cs-agent-editor-image]:opacity-55"
return "bosschat-scrollbar min-h-12 max-h-40 overflow-y-auto px-1.5 py-1 text-sm leading-6 text-foreground outline-none [&_p]:m-0 [&_p+*]:mt-2 [&_.bosschat-editor-image-wrap]:my-2 [&_.bosschat-editor-image]:max-h-64 [&_.bosschat-editor-image]:max-w-full [&_.bosschat-editor-image]:rounded-lg [&_.bosschat-editor-image]:object-contain [&_.bosschat-editor-image-wrap-uploading_.bosschat-editor-image]:opacity-55"
}
return "h-full min-h-12 max-h-[20vh] overflow-y-auto px-1.5 py-1 text-sm leading-6 text-foreground outline-none sm:max-h-none [&_.ProseMirror-focused]:outline-none [&_p]:m-0 [&_p+.cs-agent-editor-image-wrap]:mt-2 [&_.cs-agent-editor-image-wrap]:my-2 [&_.cs-agent-editor-image]:max-h-64 [&_.cs-agent-editor-image]:max-w-full [&_.cs-agent-editor-image]:rounded-md [&_.cs-agent-editor-image]:object-contain [&_.cs-agent-editor-image-wrap-uploading_.cs-agent-editor-image]:opacity-55 [&_p.is-editor-empty:first-child]:before:text-muted-foreground"
return "h-full min-h-12 max-h-[20vh] overflow-y-auto px-1.5 py-1 text-sm leading-6 text-foreground outline-none sm:max-h-none [&_.ProseMirror-focused]:outline-none [&_p]:m-0 [&_p+.bosschat-editor-image-wrap]:mt-2 [&_.bosschat-editor-image-wrap]:my-2 [&_.bosschat-editor-image]:max-h-64 [&_.bosschat-editor-image]:max-w-full [&_.bosschat-editor-image]:rounded-md [&_.bosschat-editor-image]:object-contain [&_.bosschat-editor-image-wrap-uploading_.bosschat-editor-image]:opacity-55 [&_p.is-editor-empty:first-child]:before:text-muted-foreground"
}
function getToolbarClassName(variant: SharedMessageEditorVariant) {
+1 -1
View File
@@ -214,7 +214,7 @@ export const KefuMessageList = forwardRef<KefuMessageListHandle, KefuMessageList
return (
<div
ref={containerRef}
className="cs-agent-scrollbar flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4"
className="bosschat-scrollbar flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4"
>
<div ref={contentRef} className="flex flex-col gap-4">
{hasMoreOlder && onLoadOlder ? (
+6 -6
View File
@@ -6,7 +6,7 @@ import { useEffect, useMemo, useState } from "react"
import type { CSAgentConfig } from "@/lib/sdk/config-types"
const STORAGE_KEY = "cs-agent-web-widget-test-config"
const STORAGE_KEY = "bosschat-web-widget-test-config"
const DEFAULT_JWT_TTL_MINUTES = "30"
const INITIAL_CONFIG: CSAgentConfig = {
channelId: "",
@@ -55,7 +55,7 @@ function removeMountedWidget() {
window.CSAgentWidget?.destroy()
document
.querySelectorAll(
'[data-cs-agent-widget="launcher"], [data-cs-agent-widget="frame"], [data-cs-agent-widget="script"]'
'[data-bosschat-widget="launcher"], [data-bosschat-widget="frame"], [data-bosschat-widget="script"]'
)
.forEach((node) => node.remove())
@@ -71,8 +71,8 @@ function injectWidget(config: CSAgentConfig) {
const script = document.createElement("script")
script.async = true
script.src = `${window.location.origin}/sdk/cs-ai-agent-sdk.min.js`
script.dataset.csAgentWidget = "script"
script.src = `${window.location.origin}/sdk/bosschat-sdk.min.js`
script.dataset.bossChatWidget = "script"
document.body.appendChild(script)
}
@@ -182,8 +182,8 @@ export function KefuWidgetDemo() {
const snippet = useMemo(() => {
const scriptSrc = origin
? `${origin}/sdk/cs-ai-agent-sdk.min.js`
: "/sdk/cs-ai-agent-sdk.min.js"
? `${origin}/sdk/bosschat-sdk.min.js`
: "/sdk/bosschat-sdk.min.js"
const configLines = [` channelId: "${config.channelId || ""}"`]
if (config.authMode === "jwt") {
+2 -2
View File
@@ -84,9 +84,9 @@ export function LoginForm({
<FieldGroup>
<div className="flex flex-col gap-2 text-center">
<span className="mx-auto inline-flex rounded-full border border-amber-300/60 bg-amber-50 px-3 py-1 text-[11px] font-medium tracking-[0.22em] text-amber-900 uppercase">
BoosChat
BossChat
</span>
<h1 className="text-3xl font-semibold tracking-tight">欢迎使用 BoosChat 客服平台</h1>
<h1 className="text-3xl font-semibold tracking-tight">欢迎使用 BossChat 客服平台</h1>
</div>
<Field>
<FieldLabel htmlFor="username">用户名</FieldLabel>
+2 -2
View File
@@ -129,8 +129,8 @@ export type ImCustomerSession = ImCustomerSessionExchangeResponse & {
channelId: string
}
const GUEST_STORAGE_KEY = "cs_agent_im_guest_id"
const CUSTOMER_SESSION_STORAGE_KEY = "cs_agent_customer_session"
const GUEST_STORAGE_KEY = "bosschat_im_guest_id"
const CUSTOMER_SESSION_STORAGE_KEY = "bosschat_customer_session"
const CUSTOMER_SESSION_TOKEN_HEADER = "X-Customer-Session-Token"
const CUSTOMER_SESSION_EXPIRES_HEADER = "X-Customer-Session-Expires-At"
const API_BASE_URL =
+2 -2
View File
@@ -15,8 +15,8 @@ export type AuthSession = {
roles: string[]
}
const SESSION_STORAGE_KEY = "cs-ai-agent-session"
export const AUTH_SESSION_EXPIRED_EVENT = "cs-ai-agent-auth-expired"
const SESSION_STORAGE_KEY = "bosschat-session"
export const AUTH_SESSION_EXPIRED_EVENT = "bosschat-auth-expired"
function hasWindow() {
return typeof window !== "undefined"
+9 -9
View File
@@ -30,15 +30,15 @@ export const MessageImageExtension = Image.extend({
return ({ node }) => {
const wrapper = document.createElement("span")
wrapper.className =
"cs-agent-editor-image-wrap relative inline-block max-w-full align-middle"
"bosschat-editor-image-wrap relative inline-block max-w-full align-middle"
const image = document.createElement("img")
image.className = "cs-agent-editor-image"
image.className = "bosschat-editor-image"
image.draggable = true
const overlay = document.createElement("span")
overlay.className =
"cs-agent-editor-image-loading pointer-events-none absolute inset-0 hidden items-center justify-center rounded-lg bg-background/55 backdrop-blur-[1px]"
"bosschat-editor-image-loading pointer-events-none absolute inset-0 hidden items-center justify-center rounded-lg bg-background/55 backdrop-blur-[1px]"
const spinner = document.createElement("span")
spinner.className =
@@ -115,10 +115,10 @@ export function markEditorImageUploadedByTitle(
image.setAttribute("data-provider", uploaded.provider)
image.setAttribute("data-storage-key", uploaded.storageKey)
image.setAttribute("alt", uploaded.filename || image.getAttribute("alt") || "image")
image.classList.remove("cs-agent-editor-image-uploading")
image.classList.remove("bosschat-editor-image-uploading")
image.removeAttribute("data-uploading")
image.removeAttribute("title")
setImageUploading(image.closest(".cs-agent-editor-image-wrap"), false)
setImageUploading(image.closest(".bosschat-editor-image-wrap"), false)
}
export function setEditorImageUploadingByTitle(editor: Editor, title: string) {
@@ -126,9 +126,9 @@ export function setEditorImageUploadingByTitle(editor: Editor, title: string) {
if (!image) {
return
}
image.classList.add("cs-agent-editor-image-uploading")
image.classList.add("bosschat-editor-image-uploading")
image.setAttribute("data-uploading", "true")
setImageUploading(image.closest(".cs-agent-editor-image-wrap"), true)
setImageUploading(image.closest(".bosschat-editor-image-wrap"), true)
}
export function buildSendableEditorHTML(
@@ -223,8 +223,8 @@ function setImageUploading(wrapper: Element | null, uploading: boolean) {
if (!(wrapper instanceof HTMLElement)) {
return
}
wrapper.classList.toggle("cs-agent-editor-image-wrap-uploading", uploading)
const overlay = wrapper.querySelector<HTMLElement>(".cs-agent-editor-image-loading")
wrapper.classList.toggle("bosschat-editor-image-wrap-uploading", uploading)
const overlay = wrapper.querySelector<HTMLElement>(".bosschat-editor-image-loading")
if (overlay) {
overlay.classList.toggle("hidden", !uploading)
overlay.classList.toggle("flex", uploading)
+8 -8
View File
@@ -8,14 +8,14 @@ type HostBridgeOptions = {
onMaximizedChange?: (isMaximized: boolean) => void
}
const INIT_MESSAGE_TYPE = "cs-agent:init"
const OPEN_MESSAGE_TYPE = "cs-agent:open"
const MINIMIZE_MESSAGE_TYPE = "cs-agent:minimize"
const MAXIMIZED_MESSAGE_TYPE = "cs-agent:maximized"
const READY_MESSAGE_TYPE = "cs-agent:ready"
const REQUEST_MINIMIZE_MESSAGE_TYPE = "cs-agent:request-minimize"
const REQUEST_CLOSE_MESSAGE_TYPE = "cs-agent:request-close"
const REQUEST_TOGGLE_MAXIMIZE_MESSAGE_TYPE = "cs-agent:request-toggle-maximize"
const INIT_MESSAGE_TYPE = "bosschat:init"
const OPEN_MESSAGE_TYPE = "bosschat:open"
const MINIMIZE_MESSAGE_TYPE = "bosschat:minimize"
const MAXIMIZED_MESSAGE_TYPE = "bosschat:maximized"
const READY_MESSAGE_TYPE = "bosschat:ready"
const REQUEST_MINIMIZE_MESSAGE_TYPE = "bosschat:request-minimize"
const REQUEST_CLOSE_MESSAGE_TYPE = "bosschat:request-close"
const REQUEST_TOGGLE_MAXIMIZE_MESSAGE_TYPE = "bosschat:request-toggle-maximize"
export function bindKefuHostBridge(options: HostBridgeOptions = {}) {
if (typeof window === "undefined") {
@@ -37,14 +37,14 @@ function createElement(tagName) {
}
async function loadSdk(config) {
const source = await readFile(new URL("./cs-ai-agent-sdk.ts", import.meta.url), "utf8")
const source = await readFile(new URL("./bosschat-sdk.ts", import.meta.url), "utf8")
const compiled = ts.transpileModule(source, {
compilerOptions: {
target: ts.ScriptTarget.ES2017,
module: ts.ModuleKind.ESNext,
importsNotUsedAsValues: ts.ImportsNotUsedAsValues.Remove,
},
fileName: "cs-ai-agent-sdk.ts",
fileName: "bosschat-sdk.ts",
})
const body = createElement("body")
const sandbox = {
@@ -62,7 +62,7 @@ async function loadSdk(config) {
document: {
body,
currentScript: {
src: "https://chat.example/sdk/cs-ai-agent-sdk.min.js",
src: "https://chat.example/sdk/bosschat-sdk.min.js",
},
createElement,
createElementNS: (_namespace, tagName) => createElement(tagName),
@@ -127,7 +127,7 @@ test("launcher click creates chat iframe with a freshly resolved userToken", asy
})
await flushPromises()
const launcher = sandbox.document.body.children.find(
(child) => child.dataset.csAgentWidget === "launcher"
(child) => child.dataset.bossChatWidget === "launcher"
)
assert.ok(launcher)
@@ -136,7 +136,7 @@ test("launcher click creates chat iframe with a freshly resolved userToken", asy
await flushPromises()
const frame = sandbox.document.body.children.find(
(child) => child.dataset.csAgentWidget === "frame"
(child) => child.dataset.bossChatWidget === "frame"
)
assert.ok(frame)
@@ -150,14 +150,14 @@ test("chat iframe layout uses dynamic viewport height for iOS browser chrome", a
})
await flushPromises()
const launcher = sandbox.document.body.children.find(
(child) => child.dataset.csAgentWidget === "launcher"
(child) => child.dataset.bossChatWidget === "launcher"
)
launcher.click()
await flushPromises()
const frame = sandbox.document.body.children.find(
(child) => child.dataset.csAgentWidget === "frame"
(child) => child.dataset.bossChatWidget === "frame"
)
assert.ok(frame)
@@ -1,10 +1,10 @@
import type {
CSAgentConfig,
CSAgentWidget,
BossChatConfig,
BossChatWidget,
KefuChatRuntimeConfig,
} from "./config-types"
type NormalizedCSAgentConfig = CSAgentConfig & {
type NormalizedBossChatConfig = BossChatConfig & {
baseUrl: string
channelId: string
position: "left" | "right"
@@ -23,7 +23,7 @@ type WidgetState = {
configLoading: boolean
frameHideTimer: number | null
frameDestroyTimer: number | null
config: NormalizedCSAgentConfig | null
config: NormalizedBossChatConfig | null
frameConfig: KefuChatRuntimeConfig | null
frameUrl: URL | null
animationDuration: number
@@ -33,20 +33,20 @@ type WidgetState = {
type WidgetConfigResponse = {
success?: boolean
data?: Partial<Pick<
CSAgentConfig,
BossChatConfig,
"title" | "subtitle" | "themeColor" | "position" | "width"
>>
}
type FrameMessage =
| { type: "cs-agent:init"; payload: KefuChatRuntimeConfig }
| { type: "cs-agent:open" }
| { type: "cs-agent:minimize" }
| { type: "cs-agent:maximized"; payload: { isMaximized: boolean } }
| { type: "bosschat:init"; payload: KefuChatRuntimeConfig }
| { type: "bosschat:open" }
| { type: "bosschat:minimize" }
| { type: "bosschat:maximized"; payload: { isMaximized: boolean } }
(function () {
const DEFAULT_CONFIG: Pick<
NormalizedCSAgentConfig,
NormalizedBossChatConfig,
"position" | "themeColor" | "width"
> = {
position: "right",
@@ -54,7 +54,7 @@ type FrameMessage =
width: "380px",
}
const existingState = window.__CS_AGENT_WIDGET_STATE__ as WidgetState | undefined
const existingState = window.__BOSSCHAT_WIDGET_STATE__ as WidgetState | undefined
const state: WidgetState =
existingState || {
button: null,
@@ -73,10 +73,10 @@ type FrameMessage =
animationDuration: 260,
}
if (!existingState) {
window.__CS_AGENT_WIDGET_STATE__ = state
window.__BOSSCHAT_WIDGET_STATE__ = state
}
function normalizeConfig(config?: CSAgentConfig): NormalizedCSAgentConfig {
function normalizeConfig(config?: BossChatConfig): NormalizedBossChatConfig {
const merged: Record<string, unknown> = { ...DEFAULT_CONFIG, ...(config || {}) }
merged.baseUrl = String(merged.baseUrl || window.location.origin).replace(/\/$/, "")
if (merged.apiBaseUrl) {
@@ -91,18 +91,18 @@ type FrameMessage =
if (typeof merged.getUserToken !== "function") {
delete merged.getUserToken
}
return merged as NormalizedCSAgentConfig
return merged as NormalizedBossChatConfig
}
function resolveWidgetBaseUrl(config: NormalizedCSAgentConfig) {
function resolveWidgetBaseUrl(config: NormalizedBossChatConfig) {
const currentScript = document.currentScript as HTMLScriptElement | null
if (currentScript?.src) {
return currentScript.src.replace(/\/sdk\/cs-ai-agent-sdk\.min\.js(?:\?.*)?$/, "")
return currentScript.src.replace(/\/sdk\/bosschat-sdk\.min\.js(?:\?.*)?$/, "")
}
return String(config.widgetBaseUrl || config.baseUrl || window.location.origin).replace(/\/$/, "")
}
function createFrameUrl(config: NormalizedCSAgentConfig, userToken: string) {
function createFrameUrl(config: NormalizedBossChatConfig, userToken: string) {
const widgetBaseUrl = resolveWidgetBaseUrl(config)
const frameUrl = new URL(`${widgetBaseUrl}/kefu/chat/`)
frameUrl.searchParams.set("channelId", config.channelId)
@@ -115,7 +115,7 @@ type FrameMessage =
}
function createFrameConfig(
config: NormalizedCSAgentConfig,
config: NormalizedBossChatConfig,
userToken: string
): KefuChatRuntimeConfig {
const { getUserToken: _getUserToken, ...payload } = config
@@ -151,13 +151,13 @@ type FrameMessage =
}
function mergeWidgetConfig(
config: NormalizedCSAgentConfig,
config: NormalizedBossChatConfig,
remoteConfig?: WidgetConfigResponse["data"]
) {
if (!remoteConfig) {
return config
}
const merged: NormalizedCSAgentConfig = { ...config }
const merged: NormalizedBossChatConfig = { ...config }
const remoteKeys = ["title", "subtitle", "themeColor", "position", "width"] as const
remoteKeys.forEach((key) => {
const value = remoteConfig[key]
@@ -168,7 +168,7 @@ type FrameMessage =
return merged
}
function fetchWidgetConfig(config: NormalizedCSAgentConfig) {
function fetchWidgetConfig(config: NormalizedBossChatConfig) {
const baseUrl = String(config.apiBaseUrl || config.baseUrl || "").replace(/\/$/, "")
if (!baseUrl || !config.channelId || typeof fetch !== "function") {
return Promise.resolve(config)
@@ -254,7 +254,7 @@ type FrameMessage =
try {
state.frame.contentWindow.postMessage(message, state.frameUrl.origin)
} catch (error) {
console.error("[cs-agent-widget] postMessage failed", error)
console.error("[bosschat-widget] postMessage failed", error)
}
}
@@ -266,14 +266,14 @@ type FrameMessage =
if (!state.initSent) {
state.initSent = true
postToFrame({
type: "cs-agent:init",
type: "bosschat:init",
payload: state.frameConfig || createFrameConfig(state.config, ""),
})
}
postToFrame({ type: state.isOpen ? "cs-agent:open" : "cs-agent:minimize" })
postToFrame({ type: state.isOpen ? "bosschat:open" : "bosschat:minimize" })
postToFrame({
type: "cs-agent:maximized",
type: "bosschat:maximized",
payload: { isMaximized: state.isMaximized },
})
}
@@ -350,7 +350,7 @@ type FrameMessage =
}
state.frame = document.createElement("iframe")
state.frame.dataset.csAgentWidget = "frame"
state.frame.dataset.bossChatWidget = "frame"
state.frame.title = state.config.title || "在线客服"
state.frame.src = state.frameUrl.toString()
applyFrameLayout()
@@ -374,24 +374,24 @@ type FrameMessage =
}
const data = (event.data || {}) as { type?: string }
if (data.type === "cs-agent:ready") {
if (data.type === "bosschat:ready") {
state.frameReady = true
flushFrameState()
return
}
if (data.type === "cs-agent:request-minimize") {
if (data.type === "bosschat:request-minimize") {
state.isOpen = false
syncFrameVisibility()
return
}
if (data.type === "cs-agent:request-close") {
if (data.type === "bosschat:request-close") {
destroyFrame()
return
}
if (data.type === "cs-agent:request-toggle-maximize") {
if (data.type === "bosschat:request-toggle-maximize") {
state.isMaximized = !state.isMaximized
syncFrameVisibility()
}
@@ -416,7 +416,7 @@ type FrameMessage =
]
const text = document.createElement("span")
button.type = "button"
button.dataset.csAgentWidget = "launcher"
button.dataset.bossChatWidget = "launcher"
button.setAttribute("aria-label", config.title || "在线客服")
icon.setAttribute("viewBox", "0 0 24 24")
icon.setAttribute("fill", "none")
@@ -473,15 +473,15 @@ type FrameMessage =
return button
}
function mount(config?: CSAgentConfig) {
const rawConfig = config || window.CSAgentConfig || { channelId: "" }
function mount(config?: BossChatConfig) {
const rawConfig = config || window.BossChatConfig || { channelId: "" }
state.config = normalizeConfig(rawConfig)
const widgetBaseUrl = resolveWidgetBaseUrl(state.config)
if (!rawConfig.baseUrl) {
state.config.baseUrl = widgetBaseUrl
}
if (!state.config.channelId) {
console.error("[cs-agent-widget] channelId is required")
console.error("[bosschat-widget] channelId is required")
return
}
@@ -530,11 +530,11 @@ type FrameMessage =
syncFrameVisibility()
})
.catch((error) => {
console.error("[cs-agent-widget] open failed", error)
console.error("[bosschat-widget] open failed", error)
})
}
window.CSAgentWidget = {
window.BossChatWidget = {
mount,
destroy,
open: () => openWidget(),
@@ -544,21 +544,21 @@ type FrameMessage =
},
getChatUrl: () => {
if (!state.config) {
mount(window.CSAgentConfig || { channelId: "" })
mount(window.BossChatConfig || { channelId: "" })
}
if (!state.config?.channelId) {
return Promise.reject(new Error("channelId is required"))
}
return prepareFrameUrl().then((frameUrl) => frameUrl.toString())
},
} satisfies CSAgentWidget
} satisfies BossChatWidget
if (!state.listenerBound) {
window.addEventListener("message", handleWindowMessage)
state.listenerBound = true
}
if (window.CSAgentConfig) {
mount(window.CSAgentConfig)
if (window.BossChatConfig) {
mount(window.BossChatConfig)
}
})()
+9 -9
View File
@@ -1,4 +1,4 @@
export type CSAgentConfig = {
export type BossChatConfig = {
channelId: string
baseUrl?: string
apiBaseUrl?: string
@@ -16,13 +16,13 @@ export type CSAgentConfig = {
width?: string
}
export type KefuChatRuntimeConfig = Omit<CSAgentConfig, "getUserToken"> & {
/** 仅用于 /kefu/chat 运行时换取客服会话 token,不属于 CSAgentConfig 接入参数 */
export type KefuChatRuntimeConfig = Omit<BossChatConfig, "getUserToken"> & {
/** 仅用于 /kefu/chat 运行时换取客服会话 token,不属于 BossChatConfig 接入参数 */
userToken?: string
}
export type CSAgentWidget = {
mount: (config?: CSAgentConfig) => void
export type BossChatWidget = {
mount: (config?: BossChatConfig) => void
destroy: () => void
open: () => Promise<void>
close: () => void
@@ -31,9 +31,9 @@ export type CSAgentWidget = {
declare global {
interface Window {
CSAgentConfig?: CSAgentConfig
CSAgentWidget?: CSAgentWidget
__CS_AGENT_WIDGET_CONFIG__?: KefuChatRuntimeConfig
__CS_AGENT_WIDGET_STATE__?: unknown
BossChatConfig?: BossChatConfig
BossChatWidget?: BossChatWidget
__BOSSCHAT_WIDGET_CONFIG__?: KefuChatRuntimeConfig
__BOSSCHAT_WIDGET_STATE__?: unknown
}
}
+5 -5
View File
@@ -33,11 +33,11 @@ export function readKefuChatRuntimeConfig(): KefuChatRuntimeConfig {
width: query.get("width") ?? undefined,
}
if (window.__CS_AGENT_WIDGET_CONFIG__) {
return window.__CS_AGENT_WIDGET_CONFIG__
if (window.__BOSSCHAT_WIDGET_CONFIG__) {
return window.__BOSSCHAT_WIDGET_CONFIG__
}
if (window.CSAgentConfig) {
const { getUserToken: _getUserToken, ...hostConfig } = window.CSAgentConfig
if (window.BossChatConfig) {
const { getUserToken: _getUserToken, ...hostConfig } = window.BossChatConfig
return {
...fallback,
...hostConfig,
@@ -50,5 +50,5 @@ export function setKefuChatRuntimeConfig(config: KefuChatRuntimeConfig) {
if (typeof window === "undefined") {
return
}
window.__CS_AGENT_WIDGET_CONFIG__ = config
window.__BOSSCHAT_WIDGET_CONFIG__ = config
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 69 KiB

File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -6,9 +6,9 @@ import ts from "typescript";
const currentDir = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.resolve(currentDir, "..");
const source = path.join(rootDir, "lib", "sdk", "cs-ai-agent-sdk.ts");
const source = path.join(rootDir, "lib", "sdk", "bosschat-sdk.ts");
const targetDir = path.join(rootDir, "public", "sdk");
const target = path.join(targetDir, "cs-ai-agent-sdk.min.js");
const target = path.join(targetDir, "bosschat-sdk.min.js");
await mkdir(targetDir, { recursive: true });
const sourceCode = await readFile(source, "utf8");
+2 -2
View File
@@ -4,7 +4,7 @@
$thumb: #cbd5e1;
$thumb-hover: #94a3b8;
.cs-agent-scrollbar {
.bosschat-scrollbar {
scrollbar-width: thin;
scrollbar-color: $thumb transparent;
@@ -29,7 +29,7 @@ $thumb-hover: #94a3b8;
}
}
.dark .cs-agent-scrollbar {
.dark .bosschat-scrollbar {
scrollbar-color: hsl(var(--border)) transparent;
&::-webkit-scrollbar-thumb {