@adaptive-ai/sdk 0.0.6 → 0.0.7

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.
@@ -54,7 +54,7 @@ declare global {
54
54
  fromUserId: string;
55
55
  }
56
56
  interface Window {
57
- __VERSION_ID__: string;
57
+ __VERSION_ID__?: string;
58
58
  __APP_ID__: string;
59
59
  __IS_TESTING__: boolean;
60
60
  __ROOT_URL__: string;
@@ -65,6 +65,14 @@ declare global {
65
65
  }
66
66
 
67
67
  declare function encodeFileAsBase64DataURL(file: File): Promise<string>;
68
+ declare function initializeClientEnvironment({ appId, rootUrl, baseUrl, versionId, isTesting, realtimeDomain, }: {
69
+ appId: string;
70
+ rootUrl: string;
71
+ baseUrl: string;
72
+ versionId?: string;
73
+ isTesting: boolean;
74
+ realtimeDomain: string;
75
+ }): void;
68
76
  declare function useRedirectToLogin(): {
69
77
  redirectToLogin: (input?: {
70
78
  email?: string;
@@ -91,4 +99,4 @@ declare function connectToRealtimeStore<T extends object>({ channelId, initialDa
91
99
  declare function useRealtimeStore<T extends object>(channelId: string | null, initialData: T): readonly [T | undefined, (data: T) => void];
92
100
  declare function useRealtimeMutation<TData extends object, TError = unknown, TVariables = void, TContext = unknown>(fn: MutationFunction<TData, TVariables>, opts?: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, 'mutationFn'>): UseMutationResult<TData, TError, TVariables, TContext>;
93
101
 
94
- export { connectToRealtimeStore, encodeFileAsBase64DataURL, getBaseUrl, useAuth, useRealtimeMutation, useRealtimeStore, useRedirectToLogin };
102
+ export { connectToRealtimeStore, encodeFileAsBase64DataURL, getBaseUrl, initializeClientEnvironment, useAuth, useRealtimeMutation, useRealtimeStore, useRedirectToLogin };
@@ -1,2 +1,2 @@
1
- import {useMutation}from'@tanstack/react-query';import {identity}from'lodash';import {nanoid}from'nanoid';import {useState,useEffect,useRef,useCallback}from'react';import p from'superjson';function b(e){return new Promise(r=>{let n=new FileReader;n.onload=()=>{r(n.result);},n.readAsDataURL(e);})}var l=e=>{let{email:r,phoneNumber:n}=e??{},s=r??n,t=new URLSearchParams;e&&"redirectUri"in e&&e.redirectUri?t.set("returnTo",e.redirectUri):t.set("returnTo",window.location.pathname+window.location.search),e?.provider&&e.provider!="AC1"&&(t.set("provider",e.provider),e.scope&&e.scope.length>0&&t.set("scope",e.scope.join(","))),e?.provider=="AC1"&&s&&t.set("identity",s),t.set("stripped","true");let o=window.__APP_ID__;window.__OPEN_AUTH_DRAWER__(`${window.__ROOT_URL__}/setup/${o}?${t.toString()}`);};function M(){return {redirectToLogin:e=>e?.email?l({email:e.email,provider:"AC1"}):l()}}function $(e={}){let[r,n]=useState({userId:void 0,status:"loading",signIn:l,providers:[]});return useEffect(()=>{(async()=>{try{let o=await(await fetch("/api/session",{method:"POST",headers:{"Content-Type":"application/json","x-guest-api-internal":"session","x-version-id":window.__VERSION_ID__,...window.__IS_TESTING__?{"x-is-testing":"true"}:{}}})).json()??{};n({userId:o.userId??null,status:"authenticated",signIn:l,providers:o?.providers??[]});}catch{if(e.required){let o=encodeURIComponent(window.location.pathname+window.location.search),d=window.__APP_ID__;window.top?window.top.location.href=`${window.__ROOT_URL__}/setup/${d}?returnTo=${o}`:window.location.href=`${window.__ROOT_URL__}/setup/${d}?returnTo=${o}`;}else n({userId:null,status:"unauthenticated",signIn:l,providers:[]});}})();},[e.required]),r}function C(){return window.__BASE_URL__}async function I({channelId:e,initialData:r,broadcastOnly:n,onUpdate:s}){let t=r,o=0,d=window.__REALTIME_DOMAIN__;if(n)return {getData(){return t},setData(u){t=u,fetch(`https://${d}/${e}`,{method:"POST",body:p.stringify(t)}).catch(console.error),s?.(u);},destroy(){}};let a=new WebSocket(`wss://${d}/${e}`);return new Promise((u,w)=>{function T(i){try{let c=JSON.parse(i.data.toString());c?.id&&c.id>o?(t=p.parse(c.payload),s?.(t),o=c.id):console.error("Invalid message:",i.data);}catch{console.error("Error parsing message:",i.data);}}function h(i){m(),w(i);}function R(){u({getData(){return t},setData(i){t=i,s?.(i),a.send(p.stringify(i));},destroy:m});}function m(){a.removeEventListener("message",T),a.removeEventListener("error",h),a.removeEventListener("open",R),a.close();}a.addEventListener("message",T),a.addEventListener("error",h),a.addEventListener("open",R);})}function L(e,r){let n=useRef(null),[s,t]=useState(0);return useEffect(()=>((async()=>e&&(n.current=await I({channelId:e,initialData:r,onUpdate:()=>{t(o=>o+1);}})))(),n.current?.destroy),[e,t]),[n.current?.getData(),n.current?.setData??identity]}function P(e,r){let[n,s]=useState(null),[t]=L(n,void 0),o=useCallback(async a=>{let u=nanoid(32);return s(u),await e?.({...a,__channelId:u})},[e]);return {...useMutation(o,r),data:t}}
2
- export{I as connectToRealtimeStore,b as encodeFileAsBase64DataURL,C as getBaseUrl,$ as useAuth,P as useRealtimeMutation,L as useRealtimeStore,M as useRedirectToLogin};
1
+ import {useMutation}from'@tanstack/react-query';import {identity}from'lodash';import {nanoid}from'nanoid';import {useState,useEffect,useRef,useCallback}from'react';import _ from'superjson';function b(e){return new Promise(r=>{let n=new FileReader;n.onload=()=>{r(n.result);},n.readAsDataURL(e);})}function M({appId:e,rootUrl:r,baseUrl:n,versionId:i,isTesting:t,realtimeDomain:o}){window.__APP_ID__=e,window.__ROOT_URL__=r,window.__BASE_URL__=n,i&&(window.__VERSION_ID__=i),window.__IS_TESTING__=t,window.__REALTIME_DOMAIN__=o;}var l=e=>{let{email:r,phoneNumber:n}=e??{},i=r??n,t=new URLSearchParams;e&&"redirectUri"in e&&e.redirectUri?t.set("returnTo",e.redirectUri):t.set("returnTo",window.location.pathname+window.location.search),e?.provider&&"scope"in e&&(t.set("provider",e.provider),e.scope&&e.scope.length>0&&t.set("scope",e.scope.join(","))),e?.provider=="AC1"&&i&&t.set("identity",i),t.set("stripped","true");let o=window.__APP_ID__;window.__OPEN_AUTH_DRAWER__(`${window.__ROOT_URL__}/setup/${o}?${t.toString()}`);};function P(){return {redirectToLogin:e=>e?.email?l({email:e.email,provider:"AC1"}):l()}}function $(e={}){let[r,n]=useState({userId:void 0,status:"loading",signIn:l,providers:[]});return useEffect(()=>{(async()=>{try{let o=await(await fetch("/api/session",{method:"POST",headers:{"Content-Type":"application/json","x-guest-api-internal":"session",...window.__VERSION_ID__?{"x-version-id":window.__VERSION_ID__}:{},...window.__IS_TESTING__?{"x-is-testing":"true"}:{}}})).json()??{};n({userId:o.userId??null,status:"authenticated",signIn:l,providers:o?.providers??[]});}catch{if(e.required){let o=encodeURIComponent(window.location.pathname+window.location.search),d=window.__APP_ID__;window.top?window.top.location.href=`${window.__ROOT_URL__}/setup/${d}?returnTo=${o}`:window.location.href=`${window.__ROOT_URL__}/setup/${d}?returnTo=${o}`;}else n({userId:null,status:"unauthenticated",signIn:l,providers:[]});}})();},[e.required]),r}function C(){return window.__BASE_URL__}async function U({channelId:e,initialData:r,broadcastOnly:n,onUpdate:i}){let t=r,o=0,d=window.__REALTIME_DOMAIN__;if(n)return {getData(){return t},setData(u){t=u,fetch(`https://${d}/${e}`,{method:"POST",body:_.stringify(t)}).catch(console.error),i?.(u);},destroy(){}};let s=new WebSocket(`wss://${d}/${e}`);return new Promise((u,w)=>{function T(a){try{let c=JSON.parse(a.data.toString());c?.id&&c.id>o?(t=_.parse(c.payload),i?.(t),o=c.id):console.error("Invalid message:",a.data);}catch{console.error("Error parsing message:",a.data);}}function R(a){m(),w(a);}function h(){u({getData(){return t},setData(a){t=a,i?.(a),s.send(_.stringify(a));},destroy:m});}function m(){s.removeEventListener("message",T),s.removeEventListener("error",R),s.removeEventListener("open",h),s.close();}s.addEventListener("message",T),s.addEventListener("error",R),s.addEventListener("open",h);})}function v(e,r){let n=useRef(null),[i,t]=useState(0);return useEffect(()=>((async()=>e&&(n.current=await U({channelId:e,initialData:r,onUpdate:()=>{t(o=>o+1);}})))(),n.current?.destroy),[e,t]),[n.current?.getData(),n.current?.setData??identity]}function N(e,r){let[n,i]=useState(null),[t]=v(n,void 0),o=useCallback(async s=>{let u=nanoid(32);return i(u),await e?.({...s,__channelId:u})},[e]);return {...useMutation(o,r),data:t}}
2
+ export{U as connectToRealtimeStore,b as encodeFileAsBase64DataURL,C as getBaseUrl,M as initializeClientEnvironment,$ as useAuth,N as useRealtimeMutation,v as useRealtimeStore,P as useRedirectToLogin};
@@ -120,7 +120,7 @@ declare global {
120
120
  fromUserId: string;
121
121
  }
122
122
  interface Window {
123
- __VERSION_ID__: string;
123
+ __VERSION_ID__?: string;
124
124
  __APP_ID__: string;
125
125
  __IS_TESTING__: boolean;
126
126
  __ROOT_URL__: string;
@@ -225,7 +225,7 @@ declare function textToImage(input: {
225
225
  }): Promise<string | null>;
226
226
  declare function textToSpeech(input: {
227
227
  text: string;
228
- voice?: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
228
+ voice?: 'Will' | 'Brian' | 'George' | 'Jessica' | 'Liam' | 'Alice' | 'Sarah' | 'Charlotte' | 'Matilda' | 'Eric' | 'Alloy' | 'Ash' | 'Ballad' | 'Coral' | 'Echo' | 'Fable' | 'Nova' | 'Onyx' | 'Sage' | 'Shimmer';
229
229
  }): Promise<{
230
230
  url: string;
231
231
  duration: number | undefined;
@@ -1,2 +1,2 @@
1
- import {createTRPCProxyClient,httpLink}from'@trpc/client';import {AsyncLocalStorage}from'async_hooks';import {nanoid}from'nanoid';import S from'superjson';import*as v from'zod';import {z}from'zod';function C(e){let t=Object.create(null);for(let r in e){let n=e[r];t[n]=r;}return t}var E={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,UNAUTHORIZED:-32001,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNPROCESSABLE_CONTENT:-32022,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099};C(E);C(E);typeof window>"u"||"Deno"in window||globalThis.process?.env?.NODE_ENV==="test"||!!globalThis.process?.env?.JEST_WORKER_ID||!!globalThis.process?.env?.VITEST_WORKER_ID;var h=class e extends Error{static prefix="__MISSING AUTH FOR SCOPE";static jsonRpcCode=-32001;constructor({provider:t,scope:r,accountId:n,popup:o=false}){let s=btoa(JSON.stringify({provider:t,scope:r,accountId:n}));super(`${e.prefix}: ${s}${o?" --popup":" end"}`);}jsonRpcError(){return {code:e.jsonRpcCode,message:this.message}}static check(t){return t?.message?.startsWith(e.prefix)}};var we=z.object({GUEST_SERVICES_URL:z.string().url().default("http://localhost:3000/trpc"),REALTIME_DOMAIN:z.string().default("localhost:3002"),BASE_URL:z.string().url().default("http://localhost:3001"),NODE_ENV:z.enum(["development","production","test"]).default("development")}),F=we.safeParse({GUEST_SERVICES_URL:process.env.GUEST_SERVICES_URL,REALTIME_DOMAIN:process.env.REALTIME_DOMAIN,BASE_URL:process.env.BASE_URL,NODE_ENV:process.env.NODE_ENV});if(!F.success)throw console.error("Invalid environment variables:",F.error.format()),new Error("Invalid environment variables");var _=F.data;var ee=new AsyncLocalStorage,U=null,Q=new Set,x=null;function u(){return U||(U=createTRPCProxyClient({transformer:S,links:[httpLink({url:_.GUEST_SERVICES_URL,transformer:S,headers:()=>{let e=q();if(!e)throw new Error("Missing request context");return {"x-request-id":e.requestId}}})]})),U}function q(){return ee.getStore()}function _e(e){let t=q();t&&Object.assign(t,e);}async function Xe(e,t){return ee.run(e,t)}function Z(e){throw new h({provider:e?.provider??"AC1",popup:true})}async function et(e){let r=await u().getCurrentUser.mutate(e);if(r?.error==="SEED")throw new Error('Call to "getUserId" in seed function is not allowed. Seed functions should not depend on user data.');if(!r?.userId){if(e?.throwIfNotLoggedIn??true)throw new h({provider:"AC1"});return null}return r.userId}async function tt(e){let r=await u().getCurrentUser.mutate({throwIfNotLoggedIn:e?.required});if(r?.error==="SEED")throw new Error('Call to "getAuth" in seed function is not allowed. Seed functions should not depend on user data.');if(r.userId)return {userId:r.userId,status:"authenticated",signIn:Z,providers:r.providers};if(e?.required)throw new h({provider:"AC1"});return {userId:null,status:"unauthenticated",signIn:Z,providers:[]}}async function rt(e){let t=u(),r=await t.upsertTaskStatus.mutate({status:"RUNNING"});return Q.add(r.id),_e({hasTasks:true}),(async()=>{let n=r.id;try{await e(),await t.upsertTaskStatus.mutate({id:n,status:"COMPLETED"});}catch(o){console.error(`Task ${n} failed:`,o.message),await t.upsertTaskStatus.mutate({id:n,status:"FAILED",error:o});}finally{Q.delete(r.id);}})(),r}async function nt(e){return await u().getTaskStatus.mutate({id:e})}async function ot(e){let t=u(),r={...e,schema:v.toJSONSchema(e.schema)};return await t.extractStructuredDataFromContent.mutate(r)}async function st(e){return await u().extractTextFromContent.mutate(e)}async function it(e){let t=u(),{stream:r,onProgress:n,...o}=e,s={...o,returnType:v.toJSONSchema(e.returnType),customTools:e.customTools?.map(d=>({...d,inputSchema:v.toJSONSchema(d.inputSchema)}))};if(r??n){let d=nanoid(32),a=new WebSocket(`wss://${_.REALTIME_DOMAIN}/${d}`),l=-1,c=p=>{x=Date.now();try{let g=JSON.parse(p.data.toString());if(g?.id&&g.id>l){let te=S.parse(g.payload);g.requestAgentToolCalls instanceof Array?n?.(g.requestAgentToolCalls):r?.(te),l=g.id;}}catch{}};a.addEventListener("message",c);let m=await t.requestMultimodalModel.mutate({...s,realtimeChannelId:d});return r&&r(m),a.close(),a.removeEventListener("message",c),m}return await t.requestMultimodalModel.mutate(s)}async function at(e){return await u().textToImage.mutate(e)}async function ut(e){return await u().textToSpeech.mutate(e)}async function ct(e){return await u().generateSoundEffect.mutate(e)}async function dt(e){return await u().generateDialogue.mutate(e)}async function lt(e){return await u().generateMusic.mutate(e)}async function ft(e){let t=u(),r;return typeof e.bufferOrBase64=="string"?r=e.bufferOrBase64:r=e.bufferOrBase64.toString("base64"),await t.uploadToBucket.mutate({base64:r,fileName:e.fileName})}async function pt(e){return await u().getOAuthToken.mutate({connectionId:e.connectionId})}async function mt(e){let r=await u().getOAuthConnectionForCurrentUser.mutate({...e,scope:e.scope??[]});if(!r&&e.required)throw new h({provider:e.provider,scope:e.scope,popup:true});return r}async function gt(e){return await u().getOAuthConnection.mutate(e)}async function wt(e){return await u().queryOAuthConnections.mutate(e)}async function ht(e){return await u().deleteOAuthConnection.mutate(e)}async function Et(e){await u().sendEmail.mutate(e);}async function yt(e){let t=u();if(!e.email)throw new Error("Email is required");if(!e.markdown)throw new Error("`markdown` content is required when inviting by email");return await t.inviteUser.mutate(e)}async function Tt(e){return await u().searchWithGoogle.mutate(e)}async function _t(){return await u().isAppOwner.mutate()}async function Rt(e){return await u().generateCrossAppToken.mutate(e)}async function St(e){return await u().createProduct.mutate(e)}async function Pt(){return await u().listProducts.mutate()}async function vt(e){return await u().listUserPurchases.mutate(e)}async function xt(e){await u().discontinueProduct.mutate(e);}function Ot({channelId:e,onUpdate:t}){let r=new WebSocket(`wss://${_.REALTIME_DOMAIN}/${e}`),n=-1;function o(s){t&&(x=Date.now());try{let i=JSON.parse(s.data.toString());if(i?.id&&i.id>n){let d=S.parse(i.payload);t?.(d),n=i.id;}}catch{}}return r.addEventListener("message",o),{destroy(){r.close(),r.removeEventListener("message",o);}}}async function X({channelId:e,data:t}){x=Date.now(),await fetch(`https://${_.REALTIME_DOMAIN}/${e}`,{method:"POST",body:S.stringify(t)}).catch(console.error);}async function It(){let e,t=q()?.channelId;if(!t)throw new Error("API's using `startRealtimeResponse` must be called via `useRealtimeMutation`.");return {next(r){e=r,X({channelId:t,data:r});},end(){return X({channelId:t,data:e}),e}}}async function Ct(e){return await u().getTTSVoicesCatalog.mutate(e)}async function bt(e){return await u().getDialogueVoicesCatalog.mutate(e)}async function At(e){return await u().getImageModelsCatalog.mutate(e)}function Nt(){return _.BASE_URL}function Dt(){return x}
2
- export{St as createProduct,ht as deleteOAuthConnection,xt as discontinueProduct,st as extractTextFromContent,Rt as generateCrossAppToken,dt as generateDialogue,lt as generateMusic,ct as generateSoundEffect,tt as getAuth,Nt as getBaseUrl,bt as getDialogueVoicesCatalog,At as getImageModelsCatalog,Dt as getLastStreamTime,gt as getOAuthConnection,mt as getOAuthConnectionForCurrentUser,pt as getOAuthToken,Ot as getRealtimeStore,q as getRequestContext,ot as getStructuredDataFromContent,Ct as getTTSVoicesCatalog,nt as getTaskStatus,et as getUserId,yt as inviteUser,_t as isAppOwner,Pt as listProducts,vt as listUserPurchases,wt as queryOAuthConnections,rt as queueTask,it as requestMultimodalModel,Xe as runWithContext,Tt as searchWithGoogle,Et as sendEmail,X as setRealtimeStore,_e as setRequestContext,It as startRealtimeResponse,at as textToImage,ut as textToSpeech,ft as upload};
1
+ import {createTRPCProxyClient,httpLink}from'@trpc/client';import {AsyncLocalStorage}from'async_hooks';import {nanoid}from'nanoid';import S from'superjson';import*as I from'zod';import {z}from'zod';function C(e){let t=Object.create(null);for(let r in e){let n=e[r];t[n]=r;}return t}var E={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,UNAUTHORIZED:-32001,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNPROCESSABLE_CONTENT:-32022,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099};C(E);C(E);typeof window>"u"||"Deno"in window||globalThis.process?.env?.NODE_ENV==="test"||!!globalThis.process?.env?.JEST_WORKER_ID||!!globalThis.process?.env?.VITEST_WORKER_ID;var h=class e extends Error{static prefix="__MISSING AUTH FOR SCOPE";static jsonRpcCode=-32001;constructor({provider:t,scope:r,accountId:n,popup:o=false}){let s=btoa(JSON.stringify({provider:t,scope:r,accountId:n}));super(`${e.prefix}: ${s}${o?" --popup":" end"}`);}jsonRpcError(){return {code:e.jsonRpcCode,message:this.message}}static check(t){return t?.message?.startsWith(e.prefix)}};var we=z.object({GUEST_SERVICES_URL:z.string().url().default("http://localhost:3000/trpc"),VITE_REALTIME_DOMAIN:z.string().default("localhost:3002"),VITE_BASE_URL:z.string().url().default("http://localhost:3001"),NODE_ENV:z.enum(["development","production","test"]).default("development")}),F=we.safeParse({GUEST_SERVICES_URL:process.env.GUEST_SERVICES_URL,VITE_REALTIME_DOMAIN:process.env.VITE_REALTIME_DOMAIN,VITE_BASE_URL:process.env.VITE_BASE_URL,NODE_ENV:process.env.NODE_ENV});if(!F.success)throw console.error("Invalid environment variables:",F.error.format()),new Error("Invalid environment variables");var _=F.data;var ee=new AsyncLocalStorage,U=null,Q=new Set,v=null;function u(){return U||(U=createTRPCProxyClient({transformer:S,links:[httpLink({url:_.GUEST_SERVICES_URL,transformer:S,headers:()=>{let e=q();if(!e)throw new Error("Missing request context");return {"x-request-id":e.requestId}}})]})),U}function q(){return ee.getStore()}function _e(e){let t=q();t&&Object.assign(t,e);}async function Xe(e,t){return ee.run(e,t)}function Z(e){throw new h({provider:e?.provider??"AC1",popup:true})}async function et(e){let r=await u().getCurrentUser.mutate(e);if(r?.error==="SEED")throw new Error('Call to "getUserId" in seed function is not allowed. Seed functions should not depend on user data.');if(!r?.userId){if(e?.throwIfNotLoggedIn??true)throw new h({provider:"AC1"});return null}return r.userId}async function tt(e){let r=await u().getCurrentUser.mutate({throwIfNotLoggedIn:e?.required});if(r?.error==="SEED")throw new Error('Call to "getAuth" in seed function is not allowed. Seed functions should not depend on user data.');if(r.userId)return {userId:r.userId,status:"authenticated",signIn:Z,providers:r.providers};if(e?.required)throw new h({provider:"AC1"});return {userId:null,status:"unauthenticated",signIn:Z,providers:[]}}async function rt(e){let t=u(),r=await t.upsertTaskStatus.mutate({status:"RUNNING"});return Q.add(r.id),_e({hasTasks:true}),(async()=>{let n=r.id;try{await e(),await t.upsertTaskStatus.mutate({id:n,status:"COMPLETED"});}catch(o){console.error(`Task ${n} failed:`,o.message),await t.upsertTaskStatus.mutate({id:n,status:"FAILED",error:o});}finally{Q.delete(r.id);}})(),r}async function nt(e){return await u().getTaskStatus.mutate({id:e})}async function ot(e){let t=u(),r={...e,schema:I.toJSONSchema(e.schema)};return await t.extractStructuredDataFromContent.mutate(r)}async function st(e){return await u().extractTextFromContent.mutate(e)}async function it(e){let t=u(),{stream:r,onProgress:n,...o}=e,s={...o,returnType:I.toJSONSchema(e.returnType),customTools:e.customTools?.map(d=>({...d,inputSchema:I.toJSONSchema(d.inputSchema)}))};if(r??n){let d=nanoid(32),a=new WebSocket(`wss://${_.VITE_REALTIME_DOMAIN}/${d}`),l=-1,c=p=>{v=Date.now();try{let g=JSON.parse(p.data.toString());if(g?.id&&g.id>l){let te=S.parse(g.payload);g.requestAgentToolCalls instanceof Array?n?.(g.requestAgentToolCalls):r?.(te),l=g.id;}}catch{}};a.addEventListener("message",c);let m=await t.requestMultimodalModel.mutate({...s,realtimeChannelId:d});return r&&r(m),a.close(),a.removeEventListener("message",c),m}return await t.requestMultimodalModel.mutate(s)}async function at(e){return await u().textToImage.mutate(e)}async function ut(e){return await u().textToSpeech.mutate(e)}async function ct(e){return await u().generateSoundEffect.mutate(e)}async function dt(e){return await u().generateDialogue.mutate(e)}async function lt(e){return await u().generateMusic.mutate(e)}async function ft(e){let t=u(),r;return typeof e.bufferOrBase64=="string"?r=e.bufferOrBase64:r=e.bufferOrBase64.toString("base64"),await t.uploadToBucket.mutate({base64:r,fileName:e.fileName})}async function pt(e){return await u().getOAuthToken.mutate({connectionId:e.connectionId})}async function mt(e){let r=await u().getOAuthConnectionForCurrentUser.mutate({...e,scope:e.scope??[]});if(!r&&e.required)throw new h({provider:e.provider,scope:e.scope,popup:true});return r}async function gt(e){return await u().getOAuthConnection.mutate(e)}async function wt(e){return await u().queryOAuthConnections.mutate(e)}async function ht(e){return await u().deleteOAuthConnection.mutate(e)}async function Et(e){await u().sendEmail.mutate(e);}async function yt(e){let t=u();if(!e.email)throw new Error("Email is required");if(!e.markdown)throw new Error("`markdown` content is required when inviting by email");return await t.inviteUser.mutate(e)}async function Tt(e){return await u().searchWithGoogle.mutate(e)}async function _t(){return await u().isAppOwner.mutate()}async function Rt(e){return await u().generateCrossAppToken.mutate(e)}async function St(e){return await u().createProduct.mutate(e)}async function Pt(){return await u().listProducts.mutate()}async function It(e){return await u().listUserPurchases.mutate(e)}async function vt(e){await u().discontinueProduct.mutate(e);}function xt({channelId:e,onUpdate:t}){let r=new WebSocket(`wss://${_.VITE_REALTIME_DOMAIN}/${e}`),n=-1;function o(s){t&&(v=Date.now());try{let i=JSON.parse(s.data.toString());if(i?.id&&i.id>n){let d=S.parse(i.payload);t?.(d),n=i.id;}}catch{}}return r.addEventListener("message",o),{destroy(){r.close(),r.removeEventListener("message",o);}}}async function X({channelId:e,data:t}){v=Date.now(),await fetch(`https://${_.VITE_REALTIME_DOMAIN}/${e}`,{method:"POST",body:S.stringify(t)}).catch(console.error);}async function Ot(){let e,t=q()?.channelId;if(!t)throw new Error("API's using `startRealtimeResponse` must be called via `useRealtimeMutation`.");return {next(r){e=r,X({channelId:t,data:r});},end(){return X({channelId:t,data:e}),e}}}async function Ct(e){return await u().getTTSVoicesCatalog.mutate(e)}async function bt(e){return await u().getDialogueVoicesCatalog.mutate(e)}async function At(e){return await u().getImageModelsCatalog.mutate(e)}function Nt(){return _.VITE_BASE_URL}function Dt(){return v}
2
+ export{St as createProduct,ht as deleteOAuthConnection,vt as discontinueProduct,st as extractTextFromContent,Rt as generateCrossAppToken,dt as generateDialogue,lt as generateMusic,ct as generateSoundEffect,tt as getAuth,Nt as getBaseUrl,bt as getDialogueVoicesCatalog,At as getImageModelsCatalog,Dt as getLastStreamTime,gt as getOAuthConnection,mt as getOAuthConnectionForCurrentUser,pt as getOAuthToken,xt as getRealtimeStore,q as getRequestContext,ot as getStructuredDataFromContent,Ct as getTTSVoicesCatalog,nt as getTaskStatus,et as getUserId,yt as inviteUser,_t as isAppOwner,Pt as listProducts,It as listUserPurchases,wt as queryOAuthConnections,rt as queueTask,it as requestMultimodalModel,Xe as runWithContext,Tt as searchWithGoogle,Et as sendEmail,X as setRealtimeStore,_e as setRequestContext,Ot as startRealtimeResponse,at as textToImage,ut as textToSpeech,ft as upload};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptive-ai/sdk",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {