@salesforce/platform-sdk 3.0.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.
Files changed (122) hide show
  1. package/LICENSE.txt +82 -0
  2. package/README.md +62 -0
  3. package/dist/analytics/analytics.d.ts +21 -0
  4. package/dist/analytics/analytics.d.ts.map +1 -0
  5. package/dist/analytics/error-listener.d.ts +9 -0
  6. package/dist/analytics/error-listener.d.ts.map +1 -0
  7. package/dist/analytics/index.d.ts +8 -0
  8. package/dist/analytics/index.d.ts.map +1 -0
  9. package/dist/analytics/method-configs.d.ts +11 -0
  10. package/dist/analytics/method-configs.d.ts.map +1 -0
  11. package/dist/analytics/proxy.d.ts +14 -0
  12. package/dist/analytics/proxy.d.ts.map +1 -0
  13. package/dist/analytics/schemas.d.ts +7 -0
  14. package/dist/analytics/schemas.d.ts.map +1 -0
  15. package/dist/analytics/subscribe-wrapper.d.ts +7 -0
  16. package/dist/analytics/subscribe-wrapper.d.ts.map +1 -0
  17. package/dist/analytics/types.d.ts +90 -0
  18. package/dist/analytics/types.d.ts.map +1 -0
  19. package/dist/chat/index.d.ts +22 -0
  20. package/dist/chat/index.d.ts.map +1 -0
  21. package/dist/chat/mcpapps.d.ts +61 -0
  22. package/dist/chat/mcpapps.d.ts.map +1 -0
  23. package/dist/chat/openai.d.ts +25 -0
  24. package/dist/chat/openai.d.ts.map +1 -0
  25. package/dist/chat/salesforce-acc.d.ts +13 -0
  26. package/dist/chat/salesforce-acc.d.ts.map +1 -0
  27. package/dist/chat/singleton.d.ts +32 -0
  28. package/dist/chat/singleton.d.ts.map +1 -0
  29. package/dist/core/acc-types.d.ts +49 -0
  30. package/dist/core/acc-types.d.ts.map +1 -0
  31. package/dist/core/capabilities.d.ts +40 -0
  32. package/dist/core/capabilities.d.ts.map +1 -0
  33. package/dist/core/chat.d.ts +203 -0
  34. package/dist/core/chat.d.ts.map +1 -0
  35. package/dist/core/data.d.ts +38 -0
  36. package/dist/core/data.d.ts.map +1 -0
  37. package/dist/core/index.d.ts +24 -0
  38. package/dist/core/index.d.ts.map +1 -0
  39. package/dist/core/jsonrpc-client.d.ts +167 -0
  40. package/dist/core/jsonrpc-client.d.ts.map +1 -0
  41. package/dist/core/jsonrpc.d.ts +123 -0
  42. package/dist/core/jsonrpc.d.ts.map +1 -0
  43. package/dist/core/lightning.d.ts +42 -0
  44. package/dist/core/lightning.d.ts.map +1 -0
  45. package/dist/core/mcpapps-session.d.ts +107 -0
  46. package/dist/core/mcpapps-session.d.ts.map +1 -0
  47. package/dist/core/mfe-protocol/message-channel-transport.d.ts +79 -0
  48. package/dist/core/mfe-protocol/message-channel-transport.d.ts.map +1 -0
  49. package/dist/core/options.d.ts +16 -0
  50. package/dist/core/options.d.ts.map +1 -0
  51. package/dist/core/platforms.d.ts +229 -0
  52. package/dist/core/platforms.d.ts.map +1 -0
  53. package/dist/core/sdk-promise.d.ts +14 -0
  54. package/dist/core/sdk-promise.d.ts.map +1 -0
  55. package/dist/core/surface.d.ts +24 -0
  56. package/dist/core/surface.d.ts.map +1 -0
  57. package/dist/core/view.d.ts +308 -0
  58. package/dist/core/view.d.ts.map +1 -0
  59. package/dist/data/gql.d.ts +7 -0
  60. package/dist/data/gql.d.ts.map +1 -0
  61. package/dist/data/index.d.ts +34 -0
  62. package/dist/data/index.d.ts.map +1 -0
  63. package/dist/data/mosaic/fetch.d.ts +21 -0
  64. package/dist/data/mosaic/fetch.d.ts.map +1 -0
  65. package/dist/data/mosaic/index.d.ts +22 -0
  66. package/dist/data/mosaic/index.d.ts.map +1 -0
  67. package/dist/data/openai/index.d.ts +9 -0
  68. package/dist/data/openai/index.d.ts.map +1 -0
  69. package/dist/data/shared/graphql/cache/command.d.ts +93 -0
  70. package/dist/data/shared/graphql/cache/command.d.ts.map +1 -0
  71. package/dist/data/shared/graphql/cache/index.d.ts +7 -0
  72. package/dist/data/shared/graphql/cache/index.d.ts.map +1 -0
  73. package/dist/data/shared/graphql/headers.d.ts +13 -0
  74. package/dist/data/shared/graphql/headers.d.ts.map +1 -0
  75. package/dist/data/shared/url-utils.d.ts +9 -0
  76. package/dist/data/shared/url-utils.d.ts.map +1 -0
  77. package/dist/data/webapp/client-headers.interceptor.d.ts +12 -0
  78. package/dist/data/webapp/client-headers.interceptor.d.ts.map +1 -0
  79. package/dist/data/webapp/csrf/header.interceptor.d.ts +19 -0
  80. package/dist/data/webapp/csrf/header.interceptor.d.ts.map +1 -0
  81. package/dist/data/webapp/csrf/retry.interceptor.d.ts +8 -0
  82. package/dist/data/webapp/csrf/retry.interceptor.d.ts.map +1 -0
  83. package/dist/data/webapp/csrf/retry.policy.d.ts +31 -0
  84. package/dist/data/webapp/csrf/retry.policy.d.ts.map +1 -0
  85. package/dist/data/webapp/csrf/token-manager.d.ts +42 -0
  86. package/dist/data/webapp/csrf/token-manager.d.ts.map +1 -0
  87. package/dist/data/webapp/fetch.d.ts +27 -0
  88. package/dist/data/webapp/fetch.d.ts.map +1 -0
  89. package/dist/data/webapp/index.d.ts +19 -0
  90. package/dist/data/webapp/index.d.ts.map +1 -0
  91. package/dist/index.d.ts +13 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +1506 -0
  94. package/dist/lightning/index.d.ts +15 -0
  95. package/dist/lightning/index.d.ts.map +1 -0
  96. package/dist/telemetry/action-piggyback.d.ts +7 -0
  97. package/dist/telemetry/action-piggyback.d.ts.map +1 -0
  98. package/dist/telemetry/buffer.d.ts +22 -0
  99. package/dist/telemetry/buffer.d.ts.map +1 -0
  100. package/dist/telemetry/index.d.ts +10 -0
  101. package/dist/telemetry/index.d.ts.map +1 -0
  102. package/dist/telemetry/transport.d.ts +3 -0
  103. package/dist/telemetry/transport.d.ts.map +1 -0
  104. package/dist/telemetry/types.d.ts +32 -0
  105. package/dist/telemetry/types.d.ts.map +1 -0
  106. package/dist/telemetry/uploader/TelemetryUploader.d.ts +43 -0
  107. package/dist/telemetry/uploader/TelemetryUploader.d.ts.map +1 -0
  108. package/dist/telemetry/uploader/interfaces.d.ts +61 -0
  109. package/dist/telemetry/uploader/interfaces.d.ts.map +1 -0
  110. package/dist/telemetry/widget-state-flush.d.ts +14 -0
  111. package/dist/telemetry/widget-state-flush.d.ts.map +1 -0
  112. package/dist/view/index.d.ts +22 -0
  113. package/dist/view/index.d.ts.map +1 -0
  114. package/dist/view/mcpapps.d.ts +24 -0
  115. package/dist/view/mcpapps.d.ts.map +1 -0
  116. package/dist/view/openai.d.ts +11 -0
  117. package/dist/view/openai.d.ts.map +1 -0
  118. package/dist/view/singleton.d.ts +32 -0
  119. package/dist/view/singleton.d.ts.map +1 -0
  120. package/dist/view/utils.d.ts +59 -0
  121. package/dist/view/utils.d.ts.map +1 -0
  122. package/package.json +51 -0
@@ -0,0 +1,107 @@
1
+ import { DisplayMode, HostStyles } from './chat';
2
+ import { JsonRpcClient } from './jsonrpc-client';
3
+ import { ThemeMode } from './view';
4
+ /**
5
+ * Host context returned by the ui/initialize handshake.
6
+ *
7
+ * Represents the raw MCP Apps wire-format fields. SDK classes map
8
+ * these to their own protocol-agnostic types.
9
+ */
10
+ export interface McpAppsHostContext {
11
+ /** Theme mode provided by the host */
12
+ theme?: ThemeMode;
13
+ /** Display mode of the widget */
14
+ displayMode?: DisplayMode;
15
+ /** Container dimensions */
16
+ containerDimensions?: {
17
+ height?: number;
18
+ maxHeight?: number;
19
+ width?: number;
20
+ maxWidth?: number;
21
+ };
22
+ /** Safe area insets in CSS pixels */
23
+ safeAreaInsets?: {
24
+ top: number;
25
+ right: number;
26
+ bottom: number;
27
+ left: number;
28
+ };
29
+ /** Host user agent string */
30
+ userAgent?: string;
31
+ /** BCP 47 locale */
32
+ locale?: string;
33
+ /** Device capabilities */
34
+ deviceCapabilities?: {
35
+ touch?: boolean;
36
+ hover?: boolean;
37
+ };
38
+ /** Tool info for the current tool invocation (name, schema, etc.) */
39
+ toolInfo?: {
40
+ /** JSON-RPC id of the tools/call request */
41
+ id?: string | number;
42
+ /** Full tool definition */
43
+ tool: Record<string, unknown>;
44
+ };
45
+ /** Initial tool output (structuredContent from CallToolResult), if available at init */
46
+ toolOutput?: Record<string, unknown> | null;
47
+ /** Initial tool output structured content, if available at init */
48
+ toolStructuredContent?: Record<string, unknown> | null;
49
+ /** Initial tool input arguments, if available at init */
50
+ toolInput?: Record<string, unknown>;
51
+ /** Initial tool response metadata (_meta from CallToolResult), if available at init */
52
+ toolResponseMetadata?: Record<string, unknown> | null;
53
+ /** Initial widget state, if available at init */
54
+ widgetState?: Record<string, unknown> | null;
55
+ /** Styles provided by the host for theming and font loading */
56
+ styles?: HostStyles;
57
+ }
58
+ /**
59
+ * Options for McpAppsSession initialization.
60
+ */
61
+ export interface McpAppsSessionOptions {
62
+ /** App identity sent during the ui/initialize handshake */
63
+ appInfo?: {
64
+ name: string;
65
+ version: string;
66
+ };
67
+ /** Handshake timeout in milliseconds (default 5000) */
68
+ handshakeTimeoutMs?: number;
69
+ }
70
+ /**
71
+ * Shared MCP Apps session singleton.
72
+ *
73
+ * Provides a single JSON-RPC transport (one postMessage listener, one ID counter)
74
+ * shared by both MCPAppsChatSDK and MCPAppsViewSDK. Performs the SEP-1865
75
+ * ui/initialize handshake once and exposes the resulting host context.
76
+ *
77
+ * Use {@link McpAppsSession.getInstance} to obtain the singleton. The first call
78
+ * triggers the handshake; subsequent calls return the same initialized instance.
79
+ */
80
+ export declare class McpAppsSession extends JsonRpcClient {
81
+ private static initPromise;
82
+ private hostCtx;
83
+ private _handshakeSucceeded;
84
+ /**
85
+ * Get or create the shared session singleton.
86
+ *
87
+ * The first call performs the SEP-1865 handshake. Concurrent and subsequent
88
+ * calls reuse the same session and handshake result.
89
+ */
90
+ static getInstance(options?: McpAppsSessionOptions): Promise<McpAppsSession>;
91
+ /**
92
+ * Perform the ui/initialize → hostContext → ui/notifications/initialized handshake.
93
+ *
94
+ * On success, stores the host context and sends the initialized notification.
95
+ * On timeout or error, falls back to an empty host context so the app can
96
+ * still render (graceful degradation for non-SEP-1865 hosts).
97
+ */
98
+ private handshake;
99
+ /** Returns the current host context (handshake + notification updates). */
100
+ getHostContext(): McpAppsHostContext;
101
+ /** Whether the ui/initialize handshake completed successfully (not timed out). */
102
+ get handshakeSucceeded(): boolean;
103
+ request<TParams = unknown, TResult = unknown>(method: string, params: TParams): Promise<TResult>;
104
+ sendNotification<TParams = unknown>(method: string, params?: TParams): void;
105
+ registerNotificationHandler(method: string, handler: (params: unknown) => void): void;
106
+ }
107
+ //# sourceMappingURL=mcpapps-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpapps-session.d.ts","sourceRoot":"","sources":["../../src/core/mcpapps-session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IAClC,sCAAsC;IACtC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,iCAAiC;IACjC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,2BAA2B;IAC3B,mBAAmB,CAAC,EAAE;QACrB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,qCAAqC;IACrC,cAAc,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9E,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0BAA0B;I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C,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;IAmBlF;;;;;;OAMG;YACW,SAAS;IAuCvB,2EAA2E;IAC3E,cAAc,IAAI,kBAAkB;IAIpC,kFAAkF;IAClF,IAAI,kBAAkB,IAAI,OAAO,CAEhC;IAMe,OAAO,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAC3D,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,GACb,OAAO,CAAC,OAAO,CAAC;IAIH,gBAAgB,CAAC,OAAO,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;IAI3E,2BAA2B,CAC1C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,GAChC,IAAI;CAGP"}
@@ -0,0 +1,79 @@
1
+ import { Transport } from '../jsonrpc-client';
2
+ /**
3
+ * Subscriber callback invoked for each unwrapped payload delivered on the
4
+ * port. Receivers get the `MessageEvent.data` directly — they do not need
5
+ * to reach into a `MessageEvent` wrapper.
6
+ */
7
+ export type MessageChannelTransportListener = (msg: unknown) => void;
8
+ /**
9
+ * MFE-side `Transport` backed by a `MessagePort`.
10
+ *
11
+ * During the MFE handshake, the iframe receives a transferred `MessagePort`
12
+ * (`event.ports[0]`) in the single bootstrap envelope posted by the host.
13
+ * That port is the `port1` half of the host's `MessageChannel`. Wrapping it
14
+ * in this class produces the same `Transport` shape that `JsonRpcClient`
15
+ * already consumes, so callers can swap in MessagePort-backed traffic
16
+ * without changing any of the JSON-RPC request/response/notification
17
+ * semantics.
18
+ *
19
+ * The implementation mirrors the host-side `MessageChannelTransport` that
20
+ * ships from `packages/core/src/MessageChannelTransport.ts` in the
21
+ * `ui-embedding` repo. Both sides MUST honour the same contract so one
22
+ * `JsonRpcClient` can drive either end.
23
+ *
24
+ * Contract (symmetric with the host-side transport, and with the
25
+ * `Transport` interface defined next to `WindowPostMessageTransport`):
26
+ *
27
+ * - `post(msg)` never throws on transient failure. A closed / neutered /
28
+ * disposed port silently drops the message. This matches the
29
+ * optional-chaining behaviour of `WindowPostMessageTransport.post`.
30
+ * - `onMessage(cb)` delivers the **unwrapped** payload (`MessageEvent.data`),
31
+ * not the raw `MessageEvent`. Returns an unsubscribe function.
32
+ * - The port is started (`port.start()`) lazily on the first `onMessage`
33
+ * subscription. Messages queued via `post` before that first subscribe
34
+ * are buffered in-process and flushed FIFO when the port starts.
35
+ * - `dispose()` removes listeners, closes the port, clears the outbound
36
+ * buffer, and puts the transport into a terminal state where further
37
+ * `post` calls silently no-op and further `onMessage` calls return a
38
+ * no-op unsubscribe.
39
+ *
40
+ * Usage from the container bootstrap:
41
+ * ```ts
42
+ * const transport = new MessageChannelTransport(event.ports[0]);
43
+ * // Hand the transport to the session layer; subscription drives start().
44
+ * ```
45
+ */
46
+ export declare class MessageChannelTransport implements Transport {
47
+ #private;
48
+ constructor(port: MessagePort);
49
+ /**
50
+ * Post a message to the peer.
51
+ *
52
+ * Never throws on transient failure — a closed / neutered / disposed
53
+ * port silently drops the message. If the transport has not yet
54
+ * started (no `onMessage` subscriber), the message is buffered and
55
+ * flushed on first subscription.
56
+ */
57
+ post(message: unknown): void;
58
+ /**
59
+ * Subscribe to inbound messages from the peer. The callback receives
60
+ * the **unwrapped** payload (`MessageEvent.data`) — callers never see
61
+ * the `MessageEvent` wrapper.
62
+ *
63
+ * Starts the underlying port on first subscription and flushes any
64
+ * messages queued via `post` before the port was started.
65
+ *
66
+ * Returns an unsubscribe function. Calling it is idempotent.
67
+ */
68
+ onMessage(callback: MessageChannelTransportListener): () => void;
69
+ /**
70
+ * Tear down the transport:
71
+ * - remove the internal `message` listener
72
+ * - call `port.close()`
73
+ * - clear subscriber set and outbound buffer
74
+ * - subsequent `post` calls silently no-op
75
+ * - subsequent `onMessage` calls return a no-op unsubscribe
76
+ */
77
+ dispose(): void;
78
+ }
79
+ //# sourceMappingURL=message-channel-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-channel-transport.d.ts","sourceRoot":"","sources":["../../../src/core/mfe-protocol/message-channel-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,+BAA+B,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;AAUrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,qBAAa,uBAAwB,YAAW,SAAS;;gBAQ5C,IAAI,EAAE,WAAW;IAI7B;;;;;;;OAOG;IACH,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAqB5B;;;;;;;;;OASG;IACH,SAAS,CAAC,QAAQ,EAAE,+BAA+B,GAAG,MAAM,IAAI;IAoBhE;;;;;;;OAOG;IACH,OAAO,IAAI,IAAI;CAyDf"}
@@ -0,0 +1,16 @@
1
+ import { Surface } from './surface';
2
+ /**
3
+ * Base options bag for all SDK factory functions.
4
+ *
5
+ * Individual SDKs extend this interface to add SDK-specific options.
6
+ */
7
+ export interface SDKOptions {
8
+ /**
9
+ * Override the auto-detected surface.
10
+ *
11
+ * When provided, the SDK will use this value instead of the
12
+ * result of the runtime surface detection.
13
+ */
14
+ surface?: Surface;
15
+ }
16
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/core/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB"}
@@ -0,0 +1,229 @@
1
+ import { DisplayMode } from './chat';
2
+ import { Theme, ThemeMode } from './view';
3
+ export interface OpenAISDK {
4
+ sendFollowUpMessage: (options: {
5
+ prompt: string;
6
+ }) => Promise<void>;
7
+ callTool: (toolName: string, args: Record<string, unknown>) => Promise<unknown>;
8
+ requestModal: (options: ModalOptions) => Promise<void>;
9
+ requestDisplayMode: (options: {
10
+ mode: DisplayMode;
11
+ }) => Promise<{
12
+ mode: DisplayMode;
13
+ }>;
14
+ toolInput: Record<string, unknown>;
15
+ toolOutput: Record<string, unknown> | null;
16
+ toolResponseMetadata: Record<string, unknown>;
17
+ widgetState: Record<string, unknown>;
18
+ setWidgetState: (state: Record<string, unknown>) => void;
19
+ theme: ThemeMode;
20
+ }
21
+ /**
22
+ * Salesforce ACC SDK interface exposed on window (stub)
23
+ * TODO: Define actual interface once specification is available
24
+ */
25
+ export type SalesforceACCSDK = Record<string, unknown>;
26
+ declare global {
27
+ interface Window {
28
+ openai?: OpenAISDK;
29
+ salesforceACC?: SalesforceACCSDK;
30
+ }
31
+ }
32
+ /**
33
+ * Message payload for chat stream
34
+ */
35
+ export interface ChatMessage {
36
+ content: string;
37
+ metadata?: Record<string, unknown>;
38
+ }
39
+ /**
40
+ * Tool execution payload
41
+ */
42
+ export interface ToolCall {
43
+ toolName: string;
44
+ params?: Record<string, unknown>;
45
+ }
46
+ /**
47
+ * Resource read request
48
+ */
49
+ export interface ResourceRequest {
50
+ uri: string;
51
+ }
52
+ /**
53
+ * Tool input/output state
54
+ */
55
+ export interface ToolState<T = unknown> {
56
+ data: T;
57
+ timestamp?: number;
58
+ }
59
+ /**
60
+ * Chat SDK API with optional methods based on surface capabilities
61
+ */
62
+ export interface ChatSDK {
63
+ /**
64
+ * Send a message to the host
65
+ *
66
+ * @param message - The message to send
67
+ */
68
+ sendMessageToHost?: (message: ChatMessage) => Promise<void>;
69
+ /**
70
+ * Execute a tool on the MCP Server
71
+ *
72
+ * @param toolCall - The tool to call with parameters
73
+ */
74
+ callTool?: <T>(toolCall: ToolCall) => Promise<T>;
75
+ /**
76
+ * Access the current tool input data
77
+ *
78
+ * @returns The tool input data or null if not available
79
+ */
80
+ accessToolInput?: <T>() => ToolState<T> | null;
81
+ /**
82
+ * Access the current tool output data
83
+ *
84
+ * @returns The tool output data or null if not available
85
+ */
86
+ accessToolOutput?: <T>() => ToolState<T> | null;
87
+ /**
88
+ * Access metadata about the current tool
89
+ *
90
+ * @returns Tool metadata including schema, description, etc.
91
+ */
92
+ accessToolMetadata?: <T>() => T | null;
93
+ /**
94
+ * Get the current widget state
95
+ *
96
+ * @returns The widget state or null if not available
97
+ */
98
+ getWidgetState?: <T>() => T | null;
99
+ /**
100
+ * Set the widget state
101
+ *
102
+ * @param state - The widget state to persist
103
+ */
104
+ setWidgetState?: <T>(state: T) => void;
105
+ /**
106
+ * Read resource content by URI
107
+ *
108
+ * @param request - The resource request with URI
109
+ */
110
+ readResource?: <T>(request: ResourceRequest) => Promise<T>;
111
+ /**
112
+ * Register a callback for when tool execution is canceled
113
+ *
114
+ * @param callback - Function to call when tool is canceled
115
+ */
116
+ onToolCanceled?: (callback: () => void) => void;
117
+ /**
118
+ * Get available follow-up actions
119
+ *
120
+ * @returns Array of available actions
121
+ */
122
+ followUpActions?: <T>() => T[];
123
+ }
124
+ /**
125
+ * Message severity level
126
+ */
127
+ export type MessageLevel = "info" | "success" | "warning" | "error";
128
+ /**
129
+ * Alert options
130
+ */
131
+ export interface AlertOptions {
132
+ /**
133
+ * The message to display
134
+ */
135
+ message: string;
136
+ /**
137
+ * The severity level of the alert (optional, defaults to "info")
138
+ */
139
+ level?: MessageLevel;
140
+ }
141
+ /**
142
+ * Toast options
143
+ */
144
+ export interface ToastOptions {
145
+ /**
146
+ * The message to display
147
+ */
148
+ message: string;
149
+ /**
150
+ * The severity level of the toast (optional, defaults to "info")
151
+ */
152
+ level?: MessageLevel;
153
+ }
154
+ /**
155
+ * Modal options
156
+ */
157
+ export interface ModalOptions {
158
+ /**
159
+ * Template URI for the custom modal UI
160
+ * Format: "ui://widget/[name].html"
161
+ */
162
+ template: string;
163
+ /**
164
+ * Parameters to pass to the modal
165
+ * Accessible via window.openai.view.params in the modal
166
+ */
167
+ params?: Record<string, unknown>;
168
+ }
169
+ /**
170
+ * ViewSDK API
171
+ */
172
+ export interface ViewSDK {
173
+ /**
174
+ * Display an alert in the host
175
+ *
176
+ * @param options - Alert configuration options
177
+ * @returns Promise that resolves when the alert is displayed
178
+ */
179
+ displayAlert?(options: AlertOptions): Promise<void>;
180
+ /**
181
+ * Display a toast notification in the host
182
+ *
183
+ * @param options - Toast configuration options
184
+ * @returns Promise that resolves when the toast is displayed
185
+ */
186
+ displayToast?(options: ToastOptions): Promise<void>;
187
+ /**
188
+ * Display a modal in the host
189
+ *
190
+ * @param options - Modal configuration options
191
+ * @returns Promise that resolves when the modal is displayed
192
+ */
193
+ displayModal?(options: ModalOptions): Promise<void>;
194
+ /**
195
+ * Get the current theme
196
+ *
197
+ * @returns The current theme or null if not available
198
+ */
199
+ getTheme(): Theme | null;
200
+ }
201
+ export interface DataSDK {
202
+ /**
203
+ * Run a GraphQL query
204
+ *
205
+ * @param query
206
+ * @param variables
207
+ */
208
+ graphql?: <T, V = Record<string, unknown>>(query: string, variables?: V) => Promise<GraphQLResponse<T>>;
209
+ /**
210
+ * Make a request using the Fetch API.
211
+ *
212
+ * @param input - The URL or Request object
213
+ * @param init - Optional RequestInit configuration
214
+ * @returns Promise resolving to Response
215
+ */
216
+ fetch?: typeof fetch;
217
+ }
218
+ export interface GraphQLResponse<T> {
219
+ data: T;
220
+ errors?: {
221
+ message: string;
222
+ locations?: {
223
+ line: number;
224
+ column: number;
225
+ }[];
226
+ path?: string[];
227
+ }[];
228
+ }
229
+ //# sourceMappingURL=platforms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platforms.d.ts","sourceRoot":"","sources":["../../src/core/platforms.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,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AAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACrB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC/C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;KAChB,EAAE,CAAC;CACJ"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+ /**
7
+ * Wraps an SDK factory Promise in a Proxy that throws a clear error if a
8
+ * non-Promise method is accessed, guiding callers who forgot to `await`.
9
+ *
10
+ * Symbol-keyed properties (e.g. Symbol.toStringTag, Symbol.iterator) are
11
+ * always forwarded so the value continues to behave as a proper thenable.
12
+ */
13
+ export declare function wrapSDKPromise<T>(promise: Promise<T>, factoryName: string): Promise<T>;
14
+ //# sourceMappingURL=sdk-promise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-promise.d.ts","sourceRoot":"","sources":["../../src/core/sdk-promise.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAetF"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+ /**
7
+ * Enumeration of possible runtime surfaces
8
+ */
9
+ export declare enum Surface {
10
+ WebApp = "WebApp",
11
+ MicroFrontend = "Micro-Frontend",
12
+ OpenAI = "OpenAI",
13
+ SalesforceACC = "Salesforce-ACC",
14
+ MCPApps = "MCP-Apps",
15
+ Mosaic = "Mosaic"
16
+ }
17
+ /**
18
+ * Returns the surface to use for SDK initialization.
19
+ *
20
+ * Returns the override surface if provided, otherwise falls back
21
+ * to the auto-detected surface.
22
+ */
23
+ export declare function getSurface(override?: Surface): Surface;
24
+ //# sourceMappingURL=surface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surface.d.ts","sourceRoot":"","sources":["../../src/core/surface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,oBAAY,OAAO;IAClB,MAAM,WAAW;IACjB,aAAa,mBAAmB;IAChC,MAAM,WAAW;IACjB,aAAa,mBAAmB;IAChC,OAAO,aAAa;IACpB,MAAM,WAAW;CACjB;AAoCD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAEtD"}