sunpeak 0.16.27 → 0.16.28

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.
Files changed (87) hide show
  1. package/bin/commands/build.mjs +0 -1
  2. package/dist/chatgpt/globals.css +10 -9
  3. package/dist/chatgpt/index.cjs +55 -24
  4. package/dist/chatgpt/index.cjs.map +1 -1
  5. package/dist/chatgpt/index.js +31 -25
  6. package/dist/chatgpt/index.js.map +1 -1
  7. package/dist/chunk-9hOWP6kD.cjs +64 -0
  8. package/dist/chunk-D6g4UhsZ.js +35 -0
  9. package/dist/claude/index.cjs +4 -4
  10. package/dist/claude/index.js +3 -5
  11. package/dist/discovery-BxKCIgG5.cjs +332 -0
  12. package/dist/discovery-BxKCIgG5.cjs.map +1 -0
  13. package/dist/discovery-Du4LHrih.js +261 -0
  14. package/dist/discovery-Du4LHrih.js.map +1 -0
  15. package/dist/host/chatgpt/index.cjs +171 -65
  16. package/dist/host/chatgpt/index.cjs.map +1 -1
  17. package/dist/host/chatgpt/index.js +170 -70
  18. package/dist/host/chatgpt/index.js.map +1 -1
  19. package/dist/host/index.cjs +47 -19
  20. package/dist/host/index.cjs.map +1 -1
  21. package/dist/host/index.js +47 -24
  22. package/dist/host/index.js.map +1 -1
  23. package/dist/index.cjs +3103 -3725
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.js +3026 -3746
  26. package/dist/index.js.map +1 -1
  27. package/dist/lib/discovery-cli.cjs +117 -131
  28. package/dist/lib/discovery-cli.cjs.map +1 -1
  29. package/dist/lib/discovery-cli.js +107 -111
  30. package/dist/lib/discovery-cli.js.map +1 -1
  31. package/dist/mcp/index.cjs +9818 -10283
  32. package/dist/mcp/index.cjs.map +1 -1
  33. package/dist/mcp/index.js +9799 -10282
  34. package/dist/mcp/index.js.map +1 -1
  35. package/dist/protocol-DJmRaBzO.js +11080 -0
  36. package/dist/{protocol-DkDHRwOW.cjs.map → protocol-DJmRaBzO.js.map} +1 -1
  37. package/dist/protocol-jbxhzcnS.cjs +11493 -0
  38. package/dist/protocol-jbxhzcnS.cjs.map +1 -0
  39. package/dist/simulator/index.cjs +79 -36
  40. package/dist/simulator/index.cjs.map +1 -1
  41. package/dist/simulator/index.js +43 -37
  42. package/dist/simulator/index.js.map +1 -1
  43. package/dist/simulator-BYIH-xqQ.cjs +3701 -0
  44. package/dist/{simulator-Gc6n_fT4.cjs.map → simulator-BYIH-xqQ.cjs.map} +1 -1
  45. package/dist/simulator-CmgNnWBO.js +3575 -0
  46. package/dist/simulator-CmgNnWBO.js.map +1 -0
  47. package/dist/simulator-url-BDGD4vZD.cjs +69 -0
  48. package/dist/simulator-url-BDGD4vZD.cjs.map +1 -0
  49. package/dist/simulator-url-Bkxj43yT.js +64 -0
  50. package/dist/simulator-url-Bkxj43yT.js.map +1 -0
  51. package/dist/style.css +10 -9
  52. package/dist/use-app-D2h-aiyr.cjs +940 -0
  53. package/dist/use-app-D2h-aiyr.cjs.map +1 -0
  54. package/dist/use-app-X7JbGskk.js +598 -0
  55. package/dist/use-app-X7JbGskk.js.map +1 -0
  56. package/package.json +8 -8
  57. package/template/node_modules/.bin/vite +2 -2
  58. package/template/node_modules/.bin/vitest +2 -2
  59. package/template/package.json +5 -5
  60. package/dist/claude/index.cjs.map +0 -1
  61. package/dist/claude/index.js.map +0 -1
  62. package/dist/discovery-BVqD-JsT.js +0 -224
  63. package/dist/discovery-BVqD-JsT.js.map +0 -1
  64. package/dist/discovery-D1gpaVz4.cjs +0 -223
  65. package/dist/discovery-D1gpaVz4.cjs.map +0 -1
  66. package/dist/index-BEWVLFfB.cjs +0 -28
  67. package/dist/index-BEWVLFfB.cjs.map +0 -1
  68. package/dist/index-C6XYFOmh.js +0 -29
  69. package/dist/index-C6XYFOmh.js.map +0 -1
  70. package/dist/index-D0FsXP3Y.cjs +0 -40
  71. package/dist/index-D0FsXP3Y.cjs.map +0 -1
  72. package/dist/index-Rg7SWjvl.js +0 -41
  73. package/dist/index-Rg7SWjvl.js.map +0 -1
  74. package/dist/protocol-DkDHRwOW.cjs +0 -12221
  75. package/dist/protocol-uge7qFev.js +0 -12223
  76. package/dist/protocol-uge7qFev.js.map +0 -1
  77. package/dist/simulator-B-CrMHVs.js +0 -3534
  78. package/dist/simulator-B-CrMHVs.js.map +0 -1
  79. package/dist/simulator-Gc6n_fT4.cjs +0 -3549
  80. package/dist/simulator-url-DcSYRl-P.cjs +0 -53
  81. package/dist/simulator-url-DcSYRl-P.cjs.map +0 -1
  82. package/dist/simulator-url-j_XV3EoP.js +0 -54
  83. package/dist/simulator-url-j_XV3EoP.js.map +0 -1
  84. package/dist/use-app-C9gpzIQO.js +0 -349
  85. package/dist/use-app-C9gpzIQO.js.map +0 -1
  86. package/dist/use-app-D09O2swh.cjs +0 -348
  87. package/dist/use-app-D09O2swh.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/host/chatgpt/openai-types.ts","../../../src/host/chatgpt/use-create-file.ts","../../../src/host/chatgpt/use-file-download.ts","../../../src/host/chatgpt/use-open-modal.ts","../../../src/host/chatgpt/use-request-checkout.ts"],"sourcesContent":["/**\n * TypeScript declarations for the `window.openai` ChatGPT runtime.\n *\n * These APIs are available inside ChatGPT-hosted iframes and provide\n * platform-specific capabilities beyond the MCP Apps standard.\n *\n * @see https://developers.openai.com/apps-sdk/mcp-apps-in-chatgpt\n */\n\nexport interface OpenAIUploadFileResult {\n fileId: string;\n}\n\nexport interface OpenAIFileDownloadUrlResult {\n downloadUrl: string;\n}\n\nexport interface OpenAIRequestModalParams {\n /** URL of an alternate UI template to load in the modal. Omit to reuse the current UI. */\n template?: string;\n /** Arbitrary params forwarded to the modal content. */\n params?: Record<string, unknown>;\n}\n\nexport interface OpenAICheckoutPaymentProvider {\n provider: string;\n merchant_id: string;\n supported_payment_methods: string[];\n}\n\nexport interface OpenAICheckoutTotal {\n type: string;\n display_text: string;\n amount: number;\n}\n\nexport interface OpenAICheckoutLink {\n type: 'terms_of_use' | 'privacy_policy' | string;\n url: string;\n}\n\nexport interface OpenAICheckoutSession {\n id: string;\n payment_provider: OpenAICheckoutPaymentProvider;\n status: 'ready_for_payment';\n currency: string;\n totals: OpenAICheckoutTotal[];\n links: OpenAICheckoutLink[];\n payment_mode: 'live' | 'test';\n}\n\nexport interface OpenAICheckoutOrder {\n id: string;\n checkout_session_id: string;\n status: 'completed' | string;\n permalink_url?: string;\n}\n\n/**\n * The `window.openai` runtime object injected by ChatGPT into hosted iframes.\n */\nexport interface OpenAIRuntime {\n // --- File APIs ---\n uploadFile?(file: File): Promise<OpenAIUploadFileResult>;\n getFileDownloadUrl?(params: { fileId: string }): Promise<OpenAIFileDownloadUrlResult>;\n\n // --- Modal API ---\n requestModal?(params: OpenAIRequestModalParams): Promise<void>;\n\n // --- Checkout API ---\n requestCheckout?(session: OpenAICheckoutSession): Promise<OpenAICheckoutOrder>;\n\n // --- Display ---\n requestClose?(): void;\n requestDisplayMode?(params: { mode: 'inline' | 'PiP' | 'fullscreen' }): Promise<void>;\n\n // --- Messaging ---\n sendFollowUpMessage?(params: { prompt: string }): void;\n\n // --- Other ---\n openExternal?(params: { href: string }): void;\n}\n\n/**\n * Get the `window.openai` runtime if available.\n * Returns `undefined` outside of ChatGPT or in SSR.\n */\nexport function getOpenAIRuntime(): OpenAIRuntime | undefined {\n if (typeof window !== 'undefined' && 'openai' in window) {\n return (window as unknown as { openai: OpenAIRuntime }).openai;\n }\n return undefined;\n}\n","import { useCallback } from 'react';\nimport { useApp } from '../../hooks/use-app';\nimport { getOpenAIRuntime, type OpenAIUploadFileResult } from './openai-types';\n\nexport type { OpenAIUploadFileResult as CreateFileResult };\n\n/**\n * Upload a file from the app UI into the ChatGPT conversation.\n *\n * Wraps `window.openai.uploadFile` which is only available inside ChatGPT.\n * Supported formats: `image/png`, `image/jpeg`, `image/webp`.\n *\n * Import from `sunpeak/host/chatgpt`:\n *\n * @example\n * ```tsx\n * import { useUploadFile } from 'sunpeak/host/chatgpt';\n *\n * function ImageUploader() {\n * const uploadFile = useUploadFile();\n *\n * const handleChange = async (e: React.ChangeEvent<HTMLInputElement>) => {\n * const file = e.currentTarget.files?.[0];\n * if (!file) return;\n * const { fileId } = await uploadFile(file);\n * console.log('Uploaded:', fileId);\n * };\n *\n * return <input type=\"file\" accept=\"image/*\" onChange={handleChange} />;\n * }\n * ```\n */\nexport function useUploadFile(): (file: File) => Promise<OpenAIUploadFileResult> {\n const app = useApp();\n return useCallback(\n async (file: File) => {\n if (!app) {\n throw new Error('[useUploadFile] App not connected');\n }\n const runtime = getOpenAIRuntime();\n if (!runtime?.uploadFile) {\n throw new Error('[useUploadFile] window.openai.uploadFile not available');\n }\n return runtime.uploadFile(file);\n },\n [app]\n );\n}\n","import { useCallback } from 'react';\nimport { useApp } from '../../hooks/use-app';\nimport { getOpenAIRuntime, type OpenAIFileDownloadUrlResult } from './openai-types';\n\nexport type { OpenAIFileDownloadUrlResult as FileDownloadUrlResult };\n\n/**\n * Get a temporary download URL for a file by its ID.\n *\n * @deprecated Use {@link useDownloadFile} from `sunpeak` instead — it works\n * across all hosts via the MCP Apps SDK `app.downloadFile()` method.\n *\n * Wraps `window.openai.getFileDownloadUrl` which is only available inside\n * ChatGPT. Use this to retrieve URLs for files uploaded via {@link useUploadFile}\n * or file IDs received in tool parameters.\n *\n * Import from `sunpeak/host/chatgpt`:\n *\n * @example\n * ```tsx\n * import { useGetFileDownloadUrl } from 'sunpeak/host/chatgpt';\n *\n * function FilePreview({ fileId }: { fileId: string }) {\n * const getFileDownloadUrl = useGetFileDownloadUrl();\n * const [src, setSrc] = useState<string>();\n *\n * useEffect(() => {\n * getFileDownloadUrl({ fileId }).then(({ downloadUrl }) => setSrc(downloadUrl));\n * }, [fileId, getFileDownloadUrl]);\n *\n * return src ? <img src={src} /> : <p>Loading...</p>;\n * }\n * ```\n */\nexport function useGetFileDownloadUrl(): (params: {\n fileId: string;\n}) => Promise<OpenAIFileDownloadUrlResult> {\n const app = useApp();\n return useCallback(\n async (params: { fileId: string }) => {\n if (!app) {\n throw new Error('[useGetFileDownloadUrl] App not connected');\n }\n const runtime = getOpenAIRuntime();\n if (!runtime?.getFileDownloadUrl) {\n throw new Error('[useGetFileDownloadUrl] window.openai.getFileDownloadUrl not available');\n }\n return runtime.getFileDownloadUrl(params);\n },\n [app]\n );\n}\n","import { useCallback } from 'react';\nimport { useApp } from '../../hooks/use-app';\nimport { getOpenAIRuntime, type OpenAIRequestModalParams } from './openai-types';\n\nexport type { OpenAIRequestModalParams as OpenModalParams };\n\n/**\n * Open a host-controlled modal in ChatGPT.\n *\n * Wraps `window.openai.requestModal` which is only available inside ChatGPT.\n * Pass a `template` URL to load alternate UI content in the modal, or omit\n * it to reuse the current UI.\n *\n * Import from `sunpeak/host/chatgpt`:\n *\n * @example\n * ```tsx\n * import { useRequestModal } from 'sunpeak/host/chatgpt';\n *\n * function CheckoutButton() {\n * const requestModal = useRequestModal();\n *\n * return (\n * <button onClick={() => requestModal({ template: 'ui://widget/checkout.html' })}>\n * Checkout\n * </button>\n * );\n * }\n * ```\n */\nexport function useRequestModal(): (params: OpenAIRequestModalParams) => Promise<void> {\n const app = useApp();\n return useCallback(\n async (params: OpenAIRequestModalParams) => {\n if (!app) {\n console.warn('[useRequestModal] App not connected');\n return;\n }\n const runtime = getOpenAIRuntime();\n if (!runtime?.requestModal) {\n throw new Error('[useRequestModal] window.openai.requestModal not available');\n }\n return runtime.requestModal(params);\n },\n [app]\n );\n}\n","import { useCallback } from 'react';\nimport { useApp } from '../../hooks/use-app';\nimport {\n getOpenAIRuntime,\n type OpenAICheckoutSession,\n type OpenAICheckoutOrder,\n} from './openai-types';\n\nexport type { OpenAICheckoutSession as CheckoutSession };\nexport type { OpenAICheckoutOrder as CheckoutOrder };\n\n/**\n * Trigger the ChatGPT instant checkout flow.\n *\n * Wraps `window.openai.requestCheckout` which is only available inside\n * ChatGPT. Opens the host checkout UI, handles payment display, and\n * resolves with the finalized order. Rejects on error or user cancel.\n *\n * Import from `sunpeak/host/chatgpt`:\n *\n * @example\n * ```tsx\n * import { useRequestCheckout } from 'sunpeak/host/chatgpt';\n *\n * function BuyButton() {\n * const requestCheckout = useRequestCheckout();\n *\n * const handleBuy = async () => {\n * try {\n * const order = await requestCheckout({\n * id: 'session-1',\n * payment_provider: {\n * provider: 'stripe',\n * merchant_id: 'acct_xxx',\n * supported_payment_methods: ['card', 'apple_pay'],\n * },\n * status: 'ready_for_payment',\n * currency: 'USD',\n * totals: [{ type: 'total', display_text: 'Total', amount: 999 }],\n * links: [],\n * payment_mode: 'live',\n * });\n * console.log('Order completed:', order.id);\n * } catch {\n * console.log('Checkout cancelled or failed');\n * }\n * };\n *\n * return <button onClick={handleBuy}>Buy Now</button>;\n * }\n * ```\n */\nexport function useRequestCheckout(): (\n session: OpenAICheckoutSession\n) => Promise<OpenAICheckoutOrder> {\n const app = useApp();\n return useCallback(\n async (session: OpenAICheckoutSession) => {\n if (!app) {\n throw new Error('[useRequestCheckout] App not connected');\n }\n const runtime = getOpenAIRuntime();\n if (!runtime?.requestCheckout) {\n throw new Error('[useRequestCheckout] window.openai.requestCheckout not available');\n }\n return runtime.requestCheckout(session);\n },\n [app]\n );\n}\n"],"names":[],"mappings":";;AAuFO,SAAS,mBAA8C;AAC5D,MAAI,OAAO,WAAW,eAAe,YAAY,QAAQ;AACvD,WAAQ,OAAgD;AAAA,EAC1D;AACA,SAAO;AACT;AC5DO,SAAS,gBAAiE;AAC/E,QAAM,MAAM,OAAA;AACZ,SAAO;AAAA,IACL,OAAO,SAAe;AACpB,UAAI,CAAC,KAAK;AACR,cAAM,IAAI,MAAM,mCAAmC;AAAA,MACrD;AACA,YAAM,UAAU,iBAAA;AAChB,UAAI,CAAC,SAAS,YAAY;AACxB,cAAM,IAAI,MAAM,wDAAwD;AAAA,MAC1E;AACA,aAAO,QAAQ,WAAW,IAAI;AAAA,IAChC;AAAA,IACA,CAAC,GAAG;AAAA,EAAA;AAER;ACbO,SAAS,wBAE2B;AACzC,QAAM,MAAM,OAAA;AACZ,SAAO;AAAA,IACL,OAAO,WAA+B;AACpC,UAAI,CAAC,KAAK;AACR,cAAM,IAAI,MAAM,2CAA2C;AAAA,MAC7D;AACA,YAAM,UAAU,iBAAA;AAChB,UAAI,CAAC,SAAS,oBAAoB;AAChC,cAAM,IAAI,MAAM,wEAAwE;AAAA,MAC1F;AACA,aAAO,QAAQ,mBAAmB,MAAM;AAAA,IAC1C;AAAA,IACA,CAAC,GAAG;AAAA,EAAA;AAER;ACrBO,SAAS,kBAAuE;AACrF,QAAM,MAAM,OAAA;AACZ,SAAO;AAAA,IACL,OAAO,WAAqC;AAC1C,UAAI,CAAC,KAAK;AACR,gBAAQ,KAAK,qCAAqC;AAClD;AAAA,MACF;AACA,YAAM,UAAU,iBAAA;AAChB,UAAI,CAAC,SAAS,cAAc;AAC1B,cAAM,IAAI,MAAM,4DAA4D;AAAA,MAC9E;AACA,aAAO,QAAQ,aAAa,MAAM;AAAA,IACpC;AAAA,IACA,CAAC,GAAG;AAAA,EAAA;AAER;ACMO,SAAS,qBAEkB;AAChC,QAAM,MAAM,OAAA;AACZ,SAAO;AAAA,IACL,OAAO,YAAmC;AACxC,UAAI,CAAC,KAAK;AACR,cAAM,IAAI,MAAM,wCAAwC;AAAA,MAC1D;AACA,YAAM,UAAU,iBAAA;AAChB,UAAI,CAAC,SAAS,iBAAiB;AAC7B,cAAM,IAAI,MAAM,kEAAkE;AAAA,MACpF;AACA,aAAO,QAAQ,gBAAgB,OAAO;AAAA,IACxC;AAAA,IACA,CAAC,GAAG;AAAA,EAAA;AAER;"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/host/chatgpt/openai-types.ts","../../../src/host/chatgpt/use-create-file.ts","../../../src/host/chatgpt/use-file-download.ts","../../../src/host/chatgpt/use-open-modal.ts","../../../src/host/chatgpt/use-request-checkout.ts"],"sourcesContent":["/**\n * TypeScript declarations for the `window.openai` ChatGPT runtime.\n *\n * These APIs are available inside ChatGPT-hosted iframes and provide\n * platform-specific capabilities beyond the MCP Apps standard.\n *\n * @see https://developers.openai.com/apps-sdk/mcp-apps-in-chatgpt\n */\n\nexport interface OpenAIUploadFileResult {\n fileId: string;\n}\n\nexport interface OpenAIFileDownloadUrlResult {\n downloadUrl: string;\n}\n\nexport interface OpenAIRequestModalParams {\n /** URL of an alternate UI template to load in the modal. Omit to reuse the current UI. */\n template?: string;\n /** Arbitrary params forwarded to the modal content. */\n params?: Record<string, unknown>;\n}\n\nexport interface OpenAICheckoutPaymentProvider {\n provider: string;\n merchant_id: string;\n supported_payment_methods: string[];\n}\n\nexport interface OpenAICheckoutTotal {\n type: string;\n display_text: string;\n amount: number;\n}\n\nexport interface OpenAICheckoutLink {\n type: 'terms_of_use' | 'privacy_policy' | string;\n url: string;\n}\n\nexport interface OpenAICheckoutSession {\n id: string;\n payment_provider: OpenAICheckoutPaymentProvider;\n status: 'ready_for_payment';\n currency: string;\n totals: OpenAICheckoutTotal[];\n links: OpenAICheckoutLink[];\n payment_mode: 'live' | 'test';\n}\n\nexport interface OpenAICheckoutOrder {\n id: string;\n checkout_session_id: string;\n status: 'completed' | string;\n permalink_url?: string;\n}\n\n/**\n * The `window.openai` runtime object injected by ChatGPT into hosted iframes.\n */\nexport interface OpenAIRuntime {\n // --- File APIs ---\n uploadFile?(file: File): Promise<OpenAIUploadFileResult>;\n getFileDownloadUrl?(params: { fileId: string }): Promise<OpenAIFileDownloadUrlResult>;\n\n // --- Modal API ---\n requestModal?(params: OpenAIRequestModalParams): Promise<void>;\n\n // --- Checkout API ---\n requestCheckout?(session: OpenAICheckoutSession): Promise<OpenAICheckoutOrder>;\n\n // --- Display ---\n requestClose?(): void;\n requestDisplayMode?(params: { mode: 'inline' | 'PiP' | 'fullscreen' }): Promise<void>;\n\n // --- Messaging ---\n sendFollowUpMessage?(params: { prompt: string }): void;\n\n // --- Other ---\n openExternal?(params: { href: string }): void;\n}\n\n/**\n * Get the `window.openai` runtime if available.\n * Returns `undefined` outside of ChatGPT or in SSR.\n */\nexport function getOpenAIRuntime(): OpenAIRuntime | undefined {\n if (typeof window !== 'undefined' && 'openai' in window) {\n return (window as unknown as { openai: OpenAIRuntime }).openai;\n }\n return undefined;\n}\n","import { useCallback } from 'react';\nimport { useApp } from '../../hooks/use-app';\nimport { getOpenAIRuntime, type OpenAIUploadFileResult } from './openai-types';\n\nexport type { OpenAIUploadFileResult as CreateFileResult };\n\n/**\n * Upload a file from the app UI into the ChatGPT conversation.\n *\n * Wraps `window.openai.uploadFile` which is only available inside ChatGPT.\n * Supported formats: `image/png`, `image/jpeg`, `image/webp`.\n *\n * Import from `sunpeak/host/chatgpt`:\n *\n * @example\n * ```tsx\n * import { useUploadFile } from 'sunpeak/host/chatgpt';\n *\n * function ImageUploader() {\n * const uploadFile = useUploadFile();\n *\n * const handleChange = async (e: React.ChangeEvent<HTMLInputElement>) => {\n * const file = e.currentTarget.files?.[0];\n * if (!file) return;\n * const { fileId } = await uploadFile(file);\n * console.log('Uploaded:', fileId);\n * };\n *\n * return <input type=\"file\" accept=\"image/*\" onChange={handleChange} />;\n * }\n * ```\n */\nexport function useUploadFile(): (file: File) => Promise<OpenAIUploadFileResult> {\n const app = useApp();\n return useCallback(\n async (file: File) => {\n if (!app) {\n throw new Error('[useUploadFile] App not connected');\n }\n const runtime = getOpenAIRuntime();\n if (!runtime?.uploadFile) {\n throw new Error('[useUploadFile] window.openai.uploadFile not available');\n }\n return runtime.uploadFile(file);\n },\n [app]\n );\n}\n","import { useCallback } from 'react';\nimport { useApp } from '../../hooks/use-app';\nimport { getOpenAIRuntime, type OpenAIFileDownloadUrlResult } from './openai-types';\n\nexport type { OpenAIFileDownloadUrlResult as FileDownloadUrlResult };\n\n/**\n * Get a temporary download URL for a file by its ID.\n *\n * @deprecated Use {@link useDownloadFile} from `sunpeak` instead — it works\n * across all hosts via the MCP Apps SDK `app.downloadFile()` method.\n *\n * Wraps `window.openai.getFileDownloadUrl` which is only available inside\n * ChatGPT. Use this to retrieve URLs for files uploaded via {@link useUploadFile}\n * or file IDs received in tool parameters.\n *\n * Import from `sunpeak/host/chatgpt`:\n *\n * @example\n * ```tsx\n * import { useGetFileDownloadUrl } from 'sunpeak/host/chatgpt';\n *\n * function FilePreview({ fileId }: { fileId: string }) {\n * const getFileDownloadUrl = useGetFileDownloadUrl();\n * const [src, setSrc] = useState<string>();\n *\n * useEffect(() => {\n * getFileDownloadUrl({ fileId }).then(({ downloadUrl }) => setSrc(downloadUrl));\n * }, [fileId, getFileDownloadUrl]);\n *\n * return src ? <img src={src} /> : <p>Loading...</p>;\n * }\n * ```\n */\nexport function useGetFileDownloadUrl(): (params: {\n fileId: string;\n}) => Promise<OpenAIFileDownloadUrlResult> {\n const app = useApp();\n return useCallback(\n async (params: { fileId: string }) => {\n if (!app) {\n throw new Error('[useGetFileDownloadUrl] App not connected');\n }\n const runtime = getOpenAIRuntime();\n if (!runtime?.getFileDownloadUrl) {\n throw new Error('[useGetFileDownloadUrl] window.openai.getFileDownloadUrl not available');\n }\n return runtime.getFileDownloadUrl(params);\n },\n [app]\n );\n}\n","import { useCallback } from 'react';\nimport { useApp } from '../../hooks/use-app';\nimport { getOpenAIRuntime, type OpenAIRequestModalParams } from './openai-types';\n\nexport type { OpenAIRequestModalParams as OpenModalParams };\n\n/**\n * Open a host-controlled modal in ChatGPT.\n *\n * Wraps `window.openai.requestModal` which is only available inside ChatGPT.\n * Pass a `template` URL to load alternate UI content in the modal, or omit\n * it to reuse the current UI.\n *\n * Import from `sunpeak/host/chatgpt`:\n *\n * @example\n * ```tsx\n * import { useRequestModal } from 'sunpeak/host/chatgpt';\n *\n * function CheckoutButton() {\n * const requestModal = useRequestModal();\n *\n * return (\n * <button onClick={() => requestModal({ template: 'ui://widget/checkout.html' })}>\n * Checkout\n * </button>\n * );\n * }\n * ```\n */\nexport function useRequestModal(): (params: OpenAIRequestModalParams) => Promise<void> {\n const app = useApp();\n return useCallback(\n async (params: OpenAIRequestModalParams) => {\n if (!app) {\n console.warn('[useRequestModal] App not connected');\n return;\n }\n const runtime = getOpenAIRuntime();\n if (!runtime?.requestModal) {\n throw new Error('[useRequestModal] window.openai.requestModal not available');\n }\n return runtime.requestModal(params);\n },\n [app]\n );\n}\n","import { useCallback } from 'react';\nimport { useApp } from '../../hooks/use-app';\nimport {\n getOpenAIRuntime,\n type OpenAICheckoutSession,\n type OpenAICheckoutOrder,\n} from './openai-types';\n\nexport type { OpenAICheckoutSession as CheckoutSession };\nexport type { OpenAICheckoutOrder as CheckoutOrder };\n\n/**\n * Trigger the ChatGPT instant checkout flow.\n *\n * Wraps `window.openai.requestCheckout` which is only available inside\n * ChatGPT. Opens the host checkout UI, handles payment display, and\n * resolves with the finalized order. Rejects on error or user cancel.\n *\n * Import from `sunpeak/host/chatgpt`:\n *\n * @example\n * ```tsx\n * import { useRequestCheckout } from 'sunpeak/host/chatgpt';\n *\n * function BuyButton() {\n * const requestCheckout = useRequestCheckout();\n *\n * const handleBuy = async () => {\n * try {\n * const order = await requestCheckout({\n * id: 'session-1',\n * payment_provider: {\n * provider: 'stripe',\n * merchant_id: 'acct_xxx',\n * supported_payment_methods: ['card', 'apple_pay'],\n * },\n * status: 'ready_for_payment',\n * currency: 'USD',\n * totals: [{ type: 'total', display_text: 'Total', amount: 999 }],\n * links: [],\n * payment_mode: 'live',\n * });\n * console.log('Order completed:', order.id);\n * } catch {\n * console.log('Checkout cancelled or failed');\n * }\n * };\n *\n * return <button onClick={handleBuy}>Buy Now</button>;\n * }\n * ```\n */\nexport function useRequestCheckout(): (\n session: OpenAICheckoutSession\n) => Promise<OpenAICheckoutOrder> {\n const app = useApp();\n return useCallback(\n async (session: OpenAICheckoutSession) => {\n if (!app) {\n throw new Error('[useRequestCheckout] App not connected');\n }\n const runtime = getOpenAIRuntime();\n if (!runtime?.requestCheckout) {\n throw new Error('[useRequestCheckout] window.openai.requestCheckout not available');\n }\n return runtime.requestCheckout(session);\n },\n [app]\n );\n}\n"],"mappings":";;;;;;;;AAuFA,SAAgB,mBAA8C;AAC5D,KAAI,OAAO,WAAW,eAAe,YAAY,OAC/C,QAAQ,OAAgD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACzD5D,SAAgB,gBAAiE;CAC/E,MAAM,MAAM,QAAQ;AACpB,QAAO,YACL,OAAO,SAAe;AACpB,MAAI,CAAC,IACH,OAAM,IAAI,MAAM,oCAAoC;EAEtD,MAAM,UAAU,kBAAkB;AAClC,MAAI,CAAC,SAAS,WACZ,OAAM,IAAI,MAAM,yDAAyD;AAE3E,SAAO,QAAQ,WAAW,KAAK;IAEjC,CAAC,IAAI,CACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACZH,SAAgB,wBAE2B;CACzC,MAAM,MAAM,QAAQ;AACpB,QAAO,YACL,OAAO,WAA+B;AACpC,MAAI,CAAC,IACH,OAAM,IAAI,MAAM,4CAA4C;EAE9D,MAAM,UAAU,kBAAkB;AAClC,MAAI,CAAC,SAAS,mBACZ,OAAM,IAAI,MAAM,yEAAyE;AAE3F,SAAO,QAAQ,mBAAmB,OAAO;IAE3C,CAAC,IAAI,CACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACpBH,SAAgB,kBAAuE;CACrF,MAAM,MAAM,QAAQ;AACpB,QAAO,YACL,OAAO,WAAqC;AAC1C,MAAI,CAAC,KAAK;AACR,WAAQ,KAAK,sCAAsC;AACnD;;EAEF,MAAM,UAAU,kBAAkB;AAClC,MAAI,CAAC,SAAS,aACZ,OAAM,IAAI,MAAM,6DAA6D;AAE/E,SAAO,QAAQ,aAAa,OAAO;IAErC,CAAC,IAAI,CACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACOH,SAAgB,qBAEkB;CAChC,MAAM,MAAM,QAAQ;AACpB,QAAO,YACL,OAAO,YAAmC;AACxC,MAAI,CAAC,IACH,OAAM,IAAI,MAAM,yCAAyC;EAE3D,MAAM,UAAU,kBAAkB;AAClC,MAAI,CAAC,SAAS,gBACZ,OAAM,IAAI,MAAM,mEAAmE;AAErF,SAAO,QAAQ,gBAAgB,QAAQ;IAEzC,CAAC,IAAI,CACN"}
@@ -1,30 +1,58 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../chunk-9hOWP6kD.cjs");
3
+ //#region src/host/index.ts
4
+ /**
5
+ * Detect the current host.
6
+ *
7
+ * Detection is based on:
8
+ * 1. Host runtime objects (window.openai for ChatGPT — works in both
9
+ * real hosts and the simulator when the ChatGPT host shell is active)
10
+ * 2. User agent patterns as fallback
11
+ * 3. Hostname matching as final fallback
12
+ *
13
+ * @returns The detected host
14
+ */
3
15
  function detectHost() {
4
- if (typeof window === "undefined") {
5
- return "unknown";
6
- }
7
- if ("openai" in window) {
8
- return "chatgpt";
9
- }
10
- const ua = navigator.userAgent.toLowerCase();
11
- if (ua.includes("chatgpt") || window.location.hostname.includes("chatgpt.com")) {
12
- return "chatgpt";
13
- }
14
- if (ua.includes("claude") || window.location.hostname.includes("claude.ai")) {
15
- return "claude";
16
- }
17
- return "unknown";
16
+ if (typeof window === "undefined") return "unknown";
17
+ if ("openai" in window) return "chatgpt";
18
+ const ua = navigator.userAgent.toLowerCase();
19
+ if (ua.includes("chatgpt") || window.location.hostname.includes("chatgpt.com")) return "chatgpt";
20
+ if (ua.includes("claude") || window.location.hostname.includes("claude.ai")) return "claude";
21
+ return "unknown";
18
22
  }
23
+ /**
24
+ * Check if the app is running in a ChatGPT host.
25
+ *
26
+ * @returns true if running in ChatGPT
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * import { isChatGPT } from 'sunpeak/host';
31
+ *
32
+ * function MyResource() {
33
+ * if (isChatGPT()) {
34
+ * // Use ChatGPT-specific features
35
+ * }
36
+ * }
37
+ * ```
38
+ */
19
39
  function isChatGPT() {
20
- return detectHost() === "chatgpt";
40
+ return detectHost() === "chatgpt";
21
41
  }
42
+ /**
43
+ * Check if the app is running in a Claude host.
44
+ *
45
+ * @returns true if running in Claude
46
+ */
22
47
  function isClaude() {
23
- return detectHost() === "claude";
48
+ return detectHost() === "claude";
24
49
  }
25
- const detectPlatform = detectHost;
50
+ /** @deprecated Use `detectHost` instead. */
51
+ var detectPlatform = detectHost;
52
+ //#endregion
26
53
  exports.detectHost = detectHost;
27
54
  exports.detectPlatform = detectPlatform;
28
55
  exports.isChatGPT = isChatGPT;
29
56
  exports.isClaude = isClaude;
30
- //# sourceMappingURL=index.cjs.map
57
+
58
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/host/index.ts"],"sourcesContent":["/**\n * Host detection utilities for MCP Apps.\n *\n * Use these functions to detect which host is running your app\n * and conditionally use host-specific features.\n *\n * @example\n * ```tsx\n * import { isChatGPT } from 'sunpeak/host';\n *\n * function MyResource() {\n * // Only use ChatGPT-specific features when running on ChatGPT\n * if (isChatGPT()) {\n * // Use updateModelContext, etc.\n * }\n * }\n * ```\n */\n\n/**\n * Supported hosts.\n */\nexport type Host = 'chatgpt' | 'claude' | 'unknown';\n\n/**\n * Detect the current host.\n *\n * Detection is based on:\n * 1. Host runtime objects (window.openai for ChatGPT — works in both\n * real hosts and the simulator when the ChatGPT host shell is active)\n * 2. User agent patterns as fallback\n * 3. Hostname matching as final fallback\n *\n * @returns The detected host\n */\nexport function detectHost(): Host {\n // Check if we're in a browser environment\n if (typeof window === 'undefined') {\n return 'unknown';\n }\n\n // ChatGPT injects window.openai; the simulator does the same when\n // the ChatGPT host shell is selected. This is the most reliable signal.\n if ('openai' in window) {\n return 'chatgpt';\n }\n\n // Check user agent patterns for host detection\n const ua = navigator.userAgent.toLowerCase();\n\n // ChatGPT iOS/Android apps and web\n if (ua.includes('chatgpt') || window.location.hostname.includes('chatgpt.com')) {\n return 'chatgpt';\n }\n\n // Claude apps and web\n if (ua.includes('claude') || window.location.hostname.includes('claude.ai')) {\n return 'claude';\n }\n\n return 'unknown';\n}\n\n/**\n * Check if the app is running in a ChatGPT host.\n *\n * @returns true if running in ChatGPT\n *\n * @example\n * ```tsx\n * import { isChatGPT } from 'sunpeak/host';\n *\n * function MyResource() {\n * if (isChatGPT()) {\n * // Use ChatGPT-specific features\n * }\n * }\n * ```\n */\nexport function isChatGPT(): boolean {\n return detectHost() === 'chatgpt';\n}\n\n/**\n * Check if the app is running in a Claude host.\n *\n * @returns true if running in Claude\n */\nexport function isClaude(): boolean {\n return detectHost() === 'claude';\n}\n\n/** @deprecated Use `Host` instead. */\nexport type Platform = Host;\n\n/** @deprecated Use `detectHost` instead. */\nexport const detectPlatform = detectHost;\n"],"names":[],"mappings":";;AAmCO,SAAS,aAAmB;AAEjC,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO;AAAA,EACT;AAIA,MAAI,YAAY,QAAQ;AACtB,WAAO;AAAA,EACT;AAGA,QAAM,KAAK,UAAU,UAAU,YAAA;AAG/B,MAAI,GAAG,SAAS,SAAS,KAAK,OAAO,SAAS,SAAS,SAAS,aAAa,GAAG;AAC9E,WAAO;AAAA,EACT;AAGA,MAAI,GAAG,SAAS,QAAQ,KAAK,OAAO,SAAS,SAAS,SAAS,WAAW,GAAG;AAC3E,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAkBO,SAAS,YAAqB;AACnC,SAAO,iBAAiB;AAC1B;AAOO,SAAS,WAAoB;AAClC,SAAO,iBAAiB;AAC1B;AAMO,MAAM,iBAAiB;;;;;"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/host/index.ts"],"sourcesContent":["/**\n * Host detection utilities for MCP Apps.\n *\n * Use these functions to detect which host is running your app\n * and conditionally use host-specific features.\n *\n * @example\n * ```tsx\n * import { isChatGPT } from 'sunpeak/host';\n *\n * function MyResource() {\n * // Only use ChatGPT-specific features when running on ChatGPT\n * if (isChatGPT()) {\n * // Use updateModelContext, etc.\n * }\n * }\n * ```\n */\n\n/**\n * Supported hosts.\n */\nexport type Host = 'chatgpt' | 'claude' | 'unknown';\n\n/**\n * Detect the current host.\n *\n * Detection is based on:\n * 1. Host runtime objects (window.openai for ChatGPT — works in both\n * real hosts and the simulator when the ChatGPT host shell is active)\n * 2. User agent patterns as fallback\n * 3. Hostname matching as final fallback\n *\n * @returns The detected host\n */\nexport function detectHost(): Host {\n // Check if we're in a browser environment\n if (typeof window === 'undefined') {\n return 'unknown';\n }\n\n // ChatGPT injects window.openai; the simulator does the same when\n // the ChatGPT host shell is selected. This is the most reliable signal.\n if ('openai' in window) {\n return 'chatgpt';\n }\n\n // Check user agent patterns for host detection\n const ua = navigator.userAgent.toLowerCase();\n\n // ChatGPT iOS/Android apps and web\n if (ua.includes('chatgpt') || window.location.hostname.includes('chatgpt.com')) {\n return 'chatgpt';\n }\n\n // Claude apps and web\n if (ua.includes('claude') || window.location.hostname.includes('claude.ai')) {\n return 'claude';\n }\n\n return 'unknown';\n}\n\n/**\n * Check if the app is running in a ChatGPT host.\n *\n * @returns true if running in ChatGPT\n *\n * @example\n * ```tsx\n * import { isChatGPT } from 'sunpeak/host';\n *\n * function MyResource() {\n * if (isChatGPT()) {\n * // Use ChatGPT-specific features\n * }\n * }\n * ```\n */\nexport function isChatGPT(): boolean {\n return detectHost() === 'chatgpt';\n}\n\n/**\n * Check if the app is running in a Claude host.\n *\n * @returns true if running in Claude\n */\nexport function isClaude(): boolean {\n return detectHost() === 'claude';\n}\n\n/** @deprecated Use `Host` instead. */\nexport type Platform = Host;\n\n/** @deprecated Use `detectHost` instead. */\nexport const detectPlatform = detectHost;\n"],"mappings":";;;;;;;;;;;;;;AAmCA,SAAgB,aAAmB;AAEjC,KAAI,OAAO,WAAW,YACpB,QAAO;AAKT,KAAI,YAAY,OACd,QAAO;CAIT,MAAM,KAAK,UAAU,UAAU,aAAa;AAG5C,KAAI,GAAG,SAAS,UAAU,IAAI,OAAO,SAAS,SAAS,SAAS,cAAc,CAC5E,QAAO;AAIT,KAAI,GAAG,SAAS,SAAS,IAAI,OAAO,SAAS,SAAS,SAAS,YAAY,CACzE,QAAO;AAGT,QAAO;;;;;;;;;;;;;;;;;;AAmBT,SAAgB,YAAqB;AACnC,QAAO,YAAY,KAAK;;;;;;;AAQ1B,SAAgB,WAAoB;AAClC,QAAO,YAAY,KAAK;;;AAO1B,IAAa,iBAAiB"}
@@ -1,30 +1,53 @@
1
+ //#region src/host/index.ts
2
+ /**
3
+ * Detect the current host.
4
+ *
5
+ * Detection is based on:
6
+ * 1. Host runtime objects (window.openai for ChatGPT — works in both
7
+ * real hosts and the simulator when the ChatGPT host shell is active)
8
+ * 2. User agent patterns as fallback
9
+ * 3. Hostname matching as final fallback
10
+ *
11
+ * @returns The detected host
12
+ */
1
13
  function detectHost() {
2
- if (typeof window === "undefined") {
3
- return "unknown";
4
- }
5
- if ("openai" in window) {
6
- return "chatgpt";
7
- }
8
- const ua = navigator.userAgent.toLowerCase();
9
- if (ua.includes("chatgpt") || window.location.hostname.includes("chatgpt.com")) {
10
- return "chatgpt";
11
- }
12
- if (ua.includes("claude") || window.location.hostname.includes("claude.ai")) {
13
- return "claude";
14
- }
15
- return "unknown";
14
+ if (typeof window === "undefined") return "unknown";
15
+ if ("openai" in window) return "chatgpt";
16
+ const ua = navigator.userAgent.toLowerCase();
17
+ if (ua.includes("chatgpt") || window.location.hostname.includes("chatgpt.com")) return "chatgpt";
18
+ if (ua.includes("claude") || window.location.hostname.includes("claude.ai")) return "claude";
19
+ return "unknown";
16
20
  }
21
+ /**
22
+ * Check if the app is running in a ChatGPT host.
23
+ *
24
+ * @returns true if running in ChatGPT
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * import { isChatGPT } from 'sunpeak/host';
29
+ *
30
+ * function MyResource() {
31
+ * if (isChatGPT()) {
32
+ * // Use ChatGPT-specific features
33
+ * }
34
+ * }
35
+ * ```
36
+ */
17
37
  function isChatGPT() {
18
- return detectHost() === "chatgpt";
38
+ return detectHost() === "chatgpt";
19
39
  }
40
+ /**
41
+ * Check if the app is running in a Claude host.
42
+ *
43
+ * @returns true if running in Claude
44
+ */
20
45
  function isClaude() {
21
- return detectHost() === "claude";
46
+ return detectHost() === "claude";
22
47
  }
23
- const detectPlatform = detectHost;
24
- export {
25
- detectHost,
26
- detectPlatform,
27
- isChatGPT,
28
- isClaude
29
- };
30
- //# sourceMappingURL=index.js.map
48
+ /** @deprecated Use `detectHost` instead. */
49
+ var detectPlatform = detectHost;
50
+ //#endregion
51
+ export { detectHost, detectPlatform, isChatGPT, isClaude };
52
+
53
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/host/index.ts"],"sourcesContent":["/**\n * Host detection utilities for MCP Apps.\n *\n * Use these functions to detect which host is running your app\n * and conditionally use host-specific features.\n *\n * @example\n * ```tsx\n * import { isChatGPT } from 'sunpeak/host';\n *\n * function MyResource() {\n * // Only use ChatGPT-specific features when running on ChatGPT\n * if (isChatGPT()) {\n * // Use updateModelContext, etc.\n * }\n * }\n * ```\n */\n\n/**\n * Supported hosts.\n */\nexport type Host = 'chatgpt' | 'claude' | 'unknown';\n\n/**\n * Detect the current host.\n *\n * Detection is based on:\n * 1. Host runtime objects (window.openai for ChatGPT — works in both\n * real hosts and the simulator when the ChatGPT host shell is active)\n * 2. User agent patterns as fallback\n * 3. Hostname matching as final fallback\n *\n * @returns The detected host\n */\nexport function detectHost(): Host {\n // Check if we're in a browser environment\n if (typeof window === 'undefined') {\n return 'unknown';\n }\n\n // ChatGPT injects window.openai; the simulator does the same when\n // the ChatGPT host shell is selected. This is the most reliable signal.\n if ('openai' in window) {\n return 'chatgpt';\n }\n\n // Check user agent patterns for host detection\n const ua = navigator.userAgent.toLowerCase();\n\n // ChatGPT iOS/Android apps and web\n if (ua.includes('chatgpt') || window.location.hostname.includes('chatgpt.com')) {\n return 'chatgpt';\n }\n\n // Claude apps and web\n if (ua.includes('claude') || window.location.hostname.includes('claude.ai')) {\n return 'claude';\n }\n\n return 'unknown';\n}\n\n/**\n * Check if the app is running in a ChatGPT host.\n *\n * @returns true if running in ChatGPT\n *\n * @example\n * ```tsx\n * import { isChatGPT } from 'sunpeak/host';\n *\n * function MyResource() {\n * if (isChatGPT()) {\n * // Use ChatGPT-specific features\n * }\n * }\n * ```\n */\nexport function isChatGPT(): boolean {\n return detectHost() === 'chatgpt';\n}\n\n/**\n * Check if the app is running in a Claude host.\n *\n * @returns true if running in Claude\n */\nexport function isClaude(): boolean {\n return detectHost() === 'claude';\n}\n\n/** @deprecated Use `Host` instead. */\nexport type Platform = Host;\n\n/** @deprecated Use `detectHost` instead. */\nexport const detectPlatform = detectHost;\n"],"names":[],"mappings":"AAmCO,SAAS,aAAmB;AAEjC,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO;AAAA,EACT;AAIA,MAAI,YAAY,QAAQ;AACtB,WAAO;AAAA,EACT;AAGA,QAAM,KAAK,UAAU,UAAU,YAAA;AAG/B,MAAI,GAAG,SAAS,SAAS,KAAK,OAAO,SAAS,SAAS,SAAS,aAAa,GAAG;AAC9E,WAAO;AAAA,EACT;AAGA,MAAI,GAAG,SAAS,QAAQ,KAAK,OAAO,SAAS,SAAS,SAAS,WAAW,GAAG;AAC3E,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAkBO,SAAS,YAAqB;AACnC,SAAO,iBAAiB;AAC1B;AAOO,SAAS,WAAoB;AAClC,SAAO,iBAAiB;AAC1B;AAMO,MAAM,iBAAiB;"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/host/index.ts"],"sourcesContent":["/**\n * Host detection utilities for MCP Apps.\n *\n * Use these functions to detect which host is running your app\n * and conditionally use host-specific features.\n *\n * @example\n * ```tsx\n * import { isChatGPT } from 'sunpeak/host';\n *\n * function MyResource() {\n * // Only use ChatGPT-specific features when running on ChatGPT\n * if (isChatGPT()) {\n * // Use updateModelContext, etc.\n * }\n * }\n * ```\n */\n\n/**\n * Supported hosts.\n */\nexport type Host = 'chatgpt' | 'claude' | 'unknown';\n\n/**\n * Detect the current host.\n *\n * Detection is based on:\n * 1. Host runtime objects (window.openai for ChatGPT — works in both\n * real hosts and the simulator when the ChatGPT host shell is active)\n * 2. User agent patterns as fallback\n * 3. Hostname matching as final fallback\n *\n * @returns The detected host\n */\nexport function detectHost(): Host {\n // Check if we're in a browser environment\n if (typeof window === 'undefined') {\n return 'unknown';\n }\n\n // ChatGPT injects window.openai; the simulator does the same when\n // the ChatGPT host shell is selected. This is the most reliable signal.\n if ('openai' in window) {\n return 'chatgpt';\n }\n\n // Check user agent patterns for host detection\n const ua = navigator.userAgent.toLowerCase();\n\n // ChatGPT iOS/Android apps and web\n if (ua.includes('chatgpt') || window.location.hostname.includes('chatgpt.com')) {\n return 'chatgpt';\n }\n\n // Claude apps and web\n if (ua.includes('claude') || window.location.hostname.includes('claude.ai')) {\n return 'claude';\n }\n\n return 'unknown';\n}\n\n/**\n * Check if the app is running in a ChatGPT host.\n *\n * @returns true if running in ChatGPT\n *\n * @example\n * ```tsx\n * import { isChatGPT } from 'sunpeak/host';\n *\n * function MyResource() {\n * if (isChatGPT()) {\n * // Use ChatGPT-specific features\n * }\n * }\n * ```\n */\nexport function isChatGPT(): boolean {\n return detectHost() === 'chatgpt';\n}\n\n/**\n * Check if the app is running in a Claude host.\n *\n * @returns true if running in Claude\n */\nexport function isClaude(): boolean {\n return detectHost() === 'claude';\n}\n\n/** @deprecated Use `Host` instead. */\nexport type Platform = Host;\n\n/** @deprecated Use `detectHost` instead. */\nexport const detectPlatform = detectHost;\n"],"mappings":";;;;;;;;;;;;AAmCA,SAAgB,aAAmB;AAEjC,KAAI,OAAO,WAAW,YACpB,QAAO;AAKT,KAAI,YAAY,OACd,QAAO;CAIT,MAAM,KAAK,UAAU,UAAU,aAAa;AAG5C,KAAI,GAAG,SAAS,UAAU,IAAI,OAAO,SAAS,SAAS,SAAS,cAAc,CAC5E,QAAO;AAIT,KAAI,GAAG,SAAS,SAAS,IAAI,OAAO,SAAS,SAAS,SAAS,YAAY,CACzE,QAAO;AAGT,QAAO;;;;;;;;;;;;;;;;;;AAmBT,SAAgB,YAAqB;AACnC,QAAO,YAAY,KAAK;;;;;;;AAQ1B,SAAgB,WAAoB;AAClC,QAAO,YAAY,KAAK;;;AAO1B,IAAa,iBAAiB"}