@waniwani/sdk 0.7.4 → 0.7.5-beta.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/dist/chat/index.js +1 -1
- package/dist/{chunk-HVAT4SNH.js → chunk-5JBHQYU5.js} +2 -2
- package/dist/chunk-5JBHQYU5.js.map +1 -0
- package/dist/{code-block-37QAKDTI-M2QCKVTI.js → code-block-37QAKDTI-IIYKFI5S.js} +2 -2
- package/dist/mcp/react.js +1 -1
- package/dist/mermaid-4DMBBIKO-PAA57QRQ.js +3 -0
- package/dist/openai-client-WEB5BLC4.js +5 -0
- package/dist/openai-client-WEB5BLC4.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-HVAT4SNH.js.map +0 -1
- package/dist/mermaid-4DMBBIKO-NR6M3PLG.js +0 -3
- package/dist/openai-client-Q6DRRFMS.js +0 -5
- package/dist/openai-client-Q6DRRFMS.js.map +0 -1
- /package/dist/{code-block-37QAKDTI-M2QCKVTI.js.map → code-block-37QAKDTI-IIYKFI5S.js.map} +0 -0
- /package/dist/{mermaid-4DMBBIKO-NR6M3PLG.js.map → mermaid-4DMBBIKO-PAA57QRQ.js.map} +0 -0
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{a as l,d as a,e as d}from"./chunk-5OQXAEHG.js";var s=class{pendingModelContext=null;getGlobal(e,n){return typeof window>"u"?n:window.openai?.[e]??n}onGlobalChange(e,n,o){if(typeof window>"u")return()=>{};let i=r=>{let t=r.detail.globals[e];t!==void 0&&n(o?o(t):t)};return window.addEventListener(l,i,{passive:!0}),()=>window.removeEventListener(l,i)}async connect(){if(typeof window>"u"||!("openai"in window))throw new Error("OpenAI global not found. Are you running in ChatGPT?")}async close(){}getToolOutput(){return this.getGlobal("toolOutput",null)}onToolResult(e){return this.onGlobalChange("toolOutput",e,n=>({content:[],structuredContent:n??{}}))}async callTool(e,n){if(typeof window>"u"||!window.openai?.callTool)throw new Error("OpenAI callTool not available");return{content:[{type:"text",text:(await window.openai.callTool(e,n)).result}]}}openExternal(e){typeof window<"u"&&window.openai?.openExternal&&window.openai.openExternal({href:e})}sendFollowUp(e){if(typeof window<"u"&&window.openai?.sendFollowUpMessage){let n=d(this.pendingModelContext);this.pendingModelContext=null;let o=n?`${e}
|
|
3
|
-
|
|
4
|
-
${n}`:e;window.openai.sendFollowUpMessage({prompt:o})}}updateModelContext(e){this.pendingModelContext=a(this.pendingModelContext,e)}getTheme(){return this.getGlobal("theme","light")}onThemeChange(e){return this.onGlobalChange("theme",e)}getLocale(){return this.getGlobal("locale","en")}getDisplayMode(){return this.getGlobal("displayMode","inline")}async requestDisplayMode(e){return typeof window>"u"||!window.openai?.requestDisplayMode?"inline":(await window.openai.requestDisplayMode({mode:e})).mode}onDisplayModeChange(e){return this.onGlobalChange("displayMode",e)}getSafeArea(){return this.getGlobal("safeArea",null)}onSafeAreaChange(e){return this.onGlobalChange("safeArea",e,n=>n??null)}getMaxHeight(){return this.getGlobal("maxHeight",null)}onMaxHeightChange(e){return this.onGlobalChange("maxHeight",e,n=>n??null)}getToolResponseMetadata(){return this.getGlobal("toolResponseMetadata",null)}onToolResponseMetadataChange(e){return this.onGlobalChange("toolResponseMetadata",e,n=>n??null)}getWidgetState(){return this.getGlobal("widgetState",null)}onWidgetStateChange(e){return this.onGlobalChange("widgetState",e,n=>n??null)}};export{s as OpenAIWidgetClient};
|
|
5
|
-
//# sourceMappingURL=openai-client-Q6DRRFMS.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mcp/react/widgets/openai-client.ts"],"sourcesContent":["import {\n\tformatModelContextForPrompt,\n\ttype ModelContextUpdate,\n\tmergeModelContext,\n} from \"../../../shared/model-context\";\nimport type {\n\tDisplayMode,\n\tSafeArea,\n\tTheme,\n\tUnknownObject,\n} from \"../hooks/@types\";\nimport { SET_GLOBALS_EVENT_TYPE, type SetGlobalsEvent } from \"../hooks/@types\";\nimport type {\n\tToolCallResult,\n\tToolResult,\n\tUnifiedWidgetClient,\n} from \"./widget-client\";\n\ntype GlobalsKey = keyof SetGlobalsEvent[\"detail\"][\"globals\"];\n\n/**\n * OpenAI widget client implementation.\n * Uses window.openai global object injected by ChatGPT.\n */\nexport class OpenAIWidgetClient implements UnifiedWidgetClient {\n\tprivate pendingModelContext: ModelContextUpdate | null = null;\n\n\tprivate getGlobal<T>(\n\t\tkey: keyof NonNullable<typeof window.openai>,\n\t\tfallback: T,\n\t): T {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn fallback;\n\t\t}\n\t\treturn (window.openai?.[key] as T) ?? fallback;\n\t}\n\n\tprivate onGlobalChange<\n\t\tK extends GlobalsKey,\n\t\tT = SetGlobalsEvent[\"detail\"][\"globals\"][K],\n\t>(\n\t\tkey: K,\n\t\tcallback: (value: T) => void,\n\t\ttransform?: (value: SetGlobalsEvent[\"detail\"][\"globals\"][K]) => T,\n\t): () => void {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst handler = (event: SetGlobalsEvent) => {\n\t\t\tconst value = event.detail.globals[key];\n\t\t\tif (value !== undefined) {\n\t\t\t\tcallback(transform ? transform(value) : (value as T));\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(SET_GLOBALS_EVENT_TYPE, handler, { passive: true });\n\t\treturn () => window.removeEventListener(SET_GLOBALS_EVENT_TYPE, handler);\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (typeof window === \"undefined\" || !(\"openai\" in window)) {\n\t\t\tthrow new Error(\"OpenAI global not found. Are you running in ChatGPT?\");\n\t\t}\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// No-op for OpenAI - connection is managed by the host\n\t}\n\n\tgetToolOutput<T = Record<string, unknown>>(): T | null {\n\t\treturn this.getGlobal<T | null>(\"toolOutput\", null);\n\t}\n\n\tonToolResult(callback: (result: ToolResult) => void): () => void {\n\t\treturn this.onGlobalChange(\"toolOutput\", callback, (v) => ({\n\t\t\tcontent: [],\n\t\t\tstructuredContent: v ?? {},\n\t\t}));\n\t}\n\n\tasync callTool(\n\t\tname: string,\n\t\targs: Record<string, unknown>,\n\t): Promise<ToolCallResult> {\n\t\tif (typeof window === \"undefined\" || !window.openai?.callTool) {\n\t\t\tthrow new Error(\"OpenAI callTool not available\");\n\t\t}\n\t\tconst response = await window.openai.callTool(name, args);\n\t\treturn { content: [{ type: \"text\", text: response.result }] };\n\t}\n\n\topenExternal(url: string): void {\n\t\tif (typeof window !== \"undefined\" && window.openai?.openExternal) {\n\t\t\twindow.openai.openExternal({ href: url });\n\t\t}\n\t}\n\n\tsendFollowUp(prompt: string): void {\n\t\tif (typeof window !== \"undefined\" && window.openai?.sendFollowUpMessage) {\n\t\t\tconst hiddenContext = formatModelContextForPrompt(\n\t\t\t\tthis.pendingModelContext,\n\t\t\t);\n\t\t\tthis.pendingModelContext = null;\n\t\t\tconst message = hiddenContext ? `${prompt}\\n\\n${hiddenContext}` : prompt;\n\t\t\twindow.openai.sendFollowUpMessage({ prompt: message });\n\t\t}\n\t}\n\n\tupdateModelContext(context: ModelContextUpdate): void {\n\t\tthis.pendingModelContext = mergeModelContext(\n\t\t\tthis.pendingModelContext,\n\t\t\tcontext,\n\t\t);\n\t}\n\n\tgetTheme(): Theme {\n\t\treturn this.getGlobal(\"theme\", \"light\" as Theme);\n\t}\n\n\tonThemeChange(callback: (theme: Theme) => void): () => void {\n\t\treturn this.onGlobalChange(\"theme\", callback);\n\t}\n\n\tgetLocale(): string {\n\t\treturn this.getGlobal(\"locale\", \"en\");\n\t}\n\n\tgetDisplayMode(): DisplayMode {\n\t\treturn this.getGlobal(\"displayMode\", \"inline\" as DisplayMode);\n\t}\n\n\tasync requestDisplayMode(mode: DisplayMode): Promise<DisplayMode> {\n\t\tif (typeof window === \"undefined\" || !window.openai?.requestDisplayMode) {\n\t\t\treturn \"inline\";\n\t\t}\n\t\tconst result = await window.openai.requestDisplayMode({ mode });\n\t\treturn result.mode;\n\t}\n\n\tonDisplayModeChange(callback: (mode: DisplayMode) => void): () => void {\n\t\treturn this.onGlobalChange(\"displayMode\", callback);\n\t}\n\n\tgetSafeArea(): SafeArea | null {\n\t\treturn this.getGlobal(\"safeArea\", null);\n\t}\n\n\tonSafeAreaChange(callback: (safeArea: SafeArea | null) => void): () => void {\n\t\treturn this.onGlobalChange(\"safeArea\", callback, (v) => v ?? null);\n\t}\n\n\tgetMaxHeight(): number | null {\n\t\treturn this.getGlobal(\"maxHeight\", null);\n\t}\n\n\tonMaxHeightChange(callback: (maxHeight: number | null) => void): () => void {\n\t\treturn this.onGlobalChange(\"maxHeight\", callback, (v) => v ?? null);\n\t}\n\n\tgetToolResponseMetadata(): UnknownObject | null {\n\t\treturn this.getGlobal(\"toolResponseMetadata\", null);\n\t}\n\n\tonToolResponseMetadataChange(\n\t\tcallback: (metadata: UnknownObject | null) => void,\n\t): () => void {\n\t\treturn this.onGlobalChange(\n\t\t\t\"toolResponseMetadata\",\n\t\t\tcallback,\n\t\t\t(v) => v ?? null,\n\t\t);\n\t}\n\n\tgetWidgetState(): UnknownObject | null {\n\t\treturn this.getGlobal<UnknownObject | null>(\"widgetState\", null);\n\t}\n\n\tonWidgetStateChange(\n\t\tcallback: (state: UnknownObject | null) => void,\n\t): () => void {\n\t\treturn this.onGlobalChange(\"widgetState\", callback, (v) => v ?? null);\n\t}\n}\n"],"mappings":";sDAwBO,IAAMA,EAAN,KAAwD,CACtD,oBAAiD,KAEjD,UACPC,EACAC,EACI,CACJ,OAAI,OAAO,OAAW,IACdA,EAEA,OAAO,SAASD,CAAG,GAAWC,CACvC,CAEQ,eAIPD,EACAE,EACAC,EACa,CACb,GAAI,OAAO,OAAW,IACrB,MAAO,IAAM,CAAC,EAGf,IAAMC,EAAWC,GAA2B,CAC3C,IAAMC,EAAQD,EAAM,OAAO,QAAQL,CAAG,EAClCM,IAAU,QACbJ,EAASC,EAAYA,EAAUG,CAAK,EAAKA,CAAW,CAEtD,EAEA,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7C,CAEA,WAAoB,CACnB,OAAO,KAAK,UAAU,SAAU,IAAI,CACrC,CAEA,gBAA8B,CAC7B,OAAO,KAAK,UAAU,cAAe,QAAuB,CAC7D,CAEA,MAAM,mBAAmBgB,EAAyC,CACjE,OAAI,OAAO,OAAW,KAAe,CAAC,OAAO,QAAQ,mBAC7C,UAEO,MAAM,OAAO,OAAO,mBAAmB,CAAE,KAAAA,CAAK,CAAC,GAChD,IACf,CAEA,oBAAoBhB,EAAmD,CACtE,OAAO,KAAK,eAAe,cAAeA,CAAQ,CACnD,CAEA,aAA+B,CAC9B,OAAO,KAAK,UAAU,WAAY,IAAI,CACvC,CAEA,iBAAiBA,EAA2D,CAC3E,OAAO,KAAK,eAAe,WAAYA,EAAWM,GAAMA,GAAK,IAAI,CAClE,CAEA,cAA8B,CAC7B,OAAO,KAAK,UAAU,YAAa,IAAI,CACxC,CAEA,kBAAkBN,EAA0D,CAC3E,OAAO,KAAK,eAAe,YAAaA,EAAWM,GAAMA,GAAK,IAAI,CACnE,CAEA,yBAAgD,CAC/C,OAAO,KAAK,UAAU,uBAAwB,IAAI,CACnD,CAEA,6BACCN,EACa,CACb,OAAO,KAAK,eACX,uBACAA,EACCM,GAAMA,GAAK,IACb,CACD,CAEA,gBAAuC,CACtC,OAAO,KAAK,UAAgC,cAAe,IAAI,CAChE,CAEA,oBACCN,EACa,CACb,OAAO,KAAK,eAAe,cAAeA,EAAWM,GAAMA,GAAK,IAAI,CACrE,CACD","names":["OpenAIWidgetClient","key","fallback","callback","transform","handler","event","value","SET_GLOBALS_EVENT_TYPE","v","name","args","url","prompt","hiddenContext","formatModelContextForPrompt","message","context","mergeModelContext","mode"]}
|
|
File without changes
|
|
File without changes
|