@salesforce/platform-sdk 12.8.0 → 12.10.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/analytics/analytics.d.ts +19 -15
- package/dist/analytics/analytics.d.ts.map +1 -1
- package/dist/analytics/error-listener.d.ts +3 -3
- package/dist/analytics/index.d.ts.map +1 -1
- package/dist/analytics/index.js +1 -1
- package/dist/analytics/method-configs.d.ts +8 -4
- package/dist/analytics/method-configs.d.ts.map +1 -1
- package/dist/analytics/pft.d.ts +22 -16
- package/dist/analytics/pft.d.ts.map +1 -1
- package/dist/analytics/proxy.d.ts +10 -8
- package/dist/analytics/proxy.d.ts.map +1 -1
- package/dist/analytics/types.d.ts +57 -43
- package/dist/analytics/types.d.ts.map +1 -1
- package/dist/{analytics-Dpz22kda.js → analytics-wESbWdca.js} +1 -1
- package/dist/app/index.d.ts +18 -13
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +5 -3
- package/dist/app/webapp.d.ts +5 -2
- package/dist/app/webapp.d.ts.map +1 -1
- package/dist/{capabilities-CKe8z6kZ.js → capabilities-B0mU0_G0.js} +1 -1
- package/dist/chat/index.js +1 -1
- package/dist/core/app.d.ts +31 -22
- package/dist/core/app.d.ts.map +1 -1
- package/dist/core/capabilities.d.ts +26 -17
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/chat.d.ts +155 -125
- package/dist/core/chat.d.ts.map +1 -1
- package/dist/core/data.d.ts +146 -107
- package/dist/core/data.d.ts.map +1 -1
- package/dist/core/extension-attach.d.ts +65 -51
- package/dist/core/extension-attach.d.ts.map +1 -1
- package/dist/core/extension-types.d.ts +214 -153
- package/dist/core/extension-types.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -2
- package/dist/core/lightning.d.ts +11 -19
- package/dist/core/lightning.d.ts.map +1 -1
- package/dist/core/mcpapps-session.d.ts +63 -52
- package/dist/core/mcpapps-session.d.ts.map +1 -1
- package/dist/core/options.d.ts +6 -4
- package/dist/core/options.d.ts.map +1 -1
- package/dist/core/platforms.d.ts +29 -29
- package/dist/core/sdk-promise.d.ts +7 -4
- package/dist/core/sdk-promise.d.ts.map +1 -1
- package/dist/core/surface.d.ts +89 -67
- package/dist/core/surface.d.ts.map +1 -1
- package/dist/core/view.d.ts +164 -113
- package/dist/core/view.d.ts.map +1 -1
- package/dist/data/extensions/index.d.ts +5 -2
- package/dist/data/extensions/index.d.ts.map +1 -1
- package/dist/data/extensions/labels/index.d.ts +72 -49
- package/dist/data/extensions/labels/index.d.ts.map +1 -1
- package/dist/data/extensions/labels/query.d.ts +38 -29
- package/dist/data/extensions/labels/query.d.ts.map +1 -1
- package/dist/data/gql.d.ts +8 -4
- package/dist/data/gql.d.ts.map +1 -1
- package/dist/data/index.d.ts +67 -48
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +265 -242
- package/dist/data/mosaic/fetch.d.ts +24 -15
- package/dist/data/mosaic/fetch.d.ts.map +1 -1
- package/dist/data/mosaic/index.d.ts +13 -9
- package/dist/data/mosaic/index.d.ts.map +1 -1
- package/dist/data/openai/index.d.ts +11 -5
- package/dist/data/openai/index.d.ts.map +1 -1
- package/dist/data/shared/graphql/cache/command.d.ts +60 -46
- package/dist/data/shared/graphql/cache/command.d.ts.map +1 -1
- package/dist/data/shared/graphql/cache/invoker.d.ts.map +1 -1
- package/dist/data/shared/graphql/cache/services.d.ts +21 -11
- package/dist/data/shared/graphql/cache/services.d.ts.map +1 -1
- package/dist/data/shared/graphql/cached-graphql.d.ts +9 -4
- package/dist/data/shared/graphql/cached-graphql.d.ts.map +1 -1
- package/dist/data/shared/graphql/graphql-parse.d.ts +6 -3
- package/dist/data/shared/graphql/graphql-parse.d.ts.map +1 -1
- package/dist/data/shared/graphql/headers.d.ts +34 -27
- package/dist/data/shared/graphql/headers.d.ts.map +1 -1
- package/dist/data/shared/graphql/parse-response.d.ts +31 -23
- package/dist/data/shared/graphql/parse-response.d.ts.map +1 -1
- package/dist/data/shared/graphql/uncached-graphql.d.ts +10 -6
- package/dist/data/shared/graphql/uncached-graphql.d.ts.map +1 -1
- package/dist/data/shared/url-utils.d.ts +1 -1
- package/dist/data/shared/url-utils.d.ts.map +1 -1
- package/dist/data/webapp/accept-language.interceptor.d.ts +26 -9
- package/dist/data/webapp/accept-language.interceptor.d.ts.map +1 -1
- package/dist/data/webapp/client-headers.interceptor.d.ts +4 -3
- package/dist/data/webapp/client-headers.interceptor.d.ts.map +1 -1
- package/dist/data/webapp/csrf/header.interceptor.d.ts +4 -4
- package/dist/data/webapp/csrf/header.interceptor.d.ts.map +1 -1
- package/dist/data/webapp/csrf/retry.policy.d.ts +12 -11
- package/dist/data/webapp/csrf/retry.policy.d.ts.map +1 -1
- package/dist/data/webapp/csrf/token-manager.d.ts +18 -12
- package/dist/data/webapp/csrf/token-manager.d.ts.map +1 -1
- package/dist/data/webapp/fetch.d.ts +12 -8
- package/dist/data/webapp/fetch.d.ts.map +1 -1
- package/dist/data/webapp/index.d.ts +12 -7
- package/dist/data/webapp/index.d.ts.map +1 -1
- package/dist/i18n/locale-format.d.ts +23 -21
- package/dist/i18n/locale-format.d.ts.map +1 -1
- package/dist/i18n/salesforce-backend.d.ts +19 -11
- package/dist/i18n/salesforce-backend.d.ts.map +1 -1
- package/dist/i18n/salesforce-detector.d.ts +22 -14
- package/dist/i18n/salesforce-detector.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/lightning/embedding.d.ts.map +1 -1
- package/dist/lightning/index.d.ts +4 -4
- package/dist/lightning/index.d.ts.map +1 -1
- package/dist/lightning/index.js +2 -2
- package/dist/{surface-Dd2tqrPi.js → surface-DWDgqdpN.js} +18 -13
- package/dist/telemetry/tool-adapter.d.ts.map +1 -1
- package/dist/telemetry/uploader/TelemetryUploader.d.ts.map +1 -1
- package/dist/ui-embedding/index.d.ts.map +1 -1
- package/dist/ui-embedding/session.d.ts +7 -2
- package/dist/ui-embedding/session.d.ts.map +1 -1
- package/dist/ui-embedding/session.js +1 -1
- package/dist/view/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Surface } from './surface';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* A static capability map for each surface.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Indicates which `ChatSDK` and `ViewSDK` methods are available on a given
|
|
7
|
+
* surface. Use this map to conditionally render UI or feature-gate
|
|
8
|
+
* functionality.
|
|
7
9
|
*/
|
|
8
10
|
export interface SurfaceCapabilities {
|
|
9
11
|
callTool: boolean;
|
|
@@ -12,12 +14,14 @@ export interface SurfaceCapabilities {
|
|
|
12
14
|
openLink: boolean;
|
|
13
15
|
accessToolInput: boolean;
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
16
|
-
* `ui/notifications/tool-input-partial
|
|
17
|
-
* `accessToolInputPartial()`.
|
|
18
|
-
* finalized input (`accessToolInput`) is ever available.
|
|
17
|
+
* True when the surface streams partial, still-forming tool input
|
|
18
|
+
* through `ui/notifications/tool-input-partial`. Callers retrieve that
|
|
19
|
+
* input through `accessToolInputPartial()`.
|
|
19
20
|
*
|
|
20
|
-
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* When false, `accessToolInputPartial()` is absent, and only the
|
|
23
|
+
* finalized input from `accessToolInput` is ever available. This
|
|
24
|
+
* capability implies `accessToolInput: true`.
|
|
21
25
|
*/
|
|
22
26
|
toolInputPartial: boolean;
|
|
23
27
|
accessToolOutput: boolean;
|
|
@@ -25,12 +29,14 @@ export interface SurfaceCapabilities {
|
|
|
25
29
|
getWidgetState: boolean;
|
|
26
30
|
setWidgetState: boolean;
|
|
27
31
|
/**
|
|
28
|
-
*
|
|
29
|
-
* `options.structuredContent` arguments to the host
|
|
30
|
-
* `ui/update-model-context`
|
|
31
|
-
* dropped — `state` itself is still persisted and forwarded.
|
|
32
|
+
* True when `setWidgetState` forwards the `options.content` and
|
|
33
|
+
* `options.structuredContent` arguments to the host, per the MCPApps
|
|
34
|
+
* `ui/update-model-context` specification.
|
|
32
35
|
*
|
|
33
|
-
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* When false, the surface silently drops those fields. It still
|
|
38
|
+
* persists and forwards `state` itself. This capability implies
|
|
39
|
+
* `setWidgetState: true`.
|
|
34
40
|
*/
|
|
35
41
|
setWidgetStateModelContext: boolean;
|
|
36
42
|
onToolCanceled: boolean;
|
|
@@ -38,10 +44,13 @@ export interface SurfaceCapabilities {
|
|
|
38
44
|
getHostContext: boolean;
|
|
39
45
|
subscribe: boolean;
|
|
40
46
|
/**
|
|
41
|
-
*
|
|
42
|
-
* that stream distinct tool results into one instance (MCPApps)
|
|
43
|
-
*
|
|
44
|
-
*
|
|
47
|
+
* True when the surface implements `getToolResultGeneration`. Only
|
|
48
|
+
* surfaces that stream distinct tool results into one instance (MCPApps)
|
|
49
|
+
* implement it.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* This field is optional so that adding it does not break existing
|
|
53
|
+
* `SurfaceCapabilities` literals. Treat a missing value as false.
|
|
45
54
|
*/
|
|
46
55
|
toolResultGeneration?: boolean;
|
|
47
56
|
displayAlert: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/core/capabilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/core/capabilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAEnC,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB;;;;;;;;;OASG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB;;;;;;;;;OASG;IACH,0BAA0B,EAAE,OAAO,CAAC;IACpC,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAG/B,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAElB,MAAM,EAAE,OAAO,CAAC;CAChB;AA6ED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CAY5E"}
|
package/dist/core/chat.d.ts
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
import { ThemeMode } from './view';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The message payload for a chat stream.
|
|
4
4
|
*/
|
|
5
5
|
export interface ChatMessage {
|
|
6
6
|
content: string;
|
|
7
7
|
metadata?: Record<string, unknown>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* The payload for a tool execution request.
|
|
11
11
|
*/
|
|
12
12
|
export interface ToolCall {
|
|
13
13
|
toolName: string;
|
|
14
14
|
params?: Record<string, unknown>;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* A request to read a resource.
|
|
18
18
|
*/
|
|
19
19
|
export interface ResourceRequest {
|
|
20
20
|
uri: string;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* A single content block sent to the model.
|
|
24
|
-
* shape (`{ type: "text", text }`, `{ type: "image", data, mimeType }`, etc.).
|
|
23
|
+
* A single content block sent to the model.
|
|
25
24
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* This type mirrors the MCP standard content shape, for example
|
|
27
|
+
* `{ type: "text", text }` or `{ type: "image", data, mimeType }`.
|
|
28
|
+
*
|
|
29
|
+
* The type enumerates the known, closed set as a discriminated union, so a
|
|
30
|
+
* typo in `type` is caught at compile time. The index signature permits
|
|
31
|
+
* additional unknown fields, for forward compatibility with future MCP
|
|
32
|
+
* block types.
|
|
29
33
|
*/
|
|
30
34
|
export type ContentBlock = ({
|
|
31
35
|
type: "text";
|
|
@@ -43,52 +47,62 @@ export type ContentBlock = ({
|
|
|
43
47
|
uri: string;
|
|
44
48
|
} & Record<string, unknown>);
|
|
45
49
|
/**
|
|
46
|
-
*
|
|
47
|
-
* MCPApps `update-model-context`
|
|
48
|
-
*
|
|
50
|
+
* Content fields to send to the model alongside the widget state, per the
|
|
51
|
+
* MCPApps `update-model-context` specification.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* These fields let callers, for example the Base Components team, pass
|
|
55
|
+
* specification-compliant `content` and `structuredContent` fields instead
|
|
56
|
+
* of only `state`.
|
|
49
57
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* OpenAI
|
|
53
|
-
* silently drops them. Use the
|
|
54
|
-
* to detect support before
|
|
58
|
+
* The surface forwards these fields to the host only on the MCPApps
|
|
59
|
+
* surface, through `ui/update-model-context`. On other surfaces, for
|
|
60
|
+
* example OpenAI, the implementation accepts the options for type
|
|
61
|
+
* compatibility, but it silently drops them. Use the
|
|
62
|
+
* `setWidgetStateModelContext` surface capability to detect support before
|
|
63
|
+
* you rely on this behavior.
|
|
55
64
|
*/
|
|
56
65
|
export interface SetWidgetStateOptions {
|
|
57
|
-
/**
|
|
66
|
+
/** Content blocks, for example `[{ type: "text", text: "..." }]`. */
|
|
58
67
|
content?: ContentBlock[];
|
|
59
|
-
/**
|
|
68
|
+
/** A structured (JSON) content payload. */
|
|
60
69
|
structuredContent?: Record<string, unknown>;
|
|
61
70
|
}
|
|
62
71
|
/**
|
|
63
|
-
*
|
|
72
|
+
* The state of a tool's input or output.
|
|
64
73
|
*/
|
|
65
74
|
export interface ToolState<T = unknown> {
|
|
66
75
|
data: T;
|
|
67
76
|
timestamp?: number;
|
|
68
77
|
/**
|
|
69
|
-
* True when `data` is
|
|
70
|
-
* `ui/notifications/tool-input-partial
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
78
|
+
* True when `data` is partial, still-streaming tool input, delivered
|
|
79
|
+
* through `ui/notifications/tool-input-partial`, rather than the
|
|
80
|
+
* finalized input from `ui/notifications/tool-input`.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Partial arguments are best-effort "healed" JSON: the host closes
|
|
84
|
+
* unclosed brackets and braces so the object parses. As a result,
|
|
85
|
+
* fields may be missing or truncated. Use partial data for preview UI
|
|
86
|
+
* only. Never use it for irreversible operations.
|
|
75
87
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
88
|
+
* This field is `true` only on a result from
|
|
89
|
+
* {@link ChatSDK.accessToolInputPartial}. It is absent or `false` on
|
|
90
|
+
* {@link ChatSDK.accessToolInput}, on finalized input, and on output
|
|
91
|
+
* state.
|
|
79
92
|
*/
|
|
80
93
|
partial?: boolean;
|
|
81
94
|
}
|
|
82
95
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* -
|
|
86
|
-
* -
|
|
96
|
+
* The display mode for a widget.
|
|
97
|
+
*
|
|
98
|
+
* - `inline` — the normal embedded view in chat.
|
|
99
|
+
* - `fullscreen` — the expanded, full-screen view.
|
|
100
|
+
* - `pip` — the picture-in-picture floating panel.
|
|
87
101
|
*/
|
|
88
102
|
export type DisplayMode = "inline" | "fullscreen" | "pip";
|
|
89
103
|
/**
|
|
90
|
-
*
|
|
91
|
-
* Values are in CSS pixels.
|
|
104
|
+
* The safe area insets that describe the non-occluded region of the
|
|
105
|
+
* viewport. Values are in CSS pixels.
|
|
92
106
|
*/
|
|
93
107
|
export interface SafeAreaInsets {
|
|
94
108
|
top: number;
|
|
@@ -97,188 +111,198 @@ export interface SafeAreaInsets {
|
|
|
97
111
|
left: number;
|
|
98
112
|
}
|
|
99
113
|
/**
|
|
100
|
-
*
|
|
114
|
+
* The device's interaction capabilities.
|
|
101
115
|
*/
|
|
102
116
|
export interface DeviceCapabilities {
|
|
103
|
-
/**
|
|
117
|
+
/** True when the device supports touch input. */
|
|
104
118
|
touch?: boolean;
|
|
105
|
-
/**
|
|
119
|
+
/** True when the device supports hover (pointer) input. */
|
|
106
120
|
hover?: boolean;
|
|
107
121
|
}
|
|
108
122
|
/**
|
|
109
|
-
*
|
|
123
|
+
* The styles the host provides for theming and font loading.
|
|
110
124
|
*/
|
|
111
125
|
export interface HostStyles {
|
|
112
|
-
/** CSS variables for theming */
|
|
126
|
+
/** CSS variables for theming. */
|
|
113
127
|
variables?: Record<string, string | undefined>;
|
|
114
|
-
/** CSS blocks that
|
|
128
|
+
/** CSS blocks that views can inject. */
|
|
115
129
|
css?: {
|
|
116
|
-
/** CSS for font loading
|
|
130
|
+
/** CSS for font loading, for example `@font-face` rules or `@import` statements. */
|
|
117
131
|
fonts?: string;
|
|
118
132
|
};
|
|
119
133
|
}
|
|
120
134
|
/**
|
|
121
|
-
*
|
|
135
|
+
* A protocol-agnostic host context exposed to chat SDK consumers.
|
|
122
136
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* Contains environment information that the host provides. All fields are
|
|
139
|
+
* optional, because availability depends on the host surface and its
|
|
125
140
|
* configuration.
|
|
126
141
|
*/
|
|
127
142
|
export interface HostContext {
|
|
128
|
-
/**
|
|
143
|
+
/** The current theme mode. */
|
|
129
144
|
theme?: ThemeMode;
|
|
130
|
-
/**
|
|
145
|
+
/** The current display mode of the widget. */
|
|
131
146
|
displayMode?: DisplayMode;
|
|
132
|
-
/**
|
|
147
|
+
/** The maximum height available for the widget, in CSS pixels. */
|
|
133
148
|
maxHeight?: number;
|
|
134
|
-
/**
|
|
149
|
+
/** The safe area insets, for example for a notch or system bars. */
|
|
135
150
|
safeArea?: SafeAreaInsets;
|
|
136
|
-
/**
|
|
151
|
+
/** The host's user agent string. */
|
|
137
152
|
userAgent?: string;
|
|
138
|
-
/** BCP 47 locale tag
|
|
153
|
+
/** The BCP 47 locale tag, for example `en-US`. */
|
|
139
154
|
locale?: string;
|
|
140
|
-
/**
|
|
155
|
+
/** The device's interaction capabilities. */
|
|
141
156
|
deviceCapabilities?: DeviceCapabilities;
|
|
142
|
-
/**
|
|
157
|
+
/** The styles the host provides for theming and font loading. */
|
|
143
158
|
styles?: HostStyles;
|
|
144
159
|
}
|
|
145
160
|
/**
|
|
146
|
-
*
|
|
161
|
+
* The chat SDK API. Method availability depends on the surface's capabilities.
|
|
147
162
|
*/
|
|
148
163
|
export interface ChatSDK {
|
|
149
164
|
/**
|
|
150
|
-
*
|
|
165
|
+
* Sends a message to the host.
|
|
151
166
|
*
|
|
152
|
-
* @param message - The message to send
|
|
167
|
+
* @param message - The message to send.
|
|
153
168
|
*/
|
|
154
169
|
sendMessageToHost?: (message: ChatMessage) => Promise<void>;
|
|
155
170
|
/**
|
|
156
|
-
*
|
|
171
|
+
* Runs a tool on the MCP server.
|
|
157
172
|
*
|
|
158
|
-
* @param toolCall - The tool to call with parameters
|
|
173
|
+
* @param toolCall - The tool to call, with its parameters.
|
|
159
174
|
*/
|
|
160
175
|
callTool?: <T>(toolCall: ToolCall) => Promise<T>;
|
|
161
176
|
/**
|
|
162
|
-
*
|
|
177
|
+
* Returns the current finalized tool input data.
|
|
163
178
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
179
|
+
* @remarks
|
|
180
|
+
* Returns only input delivered through `ui/notifications/tool-input`, so
|
|
181
|
+
* the returned data never changes shape mid-stream, and `partial` is
|
|
182
|
+
* always `false`. Returns `null` while a tool call's arguments are
|
|
183
|
+
* still streaming. To observe still-streaming input, use
|
|
184
|
+
* {@link accessToolInputPartial}.
|
|
168
185
|
*
|
|
169
|
-
* @returns The finalized tool input data or null
|
|
186
|
+
* @returns The finalized tool input data, or `null` when it is not available.
|
|
170
187
|
*/
|
|
171
188
|
accessToolInput?: <T>() => ToolState<T> | null;
|
|
172
189
|
/**
|
|
173
|
-
*
|
|
190
|
+
* Returns the latest partial, still-streaming tool input.
|
|
174
191
|
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
* tool
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
192
|
+
* @remarks
|
|
193
|
+
* Returns the most recent partial snapshot delivered through
|
|
194
|
+
* `ui/notifications/tool-input-partial` while the host is still
|
|
195
|
+
* producing a tool call's arguments. The result is flagged
|
|
196
|
+
* `partial: true`. Once the finalized input arrives, through
|
|
197
|
+
* `ui/notifications/tool-input`, this method clears the partial value
|
|
198
|
+
* and returns `null`. Read {@link accessToolInput} for the finalized
|
|
199
|
+
* value.
|
|
181
200
|
*
|
|
182
|
-
* Partial arguments are best-effort "healed" JSON and may have missing
|
|
183
|
-
* truncated fields (see {@link ToolState.partial}). Use them for
|
|
184
|
-
* only
|
|
201
|
+
* Partial arguments are best-effort "healed" JSON and may have missing
|
|
202
|
+
* or truncated fields (see {@link ToolState.partial}). Use them for
|
|
203
|
+
* preview UI only. Never use them for irreversible operations.
|
|
185
204
|
*
|
|
186
|
-
* Only the MCPApps surface streams partial input
|
|
187
|
-
* `toolInputPartial` surface capability.
|
|
188
|
-
* support it.
|
|
205
|
+
* Only the MCPApps surface streams partial input. Detect support
|
|
206
|
+
* through the `toolInputPartial` surface capability. This method is
|
|
207
|
+
* absent on surfaces that do not support it.
|
|
189
208
|
*
|
|
190
|
-
* @returns The latest partial tool input, or null
|
|
209
|
+
* @returns The latest partial tool input, or `null` when none is streaming.
|
|
191
210
|
*/
|
|
192
211
|
accessToolInputPartial?: <T>() => ToolState<T> | null;
|
|
193
212
|
/**
|
|
194
|
-
*
|
|
213
|
+
* Returns the current tool output data.
|
|
195
214
|
*
|
|
196
|
-
* @returns The tool output data or null
|
|
215
|
+
* @returns The tool output data, or `null` when it is not available.
|
|
197
216
|
*/
|
|
198
217
|
accessToolOutput?: <T>() => ToolState<T> | null;
|
|
199
218
|
/**
|
|
200
|
-
*
|
|
219
|
+
* Returns metadata about the current tool.
|
|
201
220
|
*
|
|
202
|
-
* @returns
|
|
221
|
+
* @returns The tool metadata, for example its schema and description.
|
|
203
222
|
*/
|
|
204
223
|
accessToolMetadata?: <T>() => T | null;
|
|
205
224
|
/**
|
|
206
|
-
*
|
|
225
|
+
* Returns the current widget state.
|
|
207
226
|
*
|
|
208
|
-
* @returns The widget state or null
|
|
227
|
+
* @returns The widget state, or `null` when it is not available.
|
|
209
228
|
*/
|
|
210
229
|
getWidgetState?: <T>() => T | null;
|
|
211
230
|
/**
|
|
212
|
-
*
|
|
231
|
+
* Sets the widget state.
|
|
213
232
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* `
|
|
233
|
+
* @remarks
|
|
234
|
+
* Persists `state` locally, retrievable through `getWidgetState`, and
|
|
235
|
+
* forwards it to the host through `ui/update-model-context`. When you
|
|
236
|
+
* provide `options` with `content`, `structuredContent`, or both, this
|
|
237
|
+
* method forwards those fields to the host in addition to `state`, so
|
|
238
|
+
* the model receives the full MCPApps `update-model-context` payload.
|
|
219
239
|
*
|
|
220
|
-
* `options.content` and `options.structuredContent` are
|
|
221
|
-
*
|
|
222
|
-
* also
|
|
223
|
-
* drop them (see `SetWidgetStateOptions`
|
|
240
|
+
* `options.content` and `options.structuredContent` are forward-only:
|
|
241
|
+
* this method does not store them locally, and `getWidgetState` does
|
|
242
|
+
* not surface them. This method also forwards them only on the MCPApps
|
|
243
|
+
* surface. Other surfaces silently drop them (see `SetWidgetStateOptions`
|
|
244
|
+
* for details).
|
|
224
245
|
*
|
|
225
|
-
* @param state - The widget state to persist
|
|
226
|
-
* @param options -
|
|
227
|
-
* Forward-only and MCPApps-only.
|
|
246
|
+
* @param state - The widget state to persist. `getWidgetState` returns this value.
|
|
247
|
+
* @param options - The `content` and `structuredContent` fields, per the
|
|
248
|
+
* MCPApps specification. Forward-only and MCPApps-only.
|
|
228
249
|
*/
|
|
229
250
|
setWidgetState?: <T>(state: T, options?: SetWidgetStateOptions) => void;
|
|
230
251
|
/**
|
|
231
|
-
*
|
|
252
|
+
* Reads resource content by URI.
|
|
232
253
|
*
|
|
233
|
-
* @param request - The resource request with URI
|
|
254
|
+
* @param request - The resource request, with the URI.
|
|
234
255
|
*/
|
|
235
256
|
readResource?: <T>(request: ResourceRequest) => Promise<T>;
|
|
236
257
|
/**
|
|
237
|
-
*
|
|
258
|
+
* Opens a URL in a new window or tab.
|
|
238
259
|
*
|
|
239
|
-
* @param url - The URL to open
|
|
260
|
+
* @param url - The URL to open.
|
|
240
261
|
*/
|
|
241
262
|
openLink?: (url: string) => Promise<void>;
|
|
242
263
|
/**
|
|
243
|
-
*
|
|
264
|
+
* Registers a callback to run when tool execution is canceled.
|
|
244
265
|
*
|
|
245
|
-
* @param callback -
|
|
266
|
+
* @param callback - The function to call when the tool is canceled.
|
|
246
267
|
*/
|
|
247
268
|
onToolCanceled?: (callback: () => void) => void;
|
|
248
269
|
/**
|
|
249
|
-
*
|
|
270
|
+
* Returns the available follow-up actions.
|
|
250
271
|
*
|
|
251
|
-
* @returns
|
|
272
|
+
* @returns The available actions.
|
|
252
273
|
*/
|
|
253
274
|
followUpActions?: <T>() => T[];
|
|
254
275
|
/**
|
|
255
|
-
*
|
|
276
|
+
* Sets the display mode for the widget.
|
|
256
277
|
*
|
|
257
|
-
* @param mode - The desired display mode
|
|
258
|
-
* @returns
|
|
278
|
+
* @param mode - The desired display mode.
|
|
279
|
+
* @returns The applied display mode.
|
|
259
280
|
*/
|
|
260
281
|
setDisplayMode?: (mode: DisplayMode) => Promise<{
|
|
261
282
|
mode: DisplayMode;
|
|
262
283
|
}>;
|
|
263
284
|
/**
|
|
264
|
-
*
|
|
285
|
+
* Returns the current host context.
|
|
265
286
|
*
|
|
266
|
-
*
|
|
287
|
+
* @remarks
|
|
288
|
+
* Returns environment information from the host surface, including the
|
|
267
289
|
* display mode, theme, locale, dimensions, and device capabilities.
|
|
268
|
-
* Returns an empty object
|
|
290
|
+
* Returns an empty object when the host has not provided context
|
|
291
|
+
* information.
|
|
269
292
|
*
|
|
270
|
-
* @returns The current host context
|
|
293
|
+
* @returns The current host context. An empty object when none is available.
|
|
271
294
|
*/
|
|
272
295
|
getHostContext?: () => HostContext;
|
|
273
296
|
/**
|
|
274
|
-
*
|
|
297
|
+
* Subscribes to data changes from the host.
|
|
275
298
|
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
299
|
+
* @remarks
|
|
300
|
+
* This method gives a platform-agnostic way to listen for changes to
|
|
301
|
+
* tool input, output, metadata, and other SDK data. It works with
|
|
302
|
+
* React's `useSyncExternalStore` and other reactive patterns.
|
|
279
303
|
*
|
|
280
|
-
* @param callback -
|
|
281
|
-
* @returns
|
|
304
|
+
* @param callback - The function to call when data changes.
|
|
305
|
+
* @returns A cleanup function that unsubscribes the callback.
|
|
282
306
|
*
|
|
283
307
|
* @example
|
|
284
308
|
* ```typescript
|
|
@@ -292,16 +316,22 @@ export interface ChatSDK {
|
|
|
292
316
|
*/
|
|
293
317
|
subscribe?: (callback: () => void) => () => void;
|
|
294
318
|
/**
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
319
|
+
* Returns a monotonic count of tool results delivered to this widget
|
|
320
|
+
* instance. The count is 0 before the first result.
|
|
321
|
+
*
|
|
322
|
+
* @remarks
|
|
323
|
+
* The count increments only on a genuinely new tool result. It never
|
|
324
|
+
* increments on a `setWidgetState` echo or a host-context change. This
|
|
325
|
+
* makes it a result-identity token for cases where the payload alone
|
|
326
|
+
* cannot serve that purpose — a host may deliver several results into
|
|
327
|
+
* one instance without clearing `widgetState`.
|
|
300
328
|
*
|
|
301
|
-
* Implemented only where distinct results stream into one instance
|
|
302
|
-
*
|
|
329
|
+
* Implemented only where distinct results stream into one instance
|
|
330
|
+
* (MCPApps). Check `getSurfaceCapabilities(...).toolResultGeneration`
|
|
331
|
+
* before you rely on it.
|
|
303
332
|
*
|
|
304
|
-
* @returns The number of tool results delivered so far
|
|
333
|
+
* @returns The number of tool results delivered so far. 0 when none
|
|
334
|
+
* have been delivered.
|
|
305
335
|
*/
|
|
306
336
|
getToolResultGeneration?: () => number;
|
|
307
337
|
}
|
package/dist/core/chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/core/chat.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,GAAG,EAAE,MAAM,CAAC;CACZ;AAED
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["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