saasco-sdk 0.2.3 → 0.2.4
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/index.cjs +46 -46
- package/dist/index.d.cts +32 -23
- package/dist/index.d.ts +32 -23
- package/dist/index.js +45 -45
- package/dist/{support-chat.cjs → support.cjs} +2334 -1425
- package/dist/{support-chat.d.cts → support.d.cts} +20 -21
- package/dist/{support-chat.d.ts → support.d.ts} +20 -21
- package/dist/{support-chat.js → support.js} +2308 -1399
- package/package.json +14 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Iframe-side half of the cross-origin bridge. Runs inside the Saasco
|
|
3
|
-
* `/embed/support
|
|
3
|
+
* `/embed/support` page and talks to the host page's loader over
|
|
4
4
|
* `postMessage`:
|
|
5
5
|
*
|
|
6
6
|
* - inbound host messages (boot/identify/updateJwt/setStateSnapshot/viewport/
|
|
@@ -29,7 +29,7 @@ declare function initEmbedBridge(options: {
|
|
|
29
29
|
declare function setStateSnapshot(snapshot: unknown): void;
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* Public types for the embeddable support
|
|
32
|
+
* Public types for the embeddable support widget. These restate the
|
|
33
33
|
* server wire contracts (`libs/support/shared` / `libs/chat/shared`) locally
|
|
34
34
|
* so the published package carries zero workspace dependencies.
|
|
35
35
|
*/
|
|
@@ -49,17 +49,16 @@ type JSONSchema7Object = {
|
|
|
49
49
|
/**
|
|
50
50
|
* The runtime shape of a tool the support widget can run in the browser. Tools
|
|
51
51
|
* are authored in the dashboard (stored in `Meta`) and served by the public
|
|
52
|
-
* settings endpoint as a `
|
|
52
|
+
* settings endpoint as a `PublicSupportTool`, which the widget rebuilds into this
|
|
53
53
|
* shape via `reconstructDashboardTool`.
|
|
54
54
|
*
|
|
55
55
|
* `execute` runs in the host app's browser when the agent calls a host tool
|
|
56
56
|
* and may touch in-page state, mutations, or SDKs. Server tools (dashboard
|
|
57
|
-
* `execution: "server"`) are proxied by the agent instead
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* Approve/Reject before running.
|
|
57
|
+
* `execution: "server"`) are proxied by the agent instead — the widget must
|
|
58
|
+
* not browser-fetch their absolute endpoints (that causes CORS noise). Tools
|
|
59
|
+
* marked `destructive` pause for an explicit Approve/Reject before running.
|
|
61
60
|
*/
|
|
62
|
-
type
|
|
61
|
+
type SupportTool = {
|
|
63
62
|
/** Shown to the model; 1–2000 chars. */
|
|
64
63
|
description: string;
|
|
65
64
|
/** Pauses for an explicit Approve/Reject before running. */
|
|
@@ -91,7 +90,7 @@ type SupportChatTool = {
|
|
|
91
90
|
contextParameters?: string[];
|
|
92
91
|
};
|
|
93
92
|
/** A canned prompt offered in the empty state; clicking it fills the input. */
|
|
94
|
-
type
|
|
93
|
+
type SupportSuggestion = {
|
|
95
94
|
/** Optional second line shown under the label. */
|
|
96
95
|
description?: string;
|
|
97
96
|
label: string;
|
|
@@ -99,7 +98,7 @@ type SupportChatSuggestion = {
|
|
|
99
98
|
prompt: string;
|
|
100
99
|
};
|
|
101
100
|
type WidgetConfig = {
|
|
102
|
-
/** Origin of the saasco app hosting the support
|
|
101
|
+
/** Origin of the saasco app hosting the support API, e.g. https://app.example.com */
|
|
103
102
|
baseUrl: string;
|
|
104
103
|
/** Read at submit time and appended to the agent's system prompt. */
|
|
105
104
|
getStateSnapshot?: () => unknown;
|
|
@@ -107,16 +106,16 @@ type WidgetConfig = {
|
|
|
107
106
|
placeholder?: string;
|
|
108
107
|
projectId: string;
|
|
109
108
|
/** Canned prompts offered before the first message. */
|
|
110
|
-
suggestions?:
|
|
109
|
+
suggestions?: SupportSuggestion[];
|
|
111
110
|
};
|
|
112
111
|
|
|
113
112
|
/**
|
|
114
|
-
* Plain-fetch transport for the public support
|
|
113
|
+
* Plain-fetch transport for the public support REST endpoints. The
|
|
115
114
|
* embedding origin must be on the project's allowlist (configured in the
|
|
116
115
|
* support widget settings) for cross-origin calls to pass CORS.
|
|
117
116
|
*/
|
|
118
117
|
|
|
119
|
-
type
|
|
118
|
+
type SupportSession = {
|
|
120
119
|
attachments?: ConversationImageAttachment[];
|
|
121
120
|
conversationId: string;
|
|
122
121
|
sessionToken: string;
|
|
@@ -126,7 +125,7 @@ type ConversationImageAttachment = {
|
|
|
126
125
|
fileName?: string;
|
|
127
126
|
url: string;
|
|
128
127
|
};
|
|
129
|
-
type
|
|
128
|
+
type SupportConversationMessage = {
|
|
130
129
|
attachments?: ConversationImageAttachment[];
|
|
131
130
|
/** Replier's first name — present for `role: "team"` (human) messages only. */
|
|
132
131
|
authorName?: string;
|
|
@@ -144,16 +143,16 @@ type ChatThreadMessage = {
|
|
|
144
143
|
plainBody: string | null;
|
|
145
144
|
role: "user" | "team" | "bot";
|
|
146
145
|
};
|
|
147
|
-
type
|
|
146
|
+
type SupportConversation = {
|
|
148
147
|
/** False while a human has taken over — the widget goes persist-only. */
|
|
149
148
|
agentEnabled: boolean;
|
|
150
149
|
conversationId: string;
|
|
151
|
-
messages:
|
|
150
|
+
messages: SupportConversationMessage[];
|
|
152
151
|
state: "open" | "closed" | "snoozed";
|
|
153
152
|
};
|
|
154
153
|
|
|
155
154
|
/**
|
|
156
|
-
* Embeddable customer-facing support
|
|
155
|
+
* Embeddable customer-facing support for third-party apps — an
|
|
157
156
|
* Intercom-style messenger (Home + Messages tabs, branded workspace rows, a
|
|
158
157
|
* restyled chat with a workspace header and per-message meta lines) on top of the
|
|
159
158
|
* persisted support channel:
|
|
@@ -164,7 +163,7 @@ type ChatThread = {
|
|
|
164
163
|
* - an email gate captures a reply-to address before the first message when the
|
|
165
164
|
* host app hasn't already identified the visitor; every message is persisted
|
|
166
165
|
* into the saasco support inbox under `projectId`, with human replies merged
|
|
167
|
-
* into the open chat by polling the
|
|
166
|
+
* into the open chat by polling the conversation endpoint, and
|
|
168
167
|
* - once a human takes the conversation over the agent stream is muted, the
|
|
169
168
|
* customer sees a handoff acknowledgment, a "Waiting for a teammate" indicator
|
|
170
169
|
* until someone replies, then "{name} has joined the conversation" above the
|
|
@@ -174,11 +173,11 @@ type ChatThread = {
|
|
|
174
173
|
* the Saasco iframe-origin `localStorage` so anonymous threads survive reloads
|
|
175
174
|
* (best-effort — Safari/strict-Firefox partition third-party storage; identified
|
|
176
175
|
* users resume server-side via the JWT instead). This component is the iframe
|
|
177
|
-
* app entry: it renders directly into the `/embed/support
|
|
176
|
+
* app entry: it renders directly into the `/embed/support` page (no host-
|
|
178
177
|
* realm blank-iframe wrapper), and the host integrates over the postMessage
|
|
179
178
|
* bridge — identity, JWT, state snapshots, viewport and open/close all arrive
|
|
180
179
|
* through {@link initEmbedBridge} and are read here from the registry.
|
|
181
180
|
*/
|
|
182
|
-
declare function
|
|
181
|
+
declare function SupportWidgetInner({ baseUrl, getStateSnapshot, placeholder, projectId, suggestions, }: WidgetConfig): React.ReactElement;
|
|
183
182
|
|
|
184
|
-
export { type
|
|
183
|
+
export { type JSONSchema7Object, type SupportConversation, type SupportConversationMessage, type SupportSession, type SupportSuggestion, type SupportTool, SupportWidgetInner, type WidgetConfig, initEmbedBridge, setStateSnapshot };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Iframe-side half of the cross-origin bridge. Runs inside the Saasco
|
|
3
|
-
* `/embed/support
|
|
3
|
+
* `/embed/support` page and talks to the host page's loader over
|
|
4
4
|
* `postMessage`:
|
|
5
5
|
*
|
|
6
6
|
* - inbound host messages (boot/identify/updateJwt/setStateSnapshot/viewport/
|
|
@@ -29,7 +29,7 @@ declare function initEmbedBridge(options: {
|
|
|
29
29
|
declare function setStateSnapshot(snapshot: unknown): void;
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* Public types for the embeddable support
|
|
32
|
+
* Public types for the embeddable support widget. These restate the
|
|
33
33
|
* server wire contracts (`libs/support/shared` / `libs/chat/shared`) locally
|
|
34
34
|
* so the published package carries zero workspace dependencies.
|
|
35
35
|
*/
|
|
@@ -49,17 +49,16 @@ type JSONSchema7Object = {
|
|
|
49
49
|
/**
|
|
50
50
|
* The runtime shape of a tool the support widget can run in the browser. Tools
|
|
51
51
|
* are authored in the dashboard (stored in `Meta`) and served by the public
|
|
52
|
-
* settings endpoint as a `
|
|
52
|
+
* settings endpoint as a `PublicSupportTool`, which the widget rebuilds into this
|
|
53
53
|
* shape via `reconstructDashboardTool`.
|
|
54
54
|
*
|
|
55
55
|
* `execute` runs in the host app's browser when the agent calls a host tool
|
|
56
56
|
* and may touch in-page state, mutations, or SDKs. Server tools (dashboard
|
|
57
|
-
* `execution: "server"`) are proxied by the agent instead
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* Approve/Reject before running.
|
|
57
|
+
* `execution: "server"`) are proxied by the agent instead — the widget must
|
|
58
|
+
* not browser-fetch their absolute endpoints (that causes CORS noise). Tools
|
|
59
|
+
* marked `destructive` pause for an explicit Approve/Reject before running.
|
|
61
60
|
*/
|
|
62
|
-
type
|
|
61
|
+
type SupportTool = {
|
|
63
62
|
/** Shown to the model; 1–2000 chars. */
|
|
64
63
|
description: string;
|
|
65
64
|
/** Pauses for an explicit Approve/Reject before running. */
|
|
@@ -91,7 +90,7 @@ type SupportChatTool = {
|
|
|
91
90
|
contextParameters?: string[];
|
|
92
91
|
};
|
|
93
92
|
/** A canned prompt offered in the empty state; clicking it fills the input. */
|
|
94
|
-
type
|
|
93
|
+
type SupportSuggestion = {
|
|
95
94
|
/** Optional second line shown under the label. */
|
|
96
95
|
description?: string;
|
|
97
96
|
label: string;
|
|
@@ -99,7 +98,7 @@ type SupportChatSuggestion = {
|
|
|
99
98
|
prompt: string;
|
|
100
99
|
};
|
|
101
100
|
type WidgetConfig = {
|
|
102
|
-
/** Origin of the saasco app hosting the support
|
|
101
|
+
/** Origin of the saasco app hosting the support API, e.g. https://app.example.com */
|
|
103
102
|
baseUrl: string;
|
|
104
103
|
/** Read at submit time and appended to the agent's system prompt. */
|
|
105
104
|
getStateSnapshot?: () => unknown;
|
|
@@ -107,16 +106,16 @@ type WidgetConfig = {
|
|
|
107
106
|
placeholder?: string;
|
|
108
107
|
projectId: string;
|
|
109
108
|
/** Canned prompts offered before the first message. */
|
|
110
|
-
suggestions?:
|
|
109
|
+
suggestions?: SupportSuggestion[];
|
|
111
110
|
};
|
|
112
111
|
|
|
113
112
|
/**
|
|
114
|
-
* Plain-fetch transport for the public support
|
|
113
|
+
* Plain-fetch transport for the public support REST endpoints. The
|
|
115
114
|
* embedding origin must be on the project's allowlist (configured in the
|
|
116
115
|
* support widget settings) for cross-origin calls to pass CORS.
|
|
117
116
|
*/
|
|
118
117
|
|
|
119
|
-
type
|
|
118
|
+
type SupportSession = {
|
|
120
119
|
attachments?: ConversationImageAttachment[];
|
|
121
120
|
conversationId: string;
|
|
122
121
|
sessionToken: string;
|
|
@@ -126,7 +125,7 @@ type ConversationImageAttachment = {
|
|
|
126
125
|
fileName?: string;
|
|
127
126
|
url: string;
|
|
128
127
|
};
|
|
129
|
-
type
|
|
128
|
+
type SupportConversationMessage = {
|
|
130
129
|
attachments?: ConversationImageAttachment[];
|
|
131
130
|
/** Replier's first name — present for `role: "team"` (human) messages only. */
|
|
132
131
|
authorName?: string;
|
|
@@ -144,16 +143,16 @@ type ChatThreadMessage = {
|
|
|
144
143
|
plainBody: string | null;
|
|
145
144
|
role: "user" | "team" | "bot";
|
|
146
145
|
};
|
|
147
|
-
type
|
|
146
|
+
type SupportConversation = {
|
|
148
147
|
/** False while a human has taken over — the widget goes persist-only. */
|
|
149
148
|
agentEnabled: boolean;
|
|
150
149
|
conversationId: string;
|
|
151
|
-
messages:
|
|
150
|
+
messages: SupportConversationMessage[];
|
|
152
151
|
state: "open" | "closed" | "snoozed";
|
|
153
152
|
};
|
|
154
153
|
|
|
155
154
|
/**
|
|
156
|
-
* Embeddable customer-facing support
|
|
155
|
+
* Embeddable customer-facing support for third-party apps — an
|
|
157
156
|
* Intercom-style messenger (Home + Messages tabs, branded workspace rows, a
|
|
158
157
|
* restyled chat with a workspace header and per-message meta lines) on top of the
|
|
159
158
|
* persisted support channel:
|
|
@@ -164,7 +163,7 @@ type ChatThread = {
|
|
|
164
163
|
* - an email gate captures a reply-to address before the first message when the
|
|
165
164
|
* host app hasn't already identified the visitor; every message is persisted
|
|
166
165
|
* into the saasco support inbox under `projectId`, with human replies merged
|
|
167
|
-
* into the open chat by polling the
|
|
166
|
+
* into the open chat by polling the conversation endpoint, and
|
|
168
167
|
* - once a human takes the conversation over the agent stream is muted, the
|
|
169
168
|
* customer sees a handoff acknowledgment, a "Waiting for a teammate" indicator
|
|
170
169
|
* until someone replies, then "{name} has joined the conversation" above the
|
|
@@ -174,11 +173,11 @@ type ChatThread = {
|
|
|
174
173
|
* the Saasco iframe-origin `localStorage` so anonymous threads survive reloads
|
|
175
174
|
* (best-effort — Safari/strict-Firefox partition third-party storage; identified
|
|
176
175
|
* users resume server-side via the JWT instead). This component is the iframe
|
|
177
|
-
* app entry: it renders directly into the `/embed/support
|
|
176
|
+
* app entry: it renders directly into the `/embed/support` page (no host-
|
|
178
177
|
* realm blank-iframe wrapper), and the host integrates over the postMessage
|
|
179
178
|
* bridge — identity, JWT, state snapshots, viewport and open/close all arrive
|
|
180
179
|
* through {@link initEmbedBridge} and are read here from the registry.
|
|
181
180
|
*/
|
|
182
|
-
declare function
|
|
181
|
+
declare function SupportWidgetInner({ baseUrl, getStateSnapshot, placeholder, projectId, suggestions, }: WidgetConfig): React.ReactElement;
|
|
183
182
|
|
|
184
|
-
export { type
|
|
183
|
+
export { type JSONSchema7Object, type SupportConversation, type SupportConversationMessage, type SupportSession, type SupportSuggestion, type SupportTool, SupportWidgetInner, type WidgetConfig, initEmbedBridge, setStateSnapshot };
|