@nimblebrain/synapse 0.18.0 → 0.19.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/README.md +13 -13
- package/dist/chunk-54W6IAHM.js +24 -0
- package/dist/chunk-54W6IAHM.js.map +1 -0
- package/dist/{chunk-HKRTDGXN.js → chunk-DRLVEHCD.js} +3 -13
- package/dist/chunk-DRLVEHCD.js.map +1 -0
- package/dist/chunk-NP7ROSH2.cjs +33 -0
- package/dist/chunk-NP7ROSH2.cjs.map +1 -0
- package/dist/{chunk-ZLASWV4N.js → chunk-OYLZ5OCK.js} +4 -4
- package/dist/chunk-OYLZ5OCK.js.map +1 -0
- package/dist/chunk-P5DBJFSQ.js +8459 -0
- package/dist/chunk-P5DBJFSQ.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-Q7SFCCGT.cjs +11 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/chunk-QXDCA7QW.cjs +8466 -0
- package/dist/chunk-QXDCA7QW.cjs.map +1 -0
- package/dist/{chunk-VDQZQDU3.cjs → chunk-RU64F5RS.cjs} +7 -7
- package/dist/chunk-RU64F5RS.cjs.map +1 -0
- package/dist/{chunk-LPWEQCZV.cjs → chunk-SZWHFTXV.cjs} +2 -13
- package/dist/chunk-SZWHFTXV.cjs.map +1 -0
- package/dist/codegen/cli.cjs +4 -4
- package/dist/codegen/cli.js +4 -4
- package/dist/codegen/index.cjs +1 -0
- package/dist/codegen/index.d.cts +1 -1
- package/dist/codegen/index.d.ts +1 -1
- package/dist/codegen/index.js +1 -0
- package/dist/connect.iife.global.js +66 -43
- package/dist/{detect-Bf8Q_0dK.d.ts → detect-DBwc8a21.d.ts} +2 -2
- package/dist/{detect-BHYg26_d.d.cts → detect-DZMJsyvZ.d.cts} +2 -2
- package/dist/host/index.cjs +15 -14
- package/dist/host/index.d.cts +3 -3
- package/dist/host/index.d.ts +3 -3
- package/dist/host/index.js +3 -2
- package/dist/index.cjs +42 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -13
- package/dist/index.d.ts +40 -13
- package/dist/index.js +35 -3
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +12 -10
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +14 -5
- package/dist/react/index.d.ts +14 -5
- package/dist/react/index.js +7 -5
- package/dist/react/index.js.map +1 -1
- package/dist/schema-reader-GM4A4L44.js +4 -0
- package/dist/{schema-reader-776246MJ.js.map → schema-reader-GM4A4L44.js.map} +1 -1
- package/dist/{schema-reader-B6LTGBMJ.cjs → schema-reader-MWBRQ2TQ.cjs} +3 -2
- package/dist/{schema-reader-B6LTGBMJ.cjs.map → schema-reader-MWBRQ2TQ.cjs.map} +1 -1
- package/dist/{server-QIYIJHD5.cjs → server-LR6T6C44.cjs} +32 -20
- package/dist/server-LR6T6C44.cjs.map +1 -0
- package/dist/{server-5N76YCWC.js → server-UHPEE55X.js} +32 -21
- package/dist/server-UHPEE55X.js.map +1 -0
- package/dist/synapse-runtime.iife.global.js +66 -43
- package/dist/synapse-ui.iife.global.js +2 -2
- package/dist/{type-generator-UA3L4OIA.cjs → type-generator-YTPFWLVG.cjs} +3 -2
- package/dist/{type-generator-UA3L4OIA.cjs.map → type-generator-YTPFWLVG.cjs.map} +1 -1
- package/dist/type-generator-ZYSVFK3X.js +4 -0
- package/dist/{type-generator-MZ4X4DE5.js.map → type-generator-ZYSVFK3X.js.map} +1 -1
- package/dist/{types-uEO4VFJ2.d.cts → types-CG08aO82.d.cts} +14 -83
- package/dist/{types-uEO4VFJ2.d.ts → types-CG08aO82.d.ts} +14 -83
- package/dist/ui/base.cjs +1 -0
- package/dist/ui/base.cjs.map +1 -1
- package/dist/ui/base.js +1 -0
- package/dist/ui/base.js.map +1 -1
- package/dist/ui/index.cjs +1 -0
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/vite/index.cjs +74 -30
- package/dist/vite/index.cjs.map +1 -1
- package/dist/vite/index.d.cts +5 -1
- package/dist/vite/index.d.ts +5 -1
- package/dist/vite/index.js +74 -30
- package/dist/vite/index.js.map +1 -1
- package/dist/{writer-NDK4U6C5.cjs → writer-HDRCQSX2.cjs} +3 -3
- package/dist/{writer-NDK4U6C5.cjs.map → writer-HDRCQSX2.cjs.map} +1 -1
- package/dist/{writer-ZNBXYUYC.js → writer-QNDPMEYD.js} +3 -3
- package/dist/{writer-ZNBXYUYC.js.map → writer-QNDPMEYD.js.map} +1 -1
- package/package.json +8 -5
- package/dist/chunk-3YSXPBEQ.js +0 -781
- package/dist/chunk-3YSXPBEQ.js.map +0 -1
- package/dist/chunk-FB7GPBEM.cjs +0 -788
- package/dist/chunk-FB7GPBEM.cjs.map +0 -1
- package/dist/chunk-HKRTDGXN.js.map +0 -1
- package/dist/chunk-LPWEQCZV.cjs.map +0 -1
- package/dist/chunk-VDQZQDU3.cjs.map +0 -1
- package/dist/chunk-ZLASWV4N.js.map +0 -1
- package/dist/schema-reader-776246MJ.js +0 -3
- package/dist/server-5N76YCWC.js.map +0 -1
- package/dist/server-QIYIJHD5.cjs.map +0 -1
- package/dist/type-generator-MZ4X4DE5.js +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(){'use strict';var be=new Set(["auto","block","swap","fallback","optional"]),ke={"--color-background-primary":"#ffffff","--color-background-secondary":"#fafafa","--color-background-tertiary":"#f3f4f6","--color-text-primary":"#111827","--color-text-secondary":"#6b7280","--color-text-tertiary":"#9ca3af","--color-text-accent":"#2563eb","--nb-color-accent-foreground":"#ffffff","--color-border-primary":"#e5e7eb","--color-border-secondary":"#d1d5db","--color-ring-primary":"#2563eb","--nb-color-danger":"#dc2626","--nb-color-danger-foreground":"#ffffff","--nb-color-success":"#059669","--nb-color-warning":"#f59e0b","--nb-color-processing":"#7c3aed","--nb-color-processing-light":"#f3eeff","--nb-color-info-light":"#eef4ff"},Pe={"--color-background-primary":"#18181b","--color-background-secondary":"#27272a","--color-background-tertiary":"#2f2f34","--color-text-primary":"#fafafa","--color-text-secondary":"#a1a1aa","--color-text-tertiary":"#71717a","--color-text-accent":"#818cf8","--nb-color-accent-foreground":"#ffffff","--color-border-primary":"#3f3f46","--color-border-secondary":"#52525b","--color-ring-primary":"#818cf8","--nb-color-danger":"#f87171","--nb-color-danger-foreground":"#18181b","--nb-color-success":"#34d399","--nb-color-warning":"#fbbf24","--nb-color-processing":"#a78bfa","--nb-color-processing-light":"#2a2440","--nb-color-info-light":"#1e2a44"},Ee={light:ke,dark:Pe},Ie="synapse-defaults",G="synapse-theme-defaults",W=new Set;function ve(){return typeof document<"u"&&typeof document.getElementById=="function"&&typeof document.createElement=="function"&&typeof document.head?.prepend=="function"}function
|
|
1
|
+
(function(){'use strict';var be=new Set(["auto","block","swap","fallback","optional"]),ke={"--color-background-primary":"#ffffff","--color-background-secondary":"#fafafa","--color-background-tertiary":"#f3f4f6","--color-text-primary":"#111827","--color-text-secondary":"#6b7280","--color-text-tertiary":"#9ca3af","--color-text-accent":"#2563eb","--nb-color-accent-foreground":"#ffffff","--color-border-primary":"#e5e7eb","--color-border-secondary":"#d1d5db","--color-ring-primary":"#2563eb","--nb-color-danger":"#dc2626","--nb-color-danger-foreground":"#ffffff","--nb-color-success":"#059669","--nb-color-warning":"#f59e0b","--nb-color-processing":"#7c3aed","--nb-color-processing-light":"#f3eeff","--nb-color-info-light":"#eef4ff"},Pe={"--color-background-primary":"#18181b","--color-background-secondary":"#27272a","--color-background-tertiary":"#2f2f34","--color-text-primary":"#fafafa","--color-text-secondary":"#a1a1aa","--color-text-tertiary":"#71717a","--color-text-accent":"#818cf8","--nb-color-accent-foreground":"#ffffff","--color-border-primary":"#3f3f46","--color-border-secondary":"#52525b","--color-ring-primary":"#818cf8","--nb-color-danger":"#f87171","--nb-color-danger-foreground":"#18181b","--nb-color-success":"#34d399","--nb-color-warning":"#fbbf24","--nb-color-processing":"#a78bfa","--nb-color-processing-light":"#2a2440","--nb-color-info-light":"#1e2a44"},Ee={light:ke,dark:Pe},Ie="synapse-defaults",G="synapse-theme-defaults",W=new Set;function ve(){return typeof document<"u"&&typeof document.getElementById=="function"&&typeof document.createElement=="function"&&typeof document.head?.prepend=="function"}function Ae(e){if(!ve())return;let o=Object.entries(Ee[e]).map(([a,p])=>` ${a}: ${p};`).join(`
|
|
2
2
|
`),n=`@layer ${Ie} {
|
|
3
3
|
:root {
|
|
4
4
|
${o}
|
|
5
5
|
}
|
|
6
|
-
}`,s=document.getElementById(G);if(s){s.textContent!==n&&(s.textContent=n);return}let i=document.createElement("style");i.id=G,i.textContent=n,document.head.prepend(i);}function
|
|
6
|
+
}`,s=document.getElementById(G);if(s){s.textContent!==n&&(s.textContent=n);return}let i=document.createElement("style");i.id=G,i.textContent=n,document.head.prepend(i);}function Ce(e,o){if(typeof document>"u")return;Ae(e);let n={};if(o&&typeof o=="object")for(let[i,a]of Object.entries(o))typeof i=="string"&&typeof a=="string"&&(n[i]=a);let s=document.documentElement.style;if(typeof s.removeProperty=="function")for(let i of W)i in n||s.removeProperty(i);for(let[i,a]of Object.entries(n))s.setProperty(i,a);W=new Set(Object.keys(n));}var F=new Set,Y="";function w(e){return Array.isArray(e)?JSON.stringify(e.map(o=>[o.family,o.src,o.weight,o.style,o.display])):""}function M(e){if(!Array.isArray(e))return;let o=e.filter(Oe);if(!(e.length>0&&o.length===0))return o}function we(e){let o=M(e);if(o===void 0||typeof document>"u"||!document.fonts||typeof FontFace>"u")return;let n=w(o);if(n!==Y){Y=n;for(let s of F)try{document.fonts.delete(s);}catch{}F.clear();for(let s of o)try{let i=new FontFace(s.family,s.src,{weight:s.weight,style:s.style,display:s.display&&be.has(s.display)?s.display:"swap"});document.fonts.add(i),F.add(i);}catch{}}}function Oe(e){if(!e||typeof e!="object")return false;let o=e;return typeof o.family=="string"&&typeof o.src=="string"}function Z(e,o,n){Ce(e,o),we(n);}function R(e){typeof document<"u"&&document.documentElement.setAttribute("data-theme",e.mode),Z(e.mode,e.tokens,e.fontFaces);}function O(e){try{if(e?.matchMedia?.("(prefers-color-scheme: dark)").matches)return "dark"}catch{}return "light"}function h(e,o){return e==="light"||e==="dark"?e:o}var T=class extends Error{constructor(o,n){super(`"${o}" is not supported by the "${n}" host`),this.name="HostUnsupportedError";}},_="synapse-ui-data",$="ui-lifecycle-iframe-ready",V="ui-lifecycle-iframe-render-data",q="ui-size-change",B="link",Q="prompt",L="openai:set_globals",X="2026-01-26",J="ui/initialize",ee="ui/notifications/initialized",te="ui/notifications/tool-result",ne="ui/notifications/host-context-changed",oe="ui/notifications/size-changed",re="ui/open-link",se="ui/message",ie="ui/resource-teardown",ae="tools/call";function ce(e,o){let n=()=>e.openai,s=n()?.toolOutput??null,i={mode:h(n()?.theme,"light"),tokens:{}},a=new Set,p=new Set,f=false,m=c=>{if(f)return;let l=c.detail?.globals;if(l){if("toolOutput"in l&&l.toolOutput!=null){s=l.toolOutput;for(let u of a)u(s);}if("theme"in l&&l.theme!=null){let u=h(l.theme,i.mode);if(u!==i.mode){i={mode:u,tokens:{}};for(let b of p)b(i);}}}};return {host:"chatgpt",getData:()=>s,onData(c){return a.add(c),()=>a.delete(c)},getTheme:()=>i,onTheme(c){return p.add(c),()=>p.delete(c)},async callTool(c,l){let u=n()?.callTool;if(!u)throw new T("callTool","chatgpt");return await u(c,l??{})},sendPrompt(c){let l=n();(l?.sendFollowUpMessage??l?.sendFollowupMessage)?.({prompt:c});},openLink(c){let l=n()?.openExternal;l?l({href:c}):e.open(c,"_blank","noopener,noreferrer");},resize(){},capabilities(){let c=n();return {pull:typeof c?.callTool=="function",sendPrompt:typeof c?.sendFollowUpMessage=="function"||typeof c?.sendFollowupMessage=="function",openLink:true}},start(){e.addEventListener(L,m,{passive:true}),s=n()?.toolOutput??s;},destroy(){f||(f=true,e.removeEventListener(L,m),a.clear(),p.clear());}}}function x(e,o){if(!e)return null;let s=e.getElementById(o)?.textContent;if(!s)return null;try{return JSON.parse(s)??null}catch{return null}}function U(e){if(e==null||typeof e!="object")return null;let o=e,n=o.renderData,s=n!=null&&typeof n=="object"?n:o;return s.toolOutput!=null?s.toolOutput:s.structuredContent!=null?s.structuredContent:s}function le(e,o){let n=o.dataElementId??_,s=null,i={mode:O(e),tokens:{}},a=new Set,p=false,f=null,m=c=>{if(p)return;let l=h(c.matches?"dark":"light",i.mode);if(l!==i.mode){i={mode:l,tokens:{}};for(let u of a)u(i);}};return {host:"generic",getData:()=>s,onData(){return ()=>{}},getTheme:()=>i,onTheme(c){return a.add(c),()=>a.delete(c)},async callTool(c){throw new T("callTool","generic")},sendPrompt(){},openLink(c){e.open(c,"_blank","noopener,noreferrer");},resize(){},capabilities(){return {pull:false,sendPrompt:false,openLink:true}},start(){s=x(e.document,n);try{f=e.matchMedia?.("(prefers-color-scheme: dark)")??null,f?.addEventListener?.("change",m);}catch{f=null;}},destroy(){p||(p=true,f?.removeEventListener?.("change",m),f=null,a.clear());}}}var _e="synapse/fontFaces";function xe(e){return M(e?.[_e])}function de(e,o){return xe(o)??e}var De=3e4;function pe(e,o){let n=o.dataElementId??_,s=o.autoResize!==false,i=null,a={mode:O(e),tokens:{}},p=new Set,f=new Set,m=false,c=false,l=1,u=new Map,b=-1,v=null,k=null,H=()=>e.parent??e;function P(t){H().postMessage(t,"*");}function D(t){c||P(t);}function N(t,r){P({jsonrpc:"2.0",method:t,params:r??{}});}function A(t,r){let d=l++;return new Promise((g,y)=>{let I=setTimeout(()=>{u.delete(d),y(new Error(`"${t}" timed out`));},De);u.set(d,{resolve:g,reject:y,timer:I}),P({jsonrpc:"2.0",id:d,method:t,params:r??{}});})}function j(t){if(t!=null){i=t;for(let r of p)r(t);}}function S(t){if(!t||typeof t!="object")return;let{mode:r,tokens:d,fontFaces:g}=a,y=false;if(t.theme!=null){let C=h(t.theme,r);C!==r&&(r=C,y=true);}let I=t.styles;I?.variables&&typeof I.variables=="object"&&(d={...d,...I.variables},y=true);let K=de(g,t);if(w(K)!==w(g)&&(g=K,y=true),y){a={mode:r,tokens:d,...g?{fontFaces:g}:{}};for(let C of f)C(a);}}function E(t){if(m)return;let r=typeof t=="number"?t:Math.ceil(e.document.body.scrollHeight);r!==b&&(b=r,c&&N(oe,{height:r}),D({type:q,payload:{height:r}}));}function me(t){let r=Number(t.id),d=u.get(r);if(d)if(u.delete(r),clearTimeout(d.timer),t.error!=null){let g=t.error;d.reject(new Error(g.message??"request failed"));}else d.resolve(t.result);}function ge(t,r){if(t===te){let d=r.structuredContent;j(d??U(r));}else t===ne&&S(r);}function ye(t){t.method===ie&&P({jsonrpc:"2.0",id:t.id,result:{}});}function he(t){if(t.type===V||t.type==="renderData"){let{theme:r,...d}=t.payload??{};r!=null&&S({theme:r}),Object.keys(d).length>0&&j(U(d));}}let z=t=>{if(m||t.source&&t.source!==H())return;let r=t.data;if(!(!r||typeof r!="object")){if(r.jsonrpc!=="2.0"){he(r);return}r.id!=null&&("result"in r||"error"in r)?me(r):typeof r.method=="string"&&(r.id!=null?ye(r):ge(r.method,r.params??{}));}};function Te(){k=()=>E(),e.addEventListener("resize",k),typeof e.ResizeObserver<"u"&&(v=new e.ResizeObserver(()=>E()),v.observe(e.document.body));}return {host:"claude",getData:()=>i,onData(t){return p.add(t),()=>p.delete(t)},getTheme:()=>a,onTheme(t){return f.add(t),()=>f.delete(t)},async callTool(t,r){return await A(ae,{name:t,arguments:r??{}})},sendPrompt(t){A(se,{role:"user",content:[{type:"text",text:t}]}).catch(()=>{}),D({type:Q,payload:{prompt:t}});},openLink(t){A(re,{url:t}).catch(()=>{}),D({type:B,payload:{url:t}});},resize(t){E(t);},capabilities(){return {pull:true,sendPrompt:true,openLink:true}},start(){e.addEventListener("message",z),i=x(e.document,n),s&&Te(),P({type:$}),A(J,{appInfo:{name:o.name??"synapse-ui",version:o.version??"0.0.0"},appCapabilities:{availableDisplayModes:["inline"]},protocolVersion:X}).then(t=>{m||(c=true,S(t?.hostContext),N(ee,{}),b=-1,E());}).catch(()=>{}),E();},destroy(){if(!m){m=true,e.removeEventListener("message",z),k&&e.removeEventListener("resize",k),k=null,v?.disconnect(),v=null;for(let t of u.values())clearTimeout(t.timer),t.reject(new Error("adapter destroyed"));u.clear(),p.clear(),f.clear();}}}}function Se(e){if(e.openai!=null)return "chatgpt";try{if(e.parent!=null&&e.parent!==e)return "claude"}catch{return "claude"}return "generic"}function Fe(e,o,n){switch(e){case "chatgpt":return ce(o);case "claude":case "nimblebrain":return pe(o,n);default:return le(o,n)}}function ue(e,o){let n=o.host??Se(e);return Fe(n,e,o)}function fe(e={}){let o=e.window??globalThis,n=ue(o,e);R(n.getTheme());let s=n.onTheme(R);n.start();let i=false;return {data:()=>n.getData(),onData:a=>n.onData(a),theme:()=>n.getTheme(),onTheme:a=>n.onTheme(a),callTool:(a,p)=>n.callTool(a,p),sendPrompt:a=>n.sendPrompt(a),openLink:a=>n.openLink(a),resize:a=>n.resize(a),capabilities:()=>n.capabilities(),host:()=>n.host,destroy(){i||(i=true,s(),n.destroy());}}}globalThis.SynapseUI={connect:fe};})();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkHLT5UBJF_cjs = require('./chunk-HLT5UBJF.cjs');
|
|
4
|
+
require('./chunk-Q7SFCCGT.cjs');
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
@@ -8,5 +9,5 @@ Object.defineProperty(exports, "generateTypes", {
|
|
|
8
9
|
enumerable: true,
|
|
9
10
|
get: function () { return chunkHLT5UBJF_cjs.generateTypes; }
|
|
10
11
|
});
|
|
11
|
-
//# sourceMappingURL=type-generator-
|
|
12
|
-
//# sourceMappingURL=type-generator-
|
|
12
|
+
//# sourceMappingURL=type-generator-YTPFWLVG.cjs.map
|
|
13
|
+
//# sourceMappingURL=type-generator-YTPFWLVG.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"type-generator-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"type-generator-YTPFWLVG.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"type-generator-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"type-generator-ZYSVFK3X.js"}
|
|
@@ -3,7 +3,8 @@ import { ReadResourceRequest, ReadResourceResult, Task } from '@modelcontextprot
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Shape of the `tasks` capability advertised in `appCapabilities` on the
|
|
6
|
-
* iframe side
|
|
6
|
+
* iframe side, and mirrored back by the host in `hostCapabilities.experimental`
|
|
7
|
+
* under the MCP Tasks extension identifier (see `readHostTasksCapability`).
|
|
7
8
|
*
|
|
8
9
|
* Matches the MCP 2025-11-25 tasks utility: empty objects (`{}`) are used
|
|
9
10
|
* as presence flags — NOT booleans — so future sub-fields can be added
|
|
@@ -46,13 +47,6 @@ interface CallToolAsTaskOptions {
|
|
|
46
47
|
* "unlimited" explicitly.
|
|
47
48
|
*/
|
|
48
49
|
ttl?: number;
|
|
49
|
-
/**
|
|
50
|
-
* Route the call through the internal-apps cross-server authz path
|
|
51
|
-
* (adds `params.server` set to this app's name). External apps MUST
|
|
52
|
-
* NOT pass this; spec doesn't touch it — it's a NimbleBrain-specific
|
|
53
|
-
* bridge convention mirroring `callTool`'s behavior.
|
|
54
|
-
*/
|
|
55
|
-
internal?: boolean;
|
|
56
50
|
}
|
|
57
51
|
/**
|
|
58
52
|
* Handle returned by `synapse.callToolAsTask`. Lifecycle mirrors the MCP
|
|
@@ -140,54 +134,6 @@ interface Theme {
|
|
|
140
134
|
*/
|
|
141
135
|
fontFaces?: FontFaceDescriptor[];
|
|
142
136
|
}
|
|
143
|
-
interface DataChangedEvent {
|
|
144
|
-
source: "agent";
|
|
145
|
-
server: string;
|
|
146
|
-
tool: string;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Built-in action types that Synapse handles natively.
|
|
150
|
-
*
|
|
151
|
-
* - `navigate` — select/focus a resource in the UI (e.g., a board, document, record)
|
|
152
|
-
* - `notify` — display a transient message (toast/banner)
|
|
153
|
-
* - `refresh` — force a full data refresh (heavier than datachanged)
|
|
154
|
-
* - `confirm` — request user confirmation before the agent proceeds
|
|
155
|
-
*
|
|
156
|
-
* Apps may also receive custom string types for domain-specific actions.
|
|
157
|
-
*/
|
|
158
|
-
type BuiltinActionType = "navigate" | "notify" | "refresh" | "confirm";
|
|
159
|
-
/**
|
|
160
|
-
* A typed, declarative action sent from the agent/server to the UI.
|
|
161
|
-
*
|
|
162
|
-
* Actions are deterministic side effects of tool execution — the tool decides
|
|
163
|
-
* what action to emit, not the LLM. The UI decides how to handle it.
|
|
164
|
-
*
|
|
165
|
-
* This mirrors Studio's ClientAction pattern, adapted for iframe postMessage.
|
|
166
|
-
*/
|
|
167
|
-
interface AgentAction<TPayload = Record<string, unknown>> {
|
|
168
|
-
/** Discriminator — a BuiltinActionType or custom string. */
|
|
169
|
-
type: BuiltinActionType | (string & {});
|
|
170
|
-
/** Typed payload — shape depends on `type`. */
|
|
171
|
-
payload: TPayload;
|
|
172
|
-
/** If true, the UI should confirm with the user before executing. */
|
|
173
|
-
requiresConfirmation?: boolean;
|
|
174
|
-
/** Human-readable label for confirmation dialogs or logs. */
|
|
175
|
-
label?: string;
|
|
176
|
-
}
|
|
177
|
-
/** Payload for the built-in "navigate" action. */
|
|
178
|
-
interface NavigatePayload {
|
|
179
|
-
/** Entity type (e.g., "board", "document", "task"). */
|
|
180
|
-
entity: string;
|
|
181
|
-
/** Entity ID to select/focus. */
|
|
182
|
-
id: string;
|
|
183
|
-
/** Optional sub-view or section within the entity. */
|
|
184
|
-
view?: string;
|
|
185
|
-
}
|
|
186
|
-
/** Payload for the built-in "notify" action. */
|
|
187
|
-
interface NotifyPayload {
|
|
188
|
-
message: string;
|
|
189
|
-
level?: "info" | "success" | "warning" | "error";
|
|
190
|
-
}
|
|
191
137
|
interface ToolCallResult<T = unknown> {
|
|
192
138
|
data: T;
|
|
193
139
|
isError: boolean;
|
|
@@ -254,11 +200,6 @@ interface ToolDefinition {
|
|
|
254
200
|
inputSchema: Record<string, unknown>;
|
|
255
201
|
outputSchema?: Record<string, unknown>;
|
|
256
202
|
}
|
|
257
|
-
interface HostInfo {
|
|
258
|
-
isNimbleBrain: boolean;
|
|
259
|
-
serverName: string;
|
|
260
|
-
protocolVersion: string;
|
|
261
|
-
}
|
|
262
203
|
interface ConnectOptions {
|
|
263
204
|
/** App name — must match the bundle name registered with the host. */
|
|
264
205
|
name: string;
|
|
@@ -266,12 +207,6 @@ interface ConnectOptions {
|
|
|
266
207
|
version: string;
|
|
267
208
|
/** Track the document height and re-send `size-changed` as it moves. */
|
|
268
209
|
autoResize?: boolean;
|
|
269
|
-
/**
|
|
270
|
-
* Mark as an internal NimbleBrain app. Enables cross-server tool calls:
|
|
271
|
-
* `callTool` carries a `server` param so the host can route the call to a
|
|
272
|
-
* sibling server. External apps MUST NOT set this.
|
|
273
|
-
*/
|
|
274
|
-
internal?: boolean;
|
|
275
210
|
/**
|
|
276
211
|
* Forward keyboard shortcuts from this iframe up to the host, so the host's
|
|
277
212
|
* own shortcuts still fire while focus is inside the app.
|
|
@@ -300,25 +235,15 @@ interface ToolResultData {
|
|
|
300
235
|
structuredContent: unknown;
|
|
301
236
|
raw: Record<string, unknown>;
|
|
302
237
|
}
|
|
303
|
-
/** Per-call overrides for {@link App.callTool}. */
|
|
304
|
-
interface CallToolOptions {
|
|
305
|
-
/**
|
|
306
|
-
* Route the call to a sibling MCP server rather than the app's own.
|
|
307
|
-
* Internal apps only — the host rejects it otherwise. Defaults to this
|
|
308
|
-
* app's name when `connect({ internal: true })` was used, which is what
|
|
309
|
-
* makes a plain `callTool` work for an internal app.
|
|
310
|
-
*/
|
|
311
|
-
server?: string;
|
|
312
|
-
}
|
|
313
238
|
/** Known short event names for {@link App.on}. */
|
|
314
|
-
type AppEventName = "tool-result" | "tool-input" | "tool-input-partial" | "tool-cancelled" | "theme-changed" | "host-context-changed" | "
|
|
239
|
+
type AppEventName = "tool-result" | "tool-input" | "tool-input-partial" | "tool-cancelled" | "theme-changed" | "host-context-changed" | "teardown";
|
|
315
240
|
/**
|
|
316
241
|
* A connected app — what `connect()` resolves to, and the only runtime object
|
|
317
242
|
* this SDK hands out.
|
|
318
243
|
*
|
|
319
244
|
* Deliberately small: it carries the ext-apps spec surface plus the state the
|
|
320
245
|
* handshake established. NimbleBrain's own extensions (the file picker,
|
|
321
|
-
* `action
|
|
246
|
+
* `action`), `downloadFile` and the MCP tasks utility are composable functions
|
|
322
247
|
* over this object rather than more methods on it.
|
|
323
248
|
*/
|
|
324
249
|
interface App {
|
|
@@ -359,8 +284,6 @@ interface App {
|
|
|
359
284
|
* notification exactly as sent, subscribe to the wire method instead:
|
|
360
285
|
* `on("ui/notifications/host-context-changed", …)`. */
|
|
361
286
|
on(event: "host-context-changed", handler: (ctx: McpUiHostContext) => void): () => void;
|
|
362
|
-
on(event: "data-changed", handler: (event: DataChangedEvent) => void): () => void;
|
|
363
|
-
on(event: "action", handler: (action: AgentAction) => void): () => void;
|
|
364
287
|
on(event: "teardown", handler: () => void): () => void;
|
|
365
288
|
on(event: string, handler: (params: any) => void): () => void;
|
|
366
289
|
resize(width?: number, height?: number): void;
|
|
@@ -374,7 +297,15 @@ interface App {
|
|
|
374
297
|
* change want `useModelContext`, which debounces.
|
|
375
298
|
*/
|
|
376
299
|
updateModelContext(state: Record<string, unknown>, summary?: string): void;
|
|
377
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Call a tool on this app's own MCP server.
|
|
302
|
+
*
|
|
303
|
+
* An app reaches its own server and nothing else. A host scopes every call
|
|
304
|
+
* to the server that mounted the app, so there is no target to name and no
|
|
305
|
+
* option to pass — cross-source work belongs to the agent, which can call
|
|
306
|
+
* two servers and hand one's result to the other.
|
|
307
|
+
*/
|
|
308
|
+
callTool<TOutput = unknown>(name: string, args?: Record<string, unknown>): Promise<ToolCallResult<TOutput>>;
|
|
378
309
|
/**
|
|
379
310
|
* Read an MCP resource from the originating server via the host bridge
|
|
380
311
|
* (ext-apps `resources/read`). Named to mirror the ext-apps spec's
|
|
@@ -389,4 +320,4 @@ interface App {
|
|
|
389
320
|
destroy(): void;
|
|
390
321
|
}
|
|
391
322
|
|
|
392
|
-
export type { App as A,
|
|
323
|
+
export type { App as A, ConnectOptions as C, Dimensions as D, FileResult as F, KeyForwardConfig as K, ModelContext as M, RequestFileOptions as R, TaskHandle as T, CallToolAsTaskOptions as a, ToolCallResult as b, Theme as c, ToolResultData as d, ToolDefinition as e, FontFaceDescriptor as f, AppEventName as g, FontDisplayValue as h, TasksCapability as i };
|
|
@@ -3,7 +3,8 @@ import { ReadResourceRequest, ReadResourceResult, Task } from '@modelcontextprot
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Shape of the `tasks` capability advertised in `appCapabilities` on the
|
|
6
|
-
* iframe side
|
|
6
|
+
* iframe side, and mirrored back by the host in `hostCapabilities.experimental`
|
|
7
|
+
* under the MCP Tasks extension identifier (see `readHostTasksCapability`).
|
|
7
8
|
*
|
|
8
9
|
* Matches the MCP 2025-11-25 tasks utility: empty objects (`{}`) are used
|
|
9
10
|
* as presence flags — NOT booleans — so future sub-fields can be added
|
|
@@ -46,13 +47,6 @@ interface CallToolAsTaskOptions {
|
|
|
46
47
|
* "unlimited" explicitly.
|
|
47
48
|
*/
|
|
48
49
|
ttl?: number;
|
|
49
|
-
/**
|
|
50
|
-
* Route the call through the internal-apps cross-server authz path
|
|
51
|
-
* (adds `params.server` set to this app's name). External apps MUST
|
|
52
|
-
* NOT pass this; spec doesn't touch it — it's a NimbleBrain-specific
|
|
53
|
-
* bridge convention mirroring `callTool`'s behavior.
|
|
54
|
-
*/
|
|
55
|
-
internal?: boolean;
|
|
56
50
|
}
|
|
57
51
|
/**
|
|
58
52
|
* Handle returned by `synapse.callToolAsTask`. Lifecycle mirrors the MCP
|
|
@@ -140,54 +134,6 @@ interface Theme {
|
|
|
140
134
|
*/
|
|
141
135
|
fontFaces?: FontFaceDescriptor[];
|
|
142
136
|
}
|
|
143
|
-
interface DataChangedEvent {
|
|
144
|
-
source: "agent";
|
|
145
|
-
server: string;
|
|
146
|
-
tool: string;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Built-in action types that Synapse handles natively.
|
|
150
|
-
*
|
|
151
|
-
* - `navigate` — select/focus a resource in the UI (e.g., a board, document, record)
|
|
152
|
-
* - `notify` — display a transient message (toast/banner)
|
|
153
|
-
* - `refresh` — force a full data refresh (heavier than datachanged)
|
|
154
|
-
* - `confirm` — request user confirmation before the agent proceeds
|
|
155
|
-
*
|
|
156
|
-
* Apps may also receive custom string types for domain-specific actions.
|
|
157
|
-
*/
|
|
158
|
-
type BuiltinActionType = "navigate" | "notify" | "refresh" | "confirm";
|
|
159
|
-
/**
|
|
160
|
-
* A typed, declarative action sent from the agent/server to the UI.
|
|
161
|
-
*
|
|
162
|
-
* Actions are deterministic side effects of tool execution — the tool decides
|
|
163
|
-
* what action to emit, not the LLM. The UI decides how to handle it.
|
|
164
|
-
*
|
|
165
|
-
* This mirrors Studio's ClientAction pattern, adapted for iframe postMessage.
|
|
166
|
-
*/
|
|
167
|
-
interface AgentAction<TPayload = Record<string, unknown>> {
|
|
168
|
-
/** Discriminator — a BuiltinActionType or custom string. */
|
|
169
|
-
type: BuiltinActionType | (string & {});
|
|
170
|
-
/** Typed payload — shape depends on `type`. */
|
|
171
|
-
payload: TPayload;
|
|
172
|
-
/** If true, the UI should confirm with the user before executing. */
|
|
173
|
-
requiresConfirmation?: boolean;
|
|
174
|
-
/** Human-readable label for confirmation dialogs or logs. */
|
|
175
|
-
label?: string;
|
|
176
|
-
}
|
|
177
|
-
/** Payload for the built-in "navigate" action. */
|
|
178
|
-
interface NavigatePayload {
|
|
179
|
-
/** Entity type (e.g., "board", "document", "task"). */
|
|
180
|
-
entity: string;
|
|
181
|
-
/** Entity ID to select/focus. */
|
|
182
|
-
id: string;
|
|
183
|
-
/** Optional sub-view or section within the entity. */
|
|
184
|
-
view?: string;
|
|
185
|
-
}
|
|
186
|
-
/** Payload for the built-in "notify" action. */
|
|
187
|
-
interface NotifyPayload {
|
|
188
|
-
message: string;
|
|
189
|
-
level?: "info" | "success" | "warning" | "error";
|
|
190
|
-
}
|
|
191
137
|
interface ToolCallResult<T = unknown> {
|
|
192
138
|
data: T;
|
|
193
139
|
isError: boolean;
|
|
@@ -254,11 +200,6 @@ interface ToolDefinition {
|
|
|
254
200
|
inputSchema: Record<string, unknown>;
|
|
255
201
|
outputSchema?: Record<string, unknown>;
|
|
256
202
|
}
|
|
257
|
-
interface HostInfo {
|
|
258
|
-
isNimbleBrain: boolean;
|
|
259
|
-
serverName: string;
|
|
260
|
-
protocolVersion: string;
|
|
261
|
-
}
|
|
262
203
|
interface ConnectOptions {
|
|
263
204
|
/** App name — must match the bundle name registered with the host. */
|
|
264
205
|
name: string;
|
|
@@ -266,12 +207,6 @@ interface ConnectOptions {
|
|
|
266
207
|
version: string;
|
|
267
208
|
/** Track the document height and re-send `size-changed` as it moves. */
|
|
268
209
|
autoResize?: boolean;
|
|
269
|
-
/**
|
|
270
|
-
* Mark as an internal NimbleBrain app. Enables cross-server tool calls:
|
|
271
|
-
* `callTool` carries a `server` param so the host can route the call to a
|
|
272
|
-
* sibling server. External apps MUST NOT set this.
|
|
273
|
-
*/
|
|
274
|
-
internal?: boolean;
|
|
275
210
|
/**
|
|
276
211
|
* Forward keyboard shortcuts from this iframe up to the host, so the host's
|
|
277
212
|
* own shortcuts still fire while focus is inside the app.
|
|
@@ -300,25 +235,15 @@ interface ToolResultData {
|
|
|
300
235
|
structuredContent: unknown;
|
|
301
236
|
raw: Record<string, unknown>;
|
|
302
237
|
}
|
|
303
|
-
/** Per-call overrides for {@link App.callTool}. */
|
|
304
|
-
interface CallToolOptions {
|
|
305
|
-
/**
|
|
306
|
-
* Route the call to a sibling MCP server rather than the app's own.
|
|
307
|
-
* Internal apps only — the host rejects it otherwise. Defaults to this
|
|
308
|
-
* app's name when `connect({ internal: true })` was used, which is what
|
|
309
|
-
* makes a plain `callTool` work for an internal app.
|
|
310
|
-
*/
|
|
311
|
-
server?: string;
|
|
312
|
-
}
|
|
313
238
|
/** Known short event names for {@link App.on}. */
|
|
314
|
-
type AppEventName = "tool-result" | "tool-input" | "tool-input-partial" | "tool-cancelled" | "theme-changed" | "host-context-changed" | "
|
|
239
|
+
type AppEventName = "tool-result" | "tool-input" | "tool-input-partial" | "tool-cancelled" | "theme-changed" | "host-context-changed" | "teardown";
|
|
315
240
|
/**
|
|
316
241
|
* A connected app — what `connect()` resolves to, and the only runtime object
|
|
317
242
|
* this SDK hands out.
|
|
318
243
|
*
|
|
319
244
|
* Deliberately small: it carries the ext-apps spec surface plus the state the
|
|
320
245
|
* handshake established. NimbleBrain's own extensions (the file picker,
|
|
321
|
-
* `action
|
|
246
|
+
* `action`), `downloadFile` and the MCP tasks utility are composable functions
|
|
322
247
|
* over this object rather than more methods on it.
|
|
323
248
|
*/
|
|
324
249
|
interface App {
|
|
@@ -359,8 +284,6 @@ interface App {
|
|
|
359
284
|
* notification exactly as sent, subscribe to the wire method instead:
|
|
360
285
|
* `on("ui/notifications/host-context-changed", …)`. */
|
|
361
286
|
on(event: "host-context-changed", handler: (ctx: McpUiHostContext) => void): () => void;
|
|
362
|
-
on(event: "data-changed", handler: (event: DataChangedEvent) => void): () => void;
|
|
363
|
-
on(event: "action", handler: (action: AgentAction) => void): () => void;
|
|
364
287
|
on(event: "teardown", handler: () => void): () => void;
|
|
365
288
|
on(event: string, handler: (params: any) => void): () => void;
|
|
366
289
|
resize(width?: number, height?: number): void;
|
|
@@ -374,7 +297,15 @@ interface App {
|
|
|
374
297
|
* change want `useModelContext`, which debounces.
|
|
375
298
|
*/
|
|
376
299
|
updateModelContext(state: Record<string, unknown>, summary?: string): void;
|
|
377
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Call a tool on this app's own MCP server.
|
|
302
|
+
*
|
|
303
|
+
* An app reaches its own server and nothing else. A host scopes every call
|
|
304
|
+
* to the server that mounted the app, so there is no target to name and no
|
|
305
|
+
* option to pass — cross-source work belongs to the agent, which can call
|
|
306
|
+
* two servers and hand one's result to the other.
|
|
307
|
+
*/
|
|
308
|
+
callTool<TOutput = unknown>(name: string, args?: Record<string, unknown>): Promise<ToolCallResult<TOutput>>;
|
|
378
309
|
/**
|
|
379
310
|
* Read an MCP resource from the originating server via the host bridge
|
|
380
311
|
* (ext-apps `resources/read`). Named to mirror the ext-apps spec's
|
|
@@ -389,4 +320,4 @@ interface App {
|
|
|
389
320
|
destroy(): void;
|
|
390
321
|
}
|
|
391
322
|
|
|
392
|
-
export type { App as A,
|
|
323
|
+
export type { App as A, ConnectOptions as C, Dimensions as D, FileResult as F, KeyForwardConfig as K, ModelContext as M, RequestFileOptions as R, TaskHandle as T, CallToolAsTaskOptions as a, ToolCallResult as b, Theme as c, ToolResultData as d, ToolDefinition as e, FontFaceDescriptor as f, AppEventName as g, FontDisplayValue as h, TasksCapability as i };
|
package/dist/ui/base.cjs
CHANGED
package/dist/ui/base.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ui/base.ts"],"names":["injectBaseReset"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/ui/base.ts"],"names":["injectBaseReset"],"mappings":";;;;;;AAqBAA,iCAAA,EAAgB","file":"base.cjs","sourcesContent":["/**\n * Establishes the root-height chain a full-pane Synapse app needs. Import for\n * the side effect:\n *\n * ```ts\n * import \"@nimblebrain/synapse/ui/base\";\n * ```\n *\n * This injects `html, body, #root { height: 100% }` (so a `height: 100%` app\n * shell resolves against the iframe's allocated pane) and `body { margin: 0 }`\n * (so the pane has no UA-margin gap). See `./internal/base-reset.ts` for why a\n * percentage chain — not a viewport unit — is the correct mechanism.\n *\n * `AppFrame` already calls `injectBaseReset()` on render, so apps built on it\n * get the chain automatically. Import this module explicitly to establish the\n * chain *before* React mounts — avoiding a first-paint layout jump — or for an\n * app that renders a full-pane root without `AppFrame`.\n */\n\nimport { injectBaseReset } from \"./internal/base-reset.js\";\n\ninjectBaseReset();\n\nexport { injectBaseReset };\n"]}
|
package/dist/ui/base.js
CHANGED
package/dist/ui/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ui/base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/ui/base.ts"],"names":[],"mappings":";;;;;AAqBA,eAAA,EAAgB","file":"base.js","sourcesContent":["/**\n * Establishes the root-height chain a full-pane Synapse app needs. Import for\n * the side effect:\n *\n * ```ts\n * import \"@nimblebrain/synapse/ui/base\";\n * ```\n *\n * This injects `html, body, #root { height: 100% }` (so a `height: 100%` app\n * shell resolves against the iframe's allocated pane) and `body { margin: 0 }`\n * (so the pane has no UA-margin gap). See `./internal/base-reset.ts` for why a\n * percentage chain — not a viewport unit — is the correct mechanism.\n *\n * `AppFrame` already calls `injectBaseReset()` on render, so apps built on it\n * get the chain automatically. Import this module explicitly to establish the\n * chain *before* React mounts — avoiding a first-paint layout jump — or for an\n * app that renders a full-pane root without `AppFrame`.\n */\n\nimport { injectBaseReset } from \"./internal/base-reset.js\";\n\ninjectBaseReset();\n\nexport { injectBaseReset };\n"]}
|