@serenity-star/sdk 2.5.0 → 2.5.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/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/readme.md +35 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-star/sdk",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "The Serenity Star JavaScript SDK provides a convenient way to interact with the Serenity Star API, enabling you to build custom applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
package/readme.md
CHANGED
|
@@ -753,6 +753,41 @@ console.log(
|
|
|
753
753
|
|
|
754
754
|
# Shared Features
|
|
755
755
|
|
|
756
|
+
## Download Attached Files
|
|
757
|
+
|
|
758
|
+
Download files attached to assistant/copilot messages through the SDK (auth handled automatically for both API Key and Token Provider modes).
|
|
759
|
+
|
|
760
|
+
```tsx
|
|
761
|
+
import SerenityClient from '@serenity-star/sdk';
|
|
762
|
+
|
|
763
|
+
const client = new SerenityClient({
|
|
764
|
+
apiKey: '<SERENITY_API_KEY>',
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
const conversation = await client.agents.assistants.createConversation("document-analyzer");
|
|
768
|
+
|
|
769
|
+
// Example attachment URL from message.attached_volatile_knowledges[index].download_url
|
|
770
|
+
const blob = await conversation.downloadAttachment("https://api.serenitystar.ai/api/file/download/<file-id>");
|
|
771
|
+
|
|
772
|
+
// Trigger browser download
|
|
773
|
+
const url = URL.createObjectURL(blob);
|
|
774
|
+
const a = document.createElement("a");
|
|
775
|
+
a.href = url;
|
|
776
|
+
a.download = "document.pdf";
|
|
777
|
+
a.click();
|
|
778
|
+
URL.revokeObjectURL(url);
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
> **Token Provider Auth:** Same API.
|
|
782
|
+
> ```ts
|
|
783
|
+
> const client = new SerenityClient({
|
|
784
|
+
> agentClientCredentials: { agentCode: "chef-assistant", publicKey: "<PUBLIC_KEY>", tokenProvider },
|
|
785
|
+
> });
|
|
786
|
+
>
|
|
787
|
+
> const conversation = await client.agents.assistants.createConversation();
|
|
788
|
+
> const blob = await conversation.downloadAttachment("https://api.serenitystar.ai/api/file/download/<file-id>");
|
|
789
|
+
> ```
|
|
790
|
+
|
|
756
791
|
## Stop Streaming Response
|
|
757
792
|
|
|
758
793
|
You can stop a streaming response at any time by calling `stop()`. This works across all agent types: **Assistants**, **Copilots**, **Activities**, **Proxies**, and **Chat Completions**.
|