@waniwani/sdk 0.21.5 → 0.22.0-beta.1
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/chat/embed.js +52 -52
- package/dist/chat/embed.js.map +1 -1
- package/dist/chat/index.d.ts +33 -0
- package/dist/chat/index.js +14 -7
- package/dist/chat/index.js.map +1 -1
- package/package.json +4 -3
package/dist/chat/index.d.ts
CHANGED
|
@@ -590,6 +590,11 @@ interface ChatBaseProps {
|
|
|
590
590
|
apiKey?: string;
|
|
591
591
|
/** Chat API endpoint URL. Defaults to Waniwani hosted endpoint */
|
|
592
592
|
api?: string;
|
|
593
|
+
/**
|
|
594
|
+
* Builds the transport turns are sent through. Defaults to the chat's own
|
|
595
|
+
* HTTP transport to `api`, which it also hands the factory as `fallback`.
|
|
596
|
+
*/
|
|
597
|
+
transport?: ChatTransportFactory;
|
|
593
598
|
/** Pre-loaded messages to display when the chat mounts. */
|
|
594
599
|
initialMessages?: ai.UIMessage[];
|
|
595
600
|
/** Initial greeting shown before user types */
|
|
@@ -869,6 +874,28 @@ interface ChatHandle {
|
|
|
869
874
|
eventId: string;
|
|
870
875
|
}>;
|
|
871
876
|
}
|
|
877
|
+
/** What the chat hands a transport factory. */
|
|
878
|
+
interface ChatTransportContext {
|
|
879
|
+
/** The chat's HTTP transport to `api`. */
|
|
880
|
+
fallback: ai.ChatTransport<ai.UIMessage>;
|
|
881
|
+
headers: () => Record<string, string> | undefined;
|
|
882
|
+
/** The channel and visitor a turn is attributed to. */
|
|
883
|
+
body: () => Record<string, unknown>;
|
|
884
|
+
/** True while the thread needs what only `fallback` carries: attachments, model context, saved history. */
|
|
885
|
+
needsFallback: () => boolean;
|
|
886
|
+
onSession: (sessionId: string) => void;
|
|
887
|
+
}
|
|
888
|
+
/** Optional hooks the chat calls on a transport. */
|
|
889
|
+
interface ChatTransportLifecycle {
|
|
890
|
+
/** The visitor started typing their first message. */
|
|
891
|
+
prepare?(): void;
|
|
892
|
+
/** On mount: the conversation this browser already holds, as messages to show. */
|
|
893
|
+
restore?(): Promise<ai.UIMessage[]>;
|
|
894
|
+
/** The visitor started a new conversation. */
|
|
895
|
+
reset?(): void;
|
|
896
|
+
dispose?(): void;
|
|
897
|
+
}
|
|
898
|
+
type ChatTransportFactory = (context: ChatTransportContext) => ai.ChatTransport<ai.UIMessage> & ChatTransportLifecycle;
|
|
872
899
|
|
|
873
900
|
type ModelContextContentBlock = ContentBlock;
|
|
874
901
|
type ModelContextUpdate = {
|
|
@@ -1153,6 +1180,12 @@ interface WaniwaniChatOverrides {
|
|
|
1153
1180
|
api?: string;
|
|
1154
1181
|
/** Override the MCP server URL (rarely needed). */
|
|
1155
1182
|
mcpServerUrl?: string;
|
|
1183
|
+
/**
|
|
1184
|
+
* The app's agent-runtime session route (`/api/mcp/agent/session`). Set,
|
|
1185
|
+
* turns go straight to the agent runtime for a chat the route admits, and
|
|
1186
|
+
* through `api` for one it does not.
|
|
1187
|
+
*/
|
|
1188
|
+
sessionApi?: string;
|
|
1156
1189
|
/**
|
|
1157
1190
|
* AI transparency notice rendered under the input (EU AI Act compliance).
|
|
1158
1191
|
* String overrides the default wording; `false` hides it.
|