@serenity-star/sdk 2.9.0 → 2.11.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serenity-star/sdk",
3
- "version": "2.9.0",
3
+ "version": "2.11.0",
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
@@ -44,6 +44,7 @@ The Serenity Star JS/TS SDK provides a comprehensive interface for interacting w
44
44
  - [Task events](#task-events)
45
45
  - [Citations](#citations)
46
46
  - [Citations on stored messages](#citations-on-stored-messages)
47
+ - [Downloading a cited knowledge file](#downloading-a-cited-knowledge-file)
47
48
  - [Upload Files (Volatile Knowledge)](#upload-files-volatile-knowledge)
48
49
  - [Audio Input](#audio-input)
49
50
  - [Send Audio Messages (Assistants/Copilots)](#send-audio-messages-assistantscopilots)
@@ -1127,6 +1128,8 @@ type CitationSource =
1127
1128
  section_id?: string;
1128
1129
  file_name?: string;
1129
1130
  page_range?: string;
1131
+ is_downloadable?: boolean; // Whether the cited file can be downloaded by authorized users
1132
+ download_url?: string; // Absolute download endpoint, or absent when not downloadable
1130
1133
  }
1131
1134
  | {
1132
1135
  type: "knowledge_website";
@@ -1175,6 +1178,40 @@ for (const message of conversation.messages) {
1175
1178
  }
1176
1179
  ```
1177
1180
 
1181
+ ### Downloading a cited knowledge file
1182
+
1183
+ When an agent's knowledge file is configured as available for download, its citations carry a
1184
+ `download_url` alongside `is_downloadable`. The URL points at the platform's download endpoint but
1185
+ **carries no credentials** — a plain `<a href>` will not work. Use `downloadKnowledgeFile` so the
1186
+ SDK attaches the client's API key or bearer token:
1187
+
1188
+ ```tsx
1189
+ for (const citation of response.citations ?? []) {
1190
+ const source = citation.source;
1191
+ if (source?.type !== "knowledge_file" || !source.download_url) continue;
1192
+
1193
+ const blob = await conversation.downloadKnowledgeFile(source.download_url);
1194
+
1195
+ // In the browser, hand the blob to the user
1196
+ const objectUrl = URL.createObjectURL(blob);
1197
+ const link = document.createElement("a");
1198
+ link.href = objectUrl;
1199
+ link.download = source.file_name ?? "download";
1200
+ link.click();
1201
+ URL.revokeObjectURL(objectUrl);
1202
+ }
1203
+ ```
1204
+
1205
+ Notes:
1206
+
1207
+ - Branch on `download_url` alone. The server derives `is_downloadable` from the URL, so the two
1208
+ can never disagree, and a missing URL already covers non-downloadable files and draft versions.
1209
+ - The URL's origin must match the client's `baseUrl`. A mismatch throws before any request is
1210
+ made, so the credential never reaches an origin you did not configure.
1211
+ - Private, deleted, or missing files all answer `404` — deliberately indistinguishable.
1212
+ - Citations loaded from history via [Get conversation by id](#get-conversation-by-id) do **not**
1213
+ currently include `download_url`.
1214
+
1178
1215
  ## Upload Files (Volatile Knowledge)
1179
1216
 
1180
1217
  Upload files to be used as context in your agent executions. This feature is available for all agent types: **Assistants**, **Copilots**, **Activities**, **Proxies**, and **Chat Completions**. Files are agent-scoped automatically and are included in the next message or execution.