@supyagent/sdk 0.1.38 → 0.2.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/dist/react.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { UIMessage } from 'ai';
3
- import React from 'react';
3
+ import React, { ReactNode } from 'react';
4
4
 
5
5
  /**
6
6
  * Extract provider/service prefix from a tool name.
@@ -317,4 +317,38 @@ interface ViewImageFormatterProps {
317
317
  }
318
318
  declare function ViewImageFormatter({ data }: ViewImageFormatterProps): react_jsx_runtime.JSX.Element;
319
319
 
320
- export { BrevoFormatter, BrowserFormatter, CalendarEventFormatter, CalendlyFormatter, CollapsibleResult, type CollapsibleResultProps, ComputeFormatter, ContextIndicator, type ContextIndicatorProps, DiscordFormatter, DocsFormatter, DriveFileFormatter, EmailFormatter, type FormatterType, GenericFormatter, GithubFormatter, HubspotFormatter, InboxFormatter, JiraFormatter, LinearFormatter, LinkedInFormatter, NotionFormatter, PROVIDER_LABELS, PipedriveFormatter, ProviderIcon, ResendFormatter, SalesforceFormatter, SearchFormatter, SheetsFormatter, SlackMessageFormatter, SlidesFormatter, StripeFormatter, SummaryMessage, type SummaryMessageProps, type SummaryResult, SupyagentToolAction, SupyagentToolCall, SupyagentToolResult, TelegramFormatter, ToolInput, type ToolResultPart, TwilioFormatter, TwitterFormatter, ViewImageFormatter, WhatsAppFormatter, extractArgs, extractResult, extractState, extractToolName, getFormatterType, getProviderFromToolName, getProviderLabel, getSummary, humanizeToolName, isContextSummary, maybeNormalize, normalizeMicrosoftCalendar, normalizeMicrosoftDrive, normalizeMicrosoftMail, resolveToolName, unwrapSupyagentResult };
320
+ /** Options for openConnectPopup() */
321
+ interface ConnectPopupOptions {
322
+ /** The connect URL returned by client.accounts.connect() */
323
+ connectUrl: string;
324
+ /** Popup width in pixels (default: 500) */
325
+ width?: number;
326
+ /** Popup height in pixels (default: 700) */
327
+ height?: number;
328
+ /** Called when the OAuth flow succeeds */
329
+ onSuccess?: (result: ConnectPopupResult) => void;
330
+ /** Called when the OAuth flow fails */
331
+ onError?: (error: Error) => void;
332
+ }
333
+ /** Resolved value of the openConnectPopup() promise */
334
+ interface ConnectPopupResult {
335
+ status: "success";
336
+ provider: string;
337
+ accountId: string;
338
+ }
339
+
340
+ /** React hook wrapping openConnectPopup with loading/error state. */
341
+ declare function useSupyagentConnect(): {
342
+ connect: (options: ConnectPopupOptions) => Promise<ConnectPopupResult>;
343
+ isConnecting: boolean;
344
+ error: Error | null;
345
+ result: ConnectPopupResult | null;
346
+ };
347
+ /** Drop-in component for the partner's redirect page. */
348
+ declare function ConnectCallback({ children, targetOrigin, autoClose, }: {
349
+ children?: ReactNode;
350
+ targetOrigin?: string;
351
+ autoClose?: boolean;
352
+ }): react_jsx_runtime.JSX.Element;
353
+
354
+ export { BrevoFormatter, BrowserFormatter, CalendarEventFormatter, CalendlyFormatter, CollapsibleResult, type CollapsibleResultProps, ComputeFormatter, ConnectCallback, type ConnectPopupOptions, type ConnectPopupResult, ContextIndicator, type ContextIndicatorProps, DiscordFormatter, DocsFormatter, DriveFileFormatter, EmailFormatter, type FormatterType, GenericFormatter, GithubFormatter, HubspotFormatter, InboxFormatter, JiraFormatter, LinearFormatter, LinkedInFormatter, NotionFormatter, PROVIDER_LABELS, PipedriveFormatter, ProviderIcon, ResendFormatter, SalesforceFormatter, SearchFormatter, SheetsFormatter, SlackMessageFormatter, SlidesFormatter, StripeFormatter, SummaryMessage, type SummaryMessageProps, type SummaryResult, SupyagentToolAction, SupyagentToolCall, SupyagentToolResult, TelegramFormatter, ToolInput, type ToolResultPart, TwilioFormatter, TwitterFormatter, ViewImageFormatter, WhatsAppFormatter, extractArgs, extractResult, extractState, extractToolName, getFormatterType, getProviderFromToolName, getProviderLabel, getSummary, humanizeToolName, isContextSummary, maybeNormalize, normalizeMicrosoftCalendar, normalizeMicrosoftDrive, normalizeMicrosoftMail, resolveToolName, unwrapSupyagentResult, useSupyagentConnect };
package/dist/react.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { UIMessage } from 'ai';
3
- import React from 'react';
3
+ import React, { ReactNode } from 'react';
4
4
 
5
5
  /**
6
6
  * Extract provider/service prefix from a tool name.
@@ -317,4 +317,38 @@ interface ViewImageFormatterProps {
317
317
  }
318
318
  declare function ViewImageFormatter({ data }: ViewImageFormatterProps): react_jsx_runtime.JSX.Element;
319
319
 
320
- export { BrevoFormatter, BrowserFormatter, CalendarEventFormatter, CalendlyFormatter, CollapsibleResult, type CollapsibleResultProps, ComputeFormatter, ContextIndicator, type ContextIndicatorProps, DiscordFormatter, DocsFormatter, DriveFileFormatter, EmailFormatter, type FormatterType, GenericFormatter, GithubFormatter, HubspotFormatter, InboxFormatter, JiraFormatter, LinearFormatter, LinkedInFormatter, NotionFormatter, PROVIDER_LABELS, PipedriveFormatter, ProviderIcon, ResendFormatter, SalesforceFormatter, SearchFormatter, SheetsFormatter, SlackMessageFormatter, SlidesFormatter, StripeFormatter, SummaryMessage, type SummaryMessageProps, type SummaryResult, SupyagentToolAction, SupyagentToolCall, SupyagentToolResult, TelegramFormatter, ToolInput, type ToolResultPart, TwilioFormatter, TwitterFormatter, ViewImageFormatter, WhatsAppFormatter, extractArgs, extractResult, extractState, extractToolName, getFormatterType, getProviderFromToolName, getProviderLabel, getSummary, humanizeToolName, isContextSummary, maybeNormalize, normalizeMicrosoftCalendar, normalizeMicrosoftDrive, normalizeMicrosoftMail, resolveToolName, unwrapSupyagentResult };
320
+ /** Options for openConnectPopup() */
321
+ interface ConnectPopupOptions {
322
+ /** The connect URL returned by client.accounts.connect() */
323
+ connectUrl: string;
324
+ /** Popup width in pixels (default: 500) */
325
+ width?: number;
326
+ /** Popup height in pixels (default: 700) */
327
+ height?: number;
328
+ /** Called when the OAuth flow succeeds */
329
+ onSuccess?: (result: ConnectPopupResult) => void;
330
+ /** Called when the OAuth flow fails */
331
+ onError?: (error: Error) => void;
332
+ }
333
+ /** Resolved value of the openConnectPopup() promise */
334
+ interface ConnectPopupResult {
335
+ status: "success";
336
+ provider: string;
337
+ accountId: string;
338
+ }
339
+
340
+ /** React hook wrapping openConnectPopup with loading/error state. */
341
+ declare function useSupyagentConnect(): {
342
+ connect: (options: ConnectPopupOptions) => Promise<ConnectPopupResult>;
343
+ isConnecting: boolean;
344
+ error: Error | null;
345
+ result: ConnectPopupResult | null;
346
+ };
347
+ /** Drop-in component for the partner's redirect page. */
348
+ declare function ConnectCallback({ children, targetOrigin, autoClose, }: {
349
+ children?: ReactNode;
350
+ targetOrigin?: string;
351
+ autoClose?: boolean;
352
+ }): react_jsx_runtime.JSX.Element;
353
+
354
+ export { BrevoFormatter, BrowserFormatter, CalendarEventFormatter, CalendlyFormatter, CollapsibleResult, type CollapsibleResultProps, ComputeFormatter, ConnectCallback, type ConnectPopupOptions, type ConnectPopupResult, ContextIndicator, type ContextIndicatorProps, DiscordFormatter, DocsFormatter, DriveFileFormatter, EmailFormatter, type FormatterType, GenericFormatter, GithubFormatter, HubspotFormatter, InboxFormatter, JiraFormatter, LinearFormatter, LinkedInFormatter, NotionFormatter, PROVIDER_LABELS, PipedriveFormatter, ProviderIcon, ResendFormatter, SalesforceFormatter, SearchFormatter, SheetsFormatter, SlackMessageFormatter, SlidesFormatter, StripeFormatter, SummaryMessage, type SummaryMessageProps, type SummaryResult, SupyagentToolAction, SupyagentToolCall, SupyagentToolResult, TelegramFormatter, ToolInput, type ToolResultPart, TwilioFormatter, TwitterFormatter, ViewImageFormatter, WhatsAppFormatter, extractArgs, extractResult, extractState, extractToolName, getFormatterType, getProviderFromToolName, getProviderLabel, getSummary, humanizeToolName, isContextSummary, maybeNormalize, normalizeMicrosoftCalendar, normalizeMicrosoftDrive, normalizeMicrosoftMail, resolveToolName, unwrapSupyagentResult, useSupyagentConnect };
package/dist/react.js CHANGED
@@ -3745,6 +3745,125 @@ function SupyagentToolCall({ part }) {
3745
3745
  }
3746
3746
  );
3747
3747
  }
3748
+
3749
+ // src/react.tsx
3750
+ import { useState as useState5, useEffect, useCallback } from "react";
3751
+
3752
+ // src/connect/popup.ts
3753
+ function openConnectPopup(options) {
3754
+ const { connectUrl, width = 500, height = 700, onSuccess, onError } = options;
3755
+ return new Promise((resolve, reject) => {
3756
+ const left = Math.round(window.screenX + (window.outerWidth - width) / 2);
3757
+ const top = Math.round(window.screenY + (window.outerHeight - height) / 2);
3758
+ const features = `width=${width},height=${height},left=${left},top=${top},popup=1`;
3759
+ const popup = window.open(connectUrl, "supyagent_connect", features);
3760
+ if (!popup) {
3761
+ const err = new Error(
3762
+ "Popup was blocked by the browser. Please allow popups for this site."
3763
+ );
3764
+ onError?.(err);
3765
+ reject(err);
3766
+ return;
3767
+ }
3768
+ const popupRef = popup;
3769
+ let settled = false;
3770
+ function cleanup() {
3771
+ window.removeEventListener("message", onMessage);
3772
+ clearInterval(pollTimer);
3773
+ }
3774
+ function onMessage(event) {
3775
+ const data = event.data;
3776
+ if (!data || data.type !== "supyagent:connect") return;
3777
+ settled = true;
3778
+ cleanup();
3779
+ try {
3780
+ popupRef.close();
3781
+ } catch {
3782
+ }
3783
+ if (data.status === "success" && data.provider && data.accountId) {
3784
+ const result = {
3785
+ status: "success",
3786
+ provider: data.provider,
3787
+ accountId: data.accountId
3788
+ };
3789
+ onSuccess?.(result);
3790
+ resolve(result);
3791
+ } else {
3792
+ const err = new Error(data.error || "OAuth connect failed");
3793
+ onError?.(err);
3794
+ reject(err);
3795
+ }
3796
+ }
3797
+ window.addEventListener("message", onMessage);
3798
+ const pollTimer = setInterval(() => {
3799
+ if (!settled && popupRef.closed) {
3800
+ settled = true;
3801
+ cleanup();
3802
+ const err = new Error("Popup was closed before completing the OAuth flow");
3803
+ onError?.(err);
3804
+ reject(err);
3805
+ }
3806
+ }, 500);
3807
+ });
3808
+ }
3809
+
3810
+ // src/connect/callback.ts
3811
+ function handleConnectCallback(options) {
3812
+ const { targetOrigin = "*", autoClose = true } = options ?? {};
3813
+ const params = new URLSearchParams(window.location.search);
3814
+ const status = params.get("status");
3815
+ const provider = params.get("provider");
3816
+ const accountId = params.get("account_id");
3817
+ const error = params.get("error");
3818
+ const message = {
3819
+ type: "supyagent:connect",
3820
+ status: status === "success" ? "success" : "error",
3821
+ ...provider ? { provider } : {},
3822
+ ...accountId ? { accountId } : {},
3823
+ ...error ? { error } : {}
3824
+ };
3825
+ if (window.opener) {
3826
+ window.opener.postMessage(message, targetOrigin);
3827
+ }
3828
+ if (autoClose) {
3829
+ window.close();
3830
+ }
3831
+ }
3832
+
3833
+ // src/react.tsx
3834
+ import { Fragment as Fragment2, jsx as jsx39 } from "react/jsx-runtime";
3835
+ function useSupyagentConnect() {
3836
+ const [isConnecting, setIsConnecting] = useState5(false);
3837
+ const [error, setError] = useState5(null);
3838
+ const [result, setResult] = useState5(null);
3839
+ const connect = useCallback(async (options) => {
3840
+ setIsConnecting(true);
3841
+ setError(null);
3842
+ setResult(null);
3843
+ try {
3844
+ const res = await openConnectPopup(options);
3845
+ setResult(res);
3846
+ return res;
3847
+ } catch (err) {
3848
+ const e = err instanceof Error ? err : new Error(String(err));
3849
+ setError(e);
3850
+ throw e;
3851
+ } finally {
3852
+ setIsConnecting(false);
3853
+ }
3854
+ }, []);
3855
+ return { connect, isConnecting, error, result };
3856
+ }
3857
+ function ConnectCallback({
3858
+ children,
3859
+ targetOrigin,
3860
+ autoClose = true
3861
+ }) {
3862
+ useEffect(() => {
3863
+ handleConnectCallback({ targetOrigin, autoClose });
3864
+ }, [targetOrigin, autoClose]);
3865
+ return /* @__PURE__ */ jsx39(Fragment2, { children: children ?? null });
3866
+ }
3748
3867
  export {
3749
3868
  BrevoFormatter,
3750
3869
  BrowserFormatter,
@@ -3752,6 +3871,7 @@ export {
3752
3871
  CalendlyFormatter,
3753
3872
  CollapsibleResult,
3754
3873
  ComputeFormatter,
3874
+ ConnectCallback,
3755
3875
  ContextIndicator,
3756
3876
  DiscordFormatter,
3757
3877
  DocsFormatter,
@@ -3800,6 +3920,7 @@ export {
3800
3920
  normalizeMicrosoftDrive,
3801
3921
  normalizeMicrosoftMail,
3802
3922
  resolveToolName,
3803
- unwrapSupyagentResult
3923
+ unwrapSupyagentResult,
3924
+ useSupyagentConnect
3804
3925
  };
3805
3926
  //# sourceMappingURL=react.js.map