@supportbridge/sdk 0.8.1 → 0.9.4
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/CHANGELOG.md +102 -72
- package/README.md +344 -325
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -2
- package/dist/client.js.map +1 -1
- package/dist/control-plane.d.ts +2 -1
- package/dist/control-plane.d.ts.map +1 -1
- package/dist/control-plane.js +10 -0
- package/dist/control-plane.js.map +1 -1
- package/dist/doctor.js +2 -2
- package/dist/doctor.js.map +1 -1
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +2 -1
- package/dist/install.js.map +1 -1
- package/dist/mcp-app.d.ts +1 -1
- package/dist/mcp-app.js +1 -1
- package/dist/mcp.js +14 -3
- package/dist/mcp.js.map +1 -1
- package/package.json +66 -53
- package/dist/offer-app.d.ts +0 -41
- package/dist/offer-app.d.ts.map +0 -1
- package/dist/offer-app.js +0 -21
- package/dist/offer-app.js.map +0 -1
package/dist/offer-app.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const SUPPORT_OFFER_RESOURCE_URI = "ui://supportbridge/offer-v1.0.1.html";
|
|
2
|
-
export const SUPPORT_OFFER_MIME_TYPE = "text/html;profile=mcp-app";
|
|
3
|
-
export function createSupportOfferApp(options = {}) {
|
|
4
|
-
const resourceUri = options.resourceUri ?? SUPPORT_OFFER_RESOURCE_URI;
|
|
5
|
-
const title = options.title ?? "Live assistance available";
|
|
6
|
-
const toolMeta = { ui: { resourceUri, visibility: ["model", "app"] }, "ui/resourceUri": resourceUri };
|
|
7
|
-
const resourceMeta = { ui: { preferredFrameSize: { width: 680, height: 230 } } };
|
|
8
|
-
return {
|
|
9
|
-
resourceUri, mimeType: SUPPORT_OFFER_MIME_TYPE, toolMeta, resourceMeta,
|
|
10
|
-
resourceContents: () => ({ contents: [{ uri: resourceUri, mimeType: SUPPORT_OFFER_MIME_TYPE, text: html(title), _meta: resourceMeta }] })
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function html(title) {
|
|
14
|
-
const config = JSON.stringify({ title }).replace(/</g, "\\u003c");
|
|
15
|
-
return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style>
|
|
16
|
-
*{box-sizing:border-box}body{margin:0;padding:10px;background:transparent;color:#17211b;font:14px/1.45 ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}.card{border:1px solid #dbe4de;border-radius:18px;background:#fff;box-shadow:0 8px 28px rgba(27,55,40,.08);overflow:hidden}.body{display:flex;gap:14px;padding:18px}.avatar{width:42px;height:42px;border-radius:50%;display:grid;place-items:center;background:#d9f2e3;color:#17633f;font-weight:750;font-size:17px;flex:none;position:relative}.avatar:after{content:"";position:absolute;right:0;bottom:1px;width:10px;height:10px;border:2px solid white;border-radius:50%;background:#27a765}.copy{min-width:0;flex:1}.eyebrow{display:flex;align-items:center;gap:7px;color:#28704c;font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.045em}.dot{width:7px;height:7px;border-radius:50%;background:#27a765}.title{font-size:17px;font-weight:750;margin:4px 0 3px}.message{color:#4f5d54}.timing{margin-top:6px;color:#748078;font-size:12px}.actions{display:flex;gap:9px;flex-wrap:wrap;padding:0 18px 18px 74px}button{border:0;border-radius:10px;padding:10px 15px;font:inherit;font-weight:700;cursor:pointer}.accept{background:#1f704c;color:#fff}.decline{background:#eef2ef;color:#34463b}.accept:hover{background:#185c3e}.decline:hover{background:#e4eae6}button:disabled{cursor:wait;opacity:.62}.status{display:none;padding:0 18px 16px 74px;color:#5e6c63}.error{color:#9b342d}.hidden{display:none!important}@media(max-width:520px){.actions,.status{padding-left:18px}}
|
|
17
|
-
</style></head><body><main class="card hidden" id="card"><div class="body"><div class="avatar" id="avatar">S</div><div class="copy"><div class="eyebrow"><span class="dot"></span><span id="availability">Available now</span></div><div class="title" id="title"></div><div class="message" id="message">A specialist is available to help.</div><div class="timing">Usually responds in under 2 minutes</div></div></div><div class="actions" id="actions"><button class="accept" id="accept">Chat with support</button><button class="decline" id="decline">Not now</button></div><div class="status" id="status" role="status"></div></main><script>
|
|
18
|
-
(()=>{const CONFIG=${config};let nextId=1,offer=null,busy=false;const pending=new Map(),q=s=>document.querySelector(s),post=message=>window.parent.postMessage(message,"*"),request=(method,params)=>new Promise((resolve,reject)=>{const id=nextId++;pending.set(id,{resolve,reject});post({jsonrpc:"2.0",id,method,params});setTimeout(()=>{if(pending.delete(id))reject(new Error(method+" timed out"))},30000)}),notify=(method,params)=>post({jsonrpc:"2.0",method,...(params?{params}:{})}),callTool=(name,args)=>request("tools/call",{name,arguments:args}),resize=()=>notify("ui/notifications/size-changed",{width:Math.ceil(document.documentElement.getBoundingClientRect().width),height:Math.ceil(document.documentElement.getBoundingClientRect().height)});q("#title").textContent=CONFIG.title;function render(data){if(!data?.support_available){q("#card").classList.add("hidden");resize();return}offer=data;q("#card").classList.remove("hidden");const rep=data.available_representative||{},name=rep.name||"Support";q("#avatar").textContent=name.charAt(0).toUpperCase();q("#title").textContent=name+" is available to help";q("#message").textContent=data.suggested_message||"Get live help with what you're working on.";q("#availability").textContent=String(rep.status||"available").replace(/^./,c=>c.toUpperCase())+" now";q("#accept").textContent="Chat with "+name;resize()}function setBusy(value,text,error=false){busy=value;q("#accept").disabled=q("#decline").disabled=value;q("#status").style.display=text?"block":"none";q("#status").textContent=text||"";q("#status").classList.toggle("error",error);resize()}async function decide(accepted){if(busy||!offer)return;setBusy(true,accepted?"Requesting a live conversation…":"Declining offer…");const tool=accepted?(offer.accept_tool||"request_assistance"):(offer.decline_tool||"dismiss_support_offer"),args=accepted?{trigger_id:offer.support_trigger_id,issue_summary:offer.suggested_message||offer.support_reason||"User requested live assistance"}:{trigger_id:offer.support_trigger_id};try{const result=await callTool(tool,args);if(result?.isError)throw new Error(result.content?.[0]?.text||"The request failed");q("#actions").classList.add("hidden");q("#status").textContent=accepted?"Connected. Opening the live conversation…":"No problem — the offer was dismissed.";q("#status").style.display="block";resize()}catch(error){setBusy(false,error instanceof Error?error.message:"Please try again.",true)}}q("#accept").addEventListener("click",()=>void decide(true));q("#decline").addEventListener("click",()=>void decide(false));window.addEventListener("message",event=>{if(event.source!==window.parent)return;const message=event.data;if(!message||message.jsonrpc!=="2.0")return;if(message.id!==undefined&&(message.result!==undefined||message.error)){const waiter=pending.get(message.id);if(!waiter)return;pending.delete(message.id);message.error?waiter.reject(new Error(message.error.message)):waiter.resolve(message.result)}else if(message.method==="ui/notifications/tool-result")render(message.params?.structuredContent);else if(message.method==="ping"&&message.id!==undefined)post({jsonrpc:"2.0",id:message.id,result:{}});else if(message.method==="ui/resource-teardown"&&message.id!==undefined)post({jsonrpc:"2.0",id:message.id,result:{}})});request("ui/initialize",{appInfo:{name:"SupportBridge Offer",version:"1.0.1"},appCapabilities:{availableDisplayModes:["inline"]},protocolVersion:"2026-01-26"}).then(()=>{notify("ui/notifications/initialized");new ResizeObserver(resize).observe(document.documentElement);resize()}).catch(()=>setBusy(false,"This host could not initialize the support offer.",true))})();
|
|
19
|
-
</script></body></html>`;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=offer-app.js.map
|
package/dist/offer-app.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"offer-app.js","sourceRoot":"","sources":["../src/offer-app.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,sCAAsC,CAAC;AACjF,MAAM,CAAC,MAAM,uBAAuB,GAAG,2BAA2B,CAAC;AAInE,MAAM,UAAU,qBAAqB,CAAC,UAAkC,EAAE;IACxE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,0BAA0B,CAAC;IACtE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,2BAA2B,CAAC;IAC3D,MAAM,QAAQ,GAAG,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE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